Overview
Miku Miku Beam’s architecture makes it easy to add new attack methods. This guide walks you through creating a custom attack implementation from scratch.Attack Method Architecture
Each attack method consists of:- A worker that implements the
AttackWorkerinterface - Registration in the engine’s registry
- Frontend integration for the web UI (optional)
Implementation Steps
1
Create Attack Worker
Create a new file in the appropriate directory under
internal/attacks/:- HTTP-based attacks →
internal/attacks/http/ - TCP/UDP attacks →
internal/attacks/tcp/ - Game-specific attacks →
internal/attacks/game/ - New protocol → Create new directory
internal/attacks/yourprotocol/
Worker Interface
All attack workers must implement theAttackWorker interface:Example Implementation
Here’s a complete example from the actual codebase:internal/attacks/yourprotocol/yourattack.go
2
Define Attack Kind
Add your attack type to the
AttackKind enum in internal/engine/engine.go:internal/engine/engine.go
3
Register the Attack
Register your worker in the engine’s initialization code.For the server (For the CLI (
cmd/mmb-server/main.go):cmd/mmb-server/main.go
cmd/mmb-cli/main.go):cmd/mmb-cli/main.go
4
Add to Web Client (Optional)
Update the web client to include your new attack method in the dropdown:
web-client/src/...
Real-World Examples
Let’s look at actual implementations from the codebase:HTTP Flood Worker
Frominternal/attacks/http/flood.go:
Notice how the worker:
- Uses the provided context for cancellation support
- Leverages the proxy parameter for routing
- Sends verbose logs only when enabled
- Returns quickly without blocking
TCP Flood Worker
Frominternal/attacks/tcp/flood.go:
Best Practices
Context Handling
Proxy Usage
Always use the provided proxy parameter:Verbose Logging
Only send logs when verbose mode is enabled:Error Handling
Testing Your Attack
Build and Test
Test Without Proxies
Test in Web Interface
- Start the server:
make run-server - Open
http://localhost:3000 - Select your attack method
- Configure parameters
- Monitor real-time stats
Attack Parameters Reference
Your worker receives these parameters:Common Patterns
HTTP-Based Attacks
TCP-Based Attacks
UDP-Based Attacks
Troubleshooting
Attack not appearing in CLI
Attack not appearing in CLI
Make sure you’ve:
- Defined the
AttackKindconstant - Registered the worker in
cmd/mmb-cli/main.go - Rebuilt the CLI binary:
make cli
Attack not appearing in web UI
Attack not appearing in web UI
Check that you’ve:
- Added it to the attack methods array in the web client
- Registered it in
cmd/mmb-server/main.go - Rebuilt both server and web client:
make all
Proxy errors or timeouts
Proxy errors or timeouts
- Verify proxies in
data/proxies.txtare valid - Test with
--no-proxyflag to isolate the issue - Use
netutilhelpers instead of direct connections
No verbose logs appearing
No verbose logs appearing
- Ensure you’re calling
SendAttackLogIfVerbose - Check you’re passing the log channel correctly
- Verify
--verboseflag is set when testing
Next Steps
Project Structure
Understand the full codebase organization
Contributing Guide
Learn how to submit your implementation
Now you’re ready to create powerful new attack methods! Remember to test thoroughly and submit a PR when you’re done.