Overview
Miku Miku Beam is organized into four main components that work together to provide both CLI and web-based stress testing capabilities.Directory Layout
Component Breakdown
CLI (cmd/mmb-cli/)
The command-line interface for running attacks directly from the terminal.
- Colored terminal output with real-time statistics
--verboseflag for detailed attack logs--no-proxyflag to run without proxies--threadsflag to control concurrency--duration,--delay,--packet-sizefor attack configuration
Server (cmd/mmb-server/)
Web server with Socket.IO support for the browser-based interface.
- REST API endpoints (
/attacks,/configuration) - Real-time WebSocket communication via Socket.IO
- Serves static web client files
- Per-client attack instance management
- Runs on
http://localhost:3000by default
POST /api/attacks- Start an attackDELETE /api/attacks- Stop an attackGET /api/configuration- Get configuration- WebSocket events for real-time stats
Core Engine (internal/)
The heart of the application containing attack implementations and coordination logic.
Engine (internal/engine/)
Attack coordination and management system.
engine.go (255 lines)
engine.go (255 lines)
Core engine implementation:
Enginestruct - Manages multiple concurrent attacksAttackInstance- Represents a single running attackStart()- Launches attacks with multiple threadsStop()- Cancels specific attacksStopAll()- Terminates all running attacks- Multi-threaded worker dispatch
- Real-time statistics aggregation
registry.go (28 lines)
registry.go (28 lines)
Attack worker registry:
Registrystruct - Maps attack kinds to workersRegister()- Adds new attack methodsGet()- Retrieves worker by attack kindListKinds()- Returns all registered attacks
logging.go
logging.go
Logging utilities:
SendAttackLogIfVerbose()- Conditional log sending- Prevents channel blocking
- Formats attack statistics
Attacks (internal/attacks/)
Individual attack method implementations organized by protocol.
HTTP Attacks (internal/attacks/http/)
HTTP Attacks (internal/attacks/http/)
flood.go - HTTP Flood Attack
- Sends random GET/POST requests
- Configurable payload sizes
- Random method selection based on packet size
- User agent rotation
- Mimics real browser behavior
- Handles redirects automatically
- Manages cookies and sessions
- Realistic headers and resources
- Sends slow HTTP requests
- Keeps connections open
- Exhausts server resources
- Partial header sending
TCP Attacks (internal/attacks/tcp/)
TCP Attacks (internal/attacks/tcp/)
flood.go - TCP Flood Attack
- Raw TCP packet flooding
- Random payload generation
- Direct connection establishment
- Proxy support via
netutil.DialTCP()
Game Attacks (internal/attacks/game/)
Game Attacks (internal/attacks/game/)
minecraft_ping.go - Minecraft Server Ping
- Minecraft protocol implementation
- Server status requests
- MOTD (Message of the Day) queries
- Player count polling
Configuration (internal/config/)
Configuration management for runtime settings.
config.go
config.go
- Server port configuration
- Data file paths (proxies, user agents)
- Default attack parameters
- Environment variable support
Network Utilities (internal/netutil/)
Network helpers with proxy support.
httpdial.go
httpdial.go
HTTP client creation with proxy support:
DialedHTTPClient()- Creates HTTP client with proxy- Custom transport configuration
- Timeout and retry logic
- TLS configuration
tcpdial.go
tcpdial.go
TCP connection helpers:
DialTCP()- Establishes TCP connection via proxy- SOCKS5 proxy support
- HTTP CONNECT tunneling
- Connection timeout handling
Proxy Management (internal/proxy/)
Proxy loading and filtering system.
loader.go
loader.go
- Loads proxies from
data/proxies.txt - Parses proxy formats:
protocol://user:pass@host:portprotocol://host:porthost:port(defaults to http)host(defaults to port 8080)
- Validates proxy configurations
- Filters out invalid entries
Shared Packages (pkg/)
Reusable packages that can be imported by external projects.
API Types (pkg/api/)
types.go
types.go
Shared API types and interfaces:
- Request/response structures
- Attack configuration types
- Statistics data models
- Error definitions
Target Utilities (pkg/target/)
node.go
node.go
Target parsing and validation:
Nodestruct - Represents parsed targetParseTarget()- Parses URLs and addressesToURL()- Converts back to URL format- Protocol/host/port extraction
Web Client (web-client/)
React-based frontend with Miku theme and real-time updates.
- Modern UI with Miku theme
- Real-time attack visualization
- Socket.IO integration for live updates
- Attack configuration interface
- Proxy/UA editor built-in
- Multi-attack support (multiple tabs)
- Built files go to
bin/web-client/ - Server serves from this location
- Production builds are optimized and minified
Build System
TheMakefile provides convenient build commands:
Build Flow
Data Files
Runtime data stored in thedata/ directory:
Proxies (data/proxies.txt)
One proxy per line in various formats:
User Agents (data/uas.txt)
One user agent string per line:
These files can be edited through the web interface or manually.
Workflow Diagrams
Attack Execution Flow
Multi-Client Architecture
Each client maintains its own isolated attack instance.Development Tips
Adding New Features
New Attack Method
- Create worker in
internal/attacks/ - Register in
cmd/mmb-cli/andcmd/mmb-server/ - Add to web client dropdown
New Protocol Support
- Create package in
internal/attacks/protocol/ - Implement
AttackWorkerinterface - Add network helpers to
internal/netutil/if needed
Engine Enhancement
Modify
internal/engine/engine.go- Update
AttackParamsstruct - Add new stats fields
- Enhance worker dispatch logic
UI Changes
Edit files in
web-client/src/- Update components
- Rebuild with
make webclient - Server automatically serves new build
Common File Locations
Where do I add a new attack type?
Where do I add a new attack type?
- Create file in
internal/attacks/[protocol]/[name].go - Add constant to
internal/engine/engine.go - Register in both
cmd/mmb-cli/main.goandcmd/mmb-server/main.go
Where are attack parameters defined?
Where are attack parameters defined?
internal/engine/engine.go - See AttackParams structWhere is the proxy logic?
Where is the proxy logic?
- Loading:
internal/proxy/loader.go - HTTP usage:
internal/netutil/httpdial.go - TCP usage:
internal/netutil/tcpdial.go
Where are API endpoints defined?
Where are API endpoints defined?
cmd/mmb-server/main.go - HTTP handlers and Socket.IO eventsNext Steps
Add Attack Methods
Learn how to implement custom attack methods
Contributing
Submit your enhancements to the project