Overview
Miku Miku Beam is built with a modular architecture that separates concerns into distinct layers: the attack engine, worker implementations, proxy handling, and network utilities.Core Components
Attack Engine
The engine (internal/engine/engine.go) is the heart of Miku Miku Beam, coordinating all attack operations and managing worker lifecycles.
Engine Responsibilities
- Managing multiple concurrent attacks with unique IDs
- Dispatching work across configurable thread pools
- Aggregating and reporting real-time statistics
- Handling graceful start/stop of attack instances
Key Structures
Attack Lifecycle
- Start: Creates a new attack instance with unique ID
- Thread Spawning: Spawns worker threads (defaults to CPU count)
- Packet Dispatch: Each thread dispatches packets at configured intervals
- Stats Aggregation: Background goroutine aggregates stats every second
- Stop: Context cancellation terminates all workers gracefully
- Selects random proxies and user agents for each packet
- Tracks total packets sent across all threads
- Prevents duplicate attack IDs by stopping existing instances
- Uses context cancellation for clean shutdown
Thread count defaults to
runtime.NumCPU() when not specified, optimizing for the host machine’s capabilities.Worker Registry
The registry (internal/engine/registry.go) maintains a mapping of attack methods to their implementations.
Attack Methods
Five attack types are registered:| Attack Kind | Protocol | Description |
|---|---|---|
http_flood | HTTP/HTTPS | High-volume HTTP GET/POST requests |
http_bypass | HTTP/HTTPS | Browser-mimicking requests with randomization |
http_slowloris | HTTP/HTTPS | Slow header transmission attack |
tcp_flood | TCP | Raw TCP packet flooding |
minecraft_ping | TCP | Minecraft server status requests |
Attack Worker Interface
All attack methods implement theAttackWorker interface:
The
Fire method should return quickly and not block. The engine dispatches calls concurrently using goroutines.Attack Parameters
Common parameters shared across all attack methods:Target Parsing
Targets are parsed into aNode structure (pkg/target/node.go) that handles:
- URLs with scheme:
http://example.com:8080/path - Host:port notation:
192.168.1.1:80 - Hostname only:
example.com(defaults to port 80)
ToURL() method automatically infers HTTPS for port 443, otherwise defaults to HTTP for L7 attacks.
Statistics & Monitoring
The engine provides real-time attack statistics through a channel:Aggregation Strategy
- Each worker thread increments a shared counter (with mutex protection)
- Background goroutine samples counter every second
- Calculates delta to determine packets/second rate
- Sends stats only when there’s activity or on first tick
Concurrency Model
Thread Distribution
Fire() call is dispatched in its own goroutine for non-blocking operation.
Context Cancellation
- Engine stores
cancelfunction inAttackInstance Stop()calls cancel, propagating to all goroutines- Workers check
<-ctx.Done()and exit gracefully - Stats channel is closed after all workers terminate
Configuration
Global configuration (internal/config/config.go) uses TOML format:
Network Layer
Network utilities (internal/netutil/) provide abstraction for:
- HTTP clients with proxy support (HTTP, HTTPS, SOCKS4, SOCKS5)
- TCP connections with proxy tunneling (HTTP CONNECT, SOCKS)
- TLS wrapping for secure connections
- Browser mimicking with realistic headers