How mqz0211/oh-my-usb works
Project type and purpose
• Oh My USB is a lightweight, command-line Python tool for crafting BadUSB (HID) payloads.
• It targets penetration testers and hardware hackers, not a multi-service web app or distributed system.
File structure
• Top-level:
• ohmyusb.py – monolithic Python script containing all business logic, CLI, payload presets, safety checks, reporting.
• README.md + LICENSE – documentation and license.
• No separate “frontend” or “backend” services, no external microservices or databases.
README for additional insights
• Core features: preset payloads, custom scripting, stealth mode, payload statistics, dangerous-command detection.
• Invocation flow: user selects preset or writes script → optional stealth delays → safety scan → stats summary → output file.
• No external dependencies besides Python standard library (presumably argparse, random, time, etc.).
a. Main components (logical modules)
• CLI / User Interface – handles user prompts, menu selection.
• Payload Manager – holds built-in presets and loads custom DuckyScript.
• Stealth Mode Processor – injects randomized delays into the payload script.
• Safety Checker – scans commands for disallowed/dangerous patterns.
• Stats Analyzer – computes line counts, delay counts, timing estimates.
• Output Generator – writes final .txt (Rubber Ducky) or other HID formats.
b. Relationships and data flow
1. User → CLI UI: selects preset or custom input
2. CLI UI → Payload Manager: retrieve or accept script lines
3. Payload Manager → Stealth Processor (if enabled): interleave DELAY commands
4. Processed script → Safety Checker: flag/remove dangerous commands
5. Clean script → Stats Analyzer: compute metrics
6. Final script + stats → Output Generator → Written file / clipboard
7. Optional: CLI UI displays stats, safety warnings, suggested external listener.
c. Architectural patterns and principles
• Pipeline design: sequential processing stages (Manager → Stealth → Safety → Stats → Output).
• Single responsibility per module.
• Extensibility hooks: easy to add new presets, output formats, or safety rules.
d. Key technologies
• Python 3.x standard library (argparse or input(), random, time, file I/O).
• DuckyScript syntax (as data format).
• HID-based payload targets (Rubber Ducky, Digispark).