Rustsploit Developer Guide
Reference manual for maintainers and contributors. Covers the architecture, build-time module discovery, shell ergonomics, and authoring guidelines for exploits, scanners, and credential modules.
Table of Contents
Project Overview
Rustsploit is a Rust-first re-imagining of RouterSploit:
-
Async-native (Tokio) for scalable brute forcing and network IO
-
Auto-discovered modules categorized as
exploits,scanners, andcreds -
Interactive shell + CLI runner referencing the same dispatch layer
-
IPv4/IPv6-friendly: target normalization happens uniformly
-
Carefully colored, concise output designed for operators on remote consoles
Code Layout
rustsploit/
├── Cargo.toml
├── build.rs # Generates dispatcher code by scanning src/modules
├── src/
│ ├── main.rs # Entry point, selects CLI or shell mode (includes input validation)
│ ├── cli.rs # Clap-based CLI parser and dispatcher
│ ├── shell.rs # Interactive shell loop + UX helpers (includes sanitization)
│ ├── api.rs # REST API server with auth, rate limiting, and security
│ ├── config.rs # Global configuration with target validation
│ ├── commands/ # Dispatch glue for exploits/scanners/creds
│ │ ├── mod.rs
│ │ ├── exploit.rs
│ │ ├── exploit_gen.rs # build.rs output
│ │ ├── scanner.rs
│ │ ├── scanner_gen.rs # build.rs output
│ │ ├── creds.rs
│ │ └── creds_gen.rs # build.rs output
│ ├── modules/ # Fully auto-discovered attack modules
│ │ ├── exploits/
│ │ ├── scanners/
│ │ └── creds/
│ └── utils.rs # Shared helpers (proxy parsing, module lookup, validation)
├── docs/
│ └── readme.md # This document
├── lists/
│ ├── readme.md # Wordlist + data file catalogue
│ ├── rtsp-paths.txt
│ ├── rtsphead.txt
│ └── telnet-default/ # Default telnet credentials
└── README.md # Product overview
Key takeaway: modules are just Rust files under src/modules/**. Add pub mod my_module; in the local mod.rs, and the build script handles the rest.
Build Pipeline & Module Discovery
build.rsscan: Before compilation, build.rs walkssrc/modules(depth-limited) looking for.rsfiles that are notmod.rs.- Signature detection: If a file exposes
pub async fn run(, it is treated as a callable module. - Name generation: Both a short name (
ssh_bruteforce) and qualified path (creds/generic/ssh_bruteforce) are registered. - Dispatcher emission: Three files (
exploit_gen.rs,scanner_gen.rs,creds_gen.rs) are emitted with exhaustivematchstatements that map names →use crate::modules::...::run. - Shell + CLI usage: When users invoke
use exploits/fooor--module foo, the dispatcher resolves the actual function.
Because the dispatcher is generated at build time, there is no manual registry drift as long as modules live in the right folder and export run.
Shell Architecture
The shell lives in src/shell.rs. Highlights:
-
Context:
ShellContextstorescurrent_module,current_target. -
Prompt helpers: Inline functions prompt for paths, yes/no decisions, timeouts, etc.
-
Shortcut parsing:
split_command+resolve_commandnormalize input (e.g.,f1 ssh,pon,ptest) to canonical keys. -
Command palette:
render_help()prints a colorized table for quick reference. -
Run pipeline: On
run/go, the shell enforces:- Module selected
- Target set
-
State reset: On exit, nothing is persisted intentionally for OPSEC.
Extensions (tab completion, history) can be added by wrapping the loop with a line-editor crate, but are omitted today to keep dependencies minimal.
Command Chaining
The shell supports command chaining via the & separator, allowing multiple commands to be executed in a single line:
rsf> u creds/generic/ssh_bruteforce & set target 10.10.10.10 & go
rsf> f1 ssh & u creds/generic/ssh_bruteforce & set target 192.168.1.1
Commands are parsed and executed sequentially from left to right. This is useful for scripting workflows or quick module setup.
Command-Line Interface
src/cli.rs uses Clap to expose three commands:
--command exploit|scanner|creds--module <name>(short or qualified, same mapping as the shell)--target <host|IP>
Example:
cargo run -- --command exploit --module heartbleed --target 203.0.113.12
If the module needs additional parameters, it can prompt interactively (e.g., brute-force modules ask for wordlists even in CLI mode). For automated pipelines, modules should provide sensible defaults or accept environment variables.
Security & Input Validation
RustSploit implements comprehensive security measures throughout the codebase. When contributing, follow these guidelines:
Input Validation Constants
Located across core modules, these constants enforce safe limits:
| File | Constant | Value | Purpose |
|---|---|---|---|
shell.rs |
MAX_INPUT_LENGTH |
4096 | Maximum shell input length |
shell.rs |
MAX_TARGET_LENGTH |
512 | Maximum target string length |
shell.rs |
MAX_URL_LENGTH |
2048 | Maximum URL length |
shell.rs |
MAX_PATH_LENGTH |
4096 | Maximum file path length |
shell.rs |
MAX_PROXY_LIST_SIZE |
10,000 | Maximum proxy entries |
utils.rs |
MAX_FILE_SIZE |
10MB | Maximum file size to read |
utils.rs |
MAX_PROXIES |
100,000 | Maximum proxies to process |
config.rs |
MAX_HOSTNAME_LENGTH |
253 | DNS hostname limit |
api.rs |
MAX_REQUEST_BODY_SIZE |
1MB | API request body limit |
api.rs |
MAX_TRACKED_IPS |
100,000 | IP tracker limit |
Security Patterns
When writing modules or core code, follow these patterns:
1. Input Length Validation
if input.len() > MAX_INPUT_LENGTH {
return Err(anyhow!("Input too long (max {} characters)", MAX_INPUT_LENGTH));
}
2. Control Character Rejection
if input.chars().any(|c| c.is_control()) {
return Err(anyhow!("Input cannot contain control characters"));
}
3. Path Traversal Prevention
if input.contains("..") || input.contains("//") {
return Err(anyhow!("Path traversal detected"));
}
4. Hostname/Target Validation
// Use the framework's normalize_target function for comprehensive validation
use crate::utils::normalize_target;
let normalized = normalize_target(raw_target)?;
// This handles IPv4, IPv6, hostnames, URLs, CIDR notation with full validation
For manual validation:
use regex::Regex;
let valid_chars = Regex::new(r"^[a-zA-Z0-9.\-_:\[\]]+$").unwrap();
if !valid_chars.is_match(target) {
return Err(anyhow!("Invalid characters in target"));
}
5. Overflow Protection
// Use saturating_add to prevent overflow
counter = counter.saturating_add(1);
6. Prompt Attempt Limiting
const MAX_ATTEMPTS: u8 = 10;
let mut attempts = 0;
loop {
attempts += 1;
if attempts > MAX_ATTEMPTS {
println!("Too many invalid attempts. Using default.");
return Ok(default);
}
// ... prompt logic
}
API Security
The API server (api.rs) implements:
- Request Body Limiting:
RequestBodyLimitLayerprevents DoS via large payloads - Rate Limiting: 3 failed auth attempts = 30 second block
- Auto-cleanup: Old entries purged when limits exceeded
- IP Tracking: With automatic rotation when suspicious activity detected
File Operations
When reading files, always:
- Validate the path doesn't contain
.. - Use
canonicalize()to resolve the real path - Check file size before reading
- Skip symlinks for security
Honeypot Detection
The framework automatically runs honeypot detection before module execution when a target is set. The basic_honeypot_check function in utils.rs:
- Scans 200 common ports with 250ms timeout per port
- If 11+ ports are open, warns that the target is likely a honeypot
- Runs automatically in the shell's
runandrun_allcommands - Can be called manually:
utils::basic_honeypot_check(&ip).await
This helps operators identify potentially deceptive targets before spending time on them.
Authoring Modules
Every module must export:
use anyhow::Result;
pub async fn run(target: &str) -> Result<()> {
// ...
Ok(())
}
Guidelines:
- Location: choose one of
src/modules/{exploits,scanners,creds}. Use subfolders for vendor families (e.g.,exploits/cisco/). mod.rs: addpub mod your_module;in the siblingmod.rs. Without this, the build script ignores the file.- Async I/O: prefer
reqwest,tokio::net,tokio::process, etc. Synchronous blocking code should be wrapped withtokio::task::spawn_blockingwhere possible (see SSH module). - Logging: leverage
coloredfor clarity, but keep messages short and actionable. Use[+],[-],[!],[*]prefixes consistently. - Error handling: bubble up with context (
anyhow::Context) so the shell/CLI surface meaningful errors. - Wordlists / resources: store under
lists/and document them inlists/readme.md. - Optional interactive mode: If the module benefits from multiple code paths, optionally expose
run_interactiveand call it fromrun.
skeleton
use anyhow::{Context, Result};
pub async fn run(target: &str) -> Result<()> {
println!("[*] Checking {}", target);
let url = format!("http://{}/status", target);
let body = reqwest::get(&url)
.await
.with_context(|| format!("failed to reach {}", url))?
.text()
.await
.context("failed to fetch body")?;
if body.contains("vulnerable") {
println!("[+] {} appears vulnerable", target);
} else {
println!("[-] {} not vulnerable", target);
}
Ok(())
}
Credential Modules: Best Practices
Modules like FTP/SSH/Telnet/POP3/SMTP/RTSP/RDP/MQTT follow shared patterns:
-
Input prompts: ask for port, username/password wordlists, concurrency limit, stop-on-success toggle, output file, verbose logging.
-
Sanitation: trim wordlist entries, skip blanks, provide early exits if lists are empty.
-
Concurrency:
- Use
tokio::Semaphorefor asynchronous modules (FTP, SSH, MQTT). - Use
threadpool+crossbeam-channelfor synchronous protocols (Telnet, POP3, SMTP).
- Use
-
Adaptive throttling: Some modules (FTP) sample CPU/RAM to avoid saturating the host.
-
TLS/STARTTLS: Accept invalid certs for offensive tooling convenience, but note this clearly.
-
Result persistence: Offer to write
host -> user:passpairs to a local file (in./by default). -
IPv6: Use helpers like
format_addrto wrap IPv6 addresses in brackets and support port suffixes. -
Error classification: Implement comprehensive error types (ConnectionFailed, AuthenticationFailed, Timeout, etc.) for better debugging and reporting.
-
Memory management: For large wordlists (>150MB), implement streaming mode to prevent memory exhaustion (see RDP module for reference).
-
Timing Attacks: When implementing user enumeration, use statistical analysis (samples/variance) rather than simple thresholds to account for network jitter (see SSH User Enum module).
-
Protocol compliance: Implement full protocol support where applicable (e.g., Telnet IAC negotiation, MQTT 3.1.1).
-
FTP Bruteforce Enhancements:
- 5 Operation Modes: Single Target, Subnet (CIDR), Batch Scanner, Quick Default Check, Subnet Default Check
- JSON configuration system with load/save/validation
- 32 utility functions (streaming wordlists, JSON/CSV export, network intelligence)
- Framework
normalize_target()integration
-
L2TP/IPsec Module:
- Multi-platform: strongswan, xl2tpd, pppd, NetworkManager (Linux), rasdial (Windows), networksetup (macOS)
- Proper IPsec Phase 1/2 and L2TP session management
- L2TPv2 packet crafting with AVP encoding
Recent Module Enhancements
-
CVE-2026-24061 Exploit:
- GNU inetutils-telnetd Remote Authentication Bypass via
NEW_ENVIRON - Automated payload execution and interactive shell session
- Mass-scan support with multi-port parallelization and exclusion ranges
- Verified logic for IAC (Interpret As Command) telnet negotiation
- GNU inetutils-telnetd Remote Authentication Bypass via
-
Telnet Module:
- Full IAC (Interpret As Command) negotiation with proper option handling
- Enhanced error classification with specific error types
- Verbose mode for quick checks with detailed attempt reporting
- Improved buffer handling using
BytesMutwith size limits
-
RDP Module:
- Streaming failover for password files >150MB
- Comprehensive error classification with 8 error types
- Multiple security level support (Auto, NLA, TLS, RDP, Negotiate)
- Command injection prevention via argument sanitization
-
MQTT Module:
- Full MQTT 3.1.1 protocol implementation
- Proper variable-length encoding and UTF-8 string encoding
- CONNACK response parsing with error classification
-
SSH User Enumeration:
- Implements timing-based enumeration inspired by CVE-2018-15473
- Statistical analysis using standard deviation to identify valid users
- precise
tokio::time::Instantmeasurements for authentication attempts
-
Directory Bruteforcer:
DirBruteConfigstruct handles comprehensive settings (extensions, status codes, threads)- Recursive scanning logic with depth control
- Custom
Clientconfiguration for optimized throughput - Interactive setup wizard
setup_wizardguides users through configuration
-
Sequential Fuzzer:
- Supports versatile payload placement (URL, Header, Body)
EncodingTypeenum supports 10+ encoding schemes including Double URL and Hex- Base-N counting algorithm for exhaustive iteration without memory overhead
- Modular
charsetselection (SQL, Traversal, Command Injection)
Exploit Modules: Best Practices
- CVE referencing: mention CVE IDs and vendor/product in comments and output.
- Artifact handling: If the exploit downloads or writes files (e.g., Heartbleed dump), store them in the current working directory or a named subfolder.
- Clean-up: If credentials or accounts are added (Abus camera module), explain the impact and clean-up instructions in output or comments.
- Safety checks: Validate responses before declaring success; false positives hurt credibility.
- Options: Use
prompt_*helpers (borrow from existing modules) if end-user input is needed (e.g., RTSP advanced headers, extra path lists).
Utilities & Helpers
src/utils.rs provides:
-
normalize_target: Comprehensive target normalization supporting:- IPv4:
192.168.1.1,192.168.1.1:8080 - IPv6:
::1,[::1],[::1]:8080,2001:db8::1 - Hostnames:
example.com,example.com:443 - URLs:
http://example.com:8080(extracts host:port) - CIDR notation:
192.168.1.0/24,2001:db8::/32
Includes comprehensive validation (DoS prevention, path traversal protection, format validation).
- IPv4:
-
extract_ip_from_target: Extracts IP address or hostname from normalized target strings, handling ports, brackets, and CIDR notation. -
basic_honeypot_check: Framework-level honeypot detection that scans 200 common ports. If 11+ ports are open, warns that the target is likely a honeypot. This runs automatically before module execution when a target is set. -
module_exists/list_all_modules/find_modules: Used by shell to present module inventory.
Feel free to expand this file with reusable pieces (e.g., credential loader, HTTP header templates) to avoid duplication inside modules.
Testing & QA
-
Static checks:
cargo fmtandcargo clippy(where available). -
Build:
cargo checkensures new modules compile. -
Runtime smoke tests:
- Shell:
cargo run→modules→ run a harmless module (e.g.,scanners/sample_scanner). - CLI:
cargo run -- --command scanner --module sample_scanner --target 127.0.0.1.
- Shell:
-
Wordlists: Validate that required lists exist (e.g., RTSP paths) and are referenced in docstrings.
When adding new modules, include short usage documentation (stdout prints, README notes) so other operators know how to drive them.
Roadmap & Ideas
- Interactive shell improvements (history, tab completion, colored banners)
- Automated module testing harness (mock servers for POP3/SMTP/RTSP)
- Credential module templates (derive-style macros for common prompts)
- Integration with external wordlists (dynamic download or git submodules)
- Session logging (
teesupport) and output JSON export for pipeline ingestion - Transport abstractions for UDP/DoS modules
Contributions are welcome—open an issue or start a discussion before large refactors.
Happy hacking, and remember: authorized testing only. Commit messages and module descriptions should always reflect controlled research usage. !***