engine package provides the core attack orchestration system for Miku Miku Beam. It coordinates attack workers, manages concurrent execution, and handles real-time statistics reporting.
Package Overview
- Engine: Orchestrates attack lifecycles and worker coordination
- Registry: Maps attack types to their worker implementations
- AttackWorker Interface: Contract for implementing attack methods
Core Types
AttackKind
AttackParams
Proxy
AttackStats
time.Time
When this stat was recorded
int64
Packets sent in the last second
int64
Cumulative packets sent since attack start
int
Number of proxies in use
string
Optional log message (e.g., “Miku miku beam from 1.2.3.4:8080 to target.com”)
Engine
NewEngine
Start
<-chan AttackStats
Channel that receives statistics updates every second
error
Error if attack could not be started (always nil in current implementation)
- Creates
params.Threadsconcurrent worker goroutines (defaults toruntime.NumCPU()) - Each thread fires at intervals defined by
params.PacketDelay - Randomly selects a proxy and user agent for each packet
- Aggregates statistics and sends updates every 1 second
- Automatically stops after
params.Durationelapses - Closes the stats channel when the attack ends
Stop
StopAll
IsRunning
GetRunningAttacks
Registry
AttackKind values to their worker implementations.
NewRegistry
Register
Get
false if not registered.
ListKinds
Logging Helpers
SendAttackLog
<source> is either the proxy address or <local> if no proxy is used.
SendAttackLogIfVerbose
verbose is true. Used by workers to respect the AttackParams.Verbose flag.
Example (from worker implementation):
Architecture
Concurrency Model
- Thread Pool: Engine spawns
Nworker threads (configured viaAttackParams.Threads) - Per-Thread Ticker: Each thread fires at
PacketDelayintervals - Fire-and-Forget: Worker
Fire()calls are dispatched in goroutines to avoid blocking - Statistics Aggregation: A dedicated goroutine collects and sends stats every second
Attack Lifecycle
See Also
- AttackWorker Interface - Implementing custom attack methods
- Proxy Package - Loading and filtering proxies