This document describes the modular architecture of React2Shell (R2S), the core package for the R2S security testing tool.
react2shell/
├── main.py # Main entry point and argument parsing
├── classes/ # Core classes
│ ├── detector.py # Target detection and information gathering
│ ├── executor.py # Command execution and payload sending
│ ├── modules.py # Exploit modules system (Metasploit-style)
│ ├── operations.py # High-level exploitation operations
│ ├── payload.py # Payload building, randomization, and warming
│ └── shell.py # Interactive shell with history and navigation
├── services/ # Services
│ ├── config.py # Configuration management (JSON format)
│ ├── exporter.py # File and archive export functionality
│ ├── formatters.py # Operation-specific report formatters
│ ├── history.py # Command history persistence
│ ├── logger.py # Logging and audit trails
│ ├── proxy.py # Proxy management and rotation
│ └── reporter.py # Report generation (JSON/HTML/TXT/CSV)
└── utils/ # Utilities
├── colors.py # ANSI color codes and colorization
└── helpers.py # Helper functions (path handling, result extraction)
- Handles command-line argument parsing
- Orchestrates all modules and services
- Manages configuration loading and saving
- Coordinates operations (test, shell, export, modules, etc.)
- Handles special commands (settings, cleanup, uninstall)
detector.py - Target Detection
- Detects target platform (Unix/Linux, Windows)
- Identifies server type (Next.js, etc.)
- Gathers initial system information
executor.py - Command Execution
- Sends payloads via multipart form data
- Handles HTTP redirects (301, 302, 303, 307, 308)
- Extracts command output from responses
- Implements WAF bypass techniques
- Supports parallel execution
- Handles Next.js 404 page detection
modules.py - Exploit Modules System
- Base
ExploitModuleclass for extensibility - Built-in modules:
EnvDumpModule- Dump environment variablesFileSearchModule- Search for files by patternNetworkScanModule- Network scanningProcessListModule- List running processes
- Module registry system
- Module option handling
operations.py - High-Level Operations
test_vulnerability()- Test for CVE-2025-55182list_directory()- List directory contentsread_file()- Read file contentsget_system_info()- Gather system informationget_app_secrets()- Attempt to read secretsget_app_code()- Attempt to read source codecustom_command()- Execute custom commands
payload.py - Payload Management
PayloadBuilder- Build RCE payloadsPayloadRandomizer- Randomize payloads to evade detectionPayloadWarmer- Auto-warm and optimize payloads
shell.py - Interactive Shell
- Full interactive shell session over HTTPS
- Command history with arrow key navigation (↑/↓)
- Cursor movement (←/→)
- Command aliases (nano/vi/vim/emacs → cat, clear → cls)
- Colored file/folder output in
ls - Persistent history saved to
~/.r2s/history - Auto-save shell session reports
- Special command handling (cd, exit, quit)
config.py - Configuration Management
- JSON-based configuration stored at
~/.r2s/config.json - Interactive settings panel (
r2s settings) - Self-healing (handles corrupted files)
- Default configuration with sensible defaults
- Per-operation report format configuration
exporter.py - Export Functionality
export_file()- Export single filesexport_archive()- Export entire app directories as zip archives- Handles binary files (zip, tar.gz) with base64 encoding
- Automatically excludes
.gitignorepatterns - Reads
.gitignorefrom server if available - Auto-cleanup of server-side archives after download
- Configurable export directory
formatters.py - Report Formatters
- Operation-specific formatters:
SecretsFormatter- Format secrets extraction resultsSystemInfoFormatter- Format system informationCodeFormatter- Format code extraction resultsModuleFormatter- Format module resultsExportFormatter- Format export resultsGenericFormatter- Fallback formatter
- HTML, JSON, TXT format support
- Copy buttons and theme toggle for HTML reports
history.py - Command History
- Persistent command history
- Saved to
~/.r2s/history - Integration with
readlinefor history navigation
logger.py - Logging and Audit Trails
- Detailed logging of all operations
- Saved to
~/.r2s/logs/audit.log - Timestamped entries
- Operation tracking
proxy.py - Proxy Management
- HTTP proxy support
- Proxy rotation from file
- Proxy authentication support
reporter.py - Report Generation
- Auto-save reports to
~/.r2s/reports/ - Human-readable timestamps (YYYYMMDD_HHMMSS)
- Multiple formats: JSON, HTML, TXT, CSV
- Operation-specific formatting
- ANSI color code stripping for reports
- HTML reports with dark/light mode
- Copy buttons for easy data extraction
colors.py - Color Utilities
- ANSI color codes
colorize()function for colored outputdisable_colors()for no-color mode
helpers.py - Helper Functions
get_r2s_home()- Get~/.r2s/directoryextract_result_from_redirect()- Extract results from redirect headersstrip_ansi_codes()- Remove ANSI codes from textprint_banner()- Print tool bannerprint_section_header()- Print section headers
- User Input →
main.py(argument parsing) - Configuration →
config.py(load settings) - Target Detection →
detector.py(gather info) - Operation Execution →
operations.pyorshell.pyormodules.py - Command Execution →
executor.py(send payloads) - Payload Building →
payload.py(if needed) - Result Processing →
reporter.py(save reports) - Logging →
logger.py(audit trail)
- Operation → Sets operation type in
Reporter - Data Collection →
reporter.add_operation_data()orreporter.add_shell_command() - Formatting →
formatters.py(operation-specific formatting) - Export →
reporter.export_json/html/txt/csv() - Auto-Save → Saved to
~/.r2s/reports/with timestamp
Configuration is stored in JSON format at ~/.r2s/config.json:
{
"report": {
"auto_save": true,
"default_format": ["html", "json", "txt"],
"shell_formats": ["html", "json", "txt"],
"test_formats": ["html", "json", "txt"],
"reports_dir": "~/.r2s/reports"
},
"export": {
"export_dir": "~/.r2s/exports"
},
"shell": {
"history_file": "~/.r2s/history"
},
"execution": {
"default_timeout": 10
}
}- ✅ Modular architecture with clear separation of concerns
- ✅ Interactive shell with arrow key navigation
- ✅ Command history persistence
- ✅ Logging and audit trails
- ✅ Report generation (JSON/HTML/TXT) with operation-specific formatters
- ✅ Configuration file support (JSON format)
- ✅ File and archive export functionality
- ✅ Exploit modules system (Metasploit-style)
- ✅ Proxy support with rotation
- ✅ Auto-save reports with configurable formats
- ✅ ANSI color code stripping for reports
- ✅ HTML reports with dark/light mode and copy buttons
# Run as Python module
python3 -m react2shell.main -u https://target.com -t
# Or use the built binary
r2s -u https://target.com -t- Main README: See
../README.mdfor full tool documentation - Testing Environment: See
../nextjs/README.mdfor testing setup
zamdevio
- GitHub: https://github.com/zamdevio
- Project Repository: https://github.com/zamdevio/r2s
Part of the R2S (React2Shell) Security Testing Tool