Skip to main content
The 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

The engine package consists of three main components:
  • 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

Enumerates supported attack types. Constants:

AttackParams

Common parameters passed to all attack workers.

Proxy

Represents a network proxy for routing attacks.

AttackStats

Live statistics reported by the engine and workers.
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

Coordinates attack lifecycles, manages concurrent workers, and aggregates statistics.

NewEngine

Creates a new Engine with the given worker registry. Example:

Start

Launches a new attack with the given ID. If an attack with the same ID is already running, it will be stopped first. Parameters: Returns:
<-chan AttackStats
Channel that receives statistics updates every second
error
Error if attack could not be started (always nil in current implementation)
Behavior:
  • Creates params.Threads concurrent worker goroutines (defaults to runtime.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.Duration elapses
  • Closes the stats channel when the attack ends
Example:

Stop

Cancels a specific attack by ID. Safe to call if attack doesn’t exist. Example:

StopAll

Cancels all running attacks.

IsRunning

Checks if a specific attack is currently running.

GetRunningAttacks

Returns a list of all running attack IDs.

Registry

Maps AttackKind values to their worker implementations.

NewRegistry

Creates an empty worker registry.

Register

Registers a worker implementation for an attack kind. Example:

Get

Retrieves the worker for a given attack kind. Returns false if not registered.

ListKinds

Returns all registered attack kinds.

Logging Helpers

SendAttackLog

Sends a standardized attack log message to the stats channel. Non-blocking - safe to call on closed channels. Log Format:
Where <source> is either the proxy address or <local> if no proxy is used.

SendAttackLogIfVerbose

Conditionally sends a log only if verbose is true. Used by workers to respect the AttackParams.Verbose flag. Example (from worker implementation):

Architecture

Concurrency Model

  1. Thread Pool: Engine spawns N worker threads (configured via AttackParams.Threads)
  2. Per-Thread Ticker: Each thread fires at PacketDelay intervals
  3. Fire-and-Forget: Worker Fire() calls are dispatched in goroutines to avoid blocking
  4. Statistics Aggregation: A dedicated goroutine collects and sends stats every second

Attack Lifecycle

See Also