Skip to main content

MCP Server for Reverse Engineering with Binary Analysis Tools

Project description

Reversecore_MCP

Icon

License: MIT Python Version FastMCP Docker Tests Coverage

Watch the Demo

๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด (Korean)

An enterprise-grade MCP (Model Context Protocol) server for AI-powered reverse engineering. Enables AI agents to perform comprehensive binary analysis through natural language commands.

๐Ÿ“‹ Prerequisites

Ghidra (Required for Decompilation)

Ghidra is required for advanced decompilation features. The installation scripts automatically install Ghidra to <project>/Tools directory.

Option 1: Automatic Installation (Recommended)

# Windows (PowerShell)
.\scripts\install-ghidra.ps1

# With custom version/path (optional)
.\scripts\install-ghidra.ps1 -Version "11.4.3" -InstallDir "C:\CustomPath"
# Linux/macOS
chmod +x ./scripts/install-ghidra.sh
./scripts/install-ghidra.sh

# With custom version/path (optional)
./scripts/install-ghidra.sh -v 11.4.3 -d /custom/path

What the scripts do:

  • Downloads Ghidra 11.4.3 from GitHub (~400MB)
  • Extracts to <project>/Tools/ghidra_11.4.3_PUBLIC_YYYYMMDD
  • Sets GHIDRA_INSTALL_DIR environment variable
  • Updates project .env file

Option 2: Manual Installation

  1. Download: Ghidra 11.4.3
  2. Extract to <project>/Tools/ or any directory
  3. Set environment variable:
    # Linux/macOS (~/.bashrc or ~/.zshrc)
    export GHIDRA_INSTALL_DIR=/path/to/ghidra_11.4.3_PUBLIC_YYYYMMDD
    
    # Windows (PowerShell - permanent)
    [Environment]::SetEnvironmentVariable("GHIDRA_INSTALL_DIR", "C:\path\to\ghidra", "User")
    
    Or add to .env file (copy from .env.example)

โš ๏ธ Note: JDK 17+ is required for Ghidra. Download from Adoptium if needed.

๐Ÿš€ Quick Start

Docker (Recommended)

# Auto-detect architecture (Intel/AMD or Apple Silicon)
./scripts/run-docker.sh

# Or manually:
# Intel/AMD
docker compose --profile x86 up -d

# Apple Silicon (M1/M2/M3/M4)
docker compose --profile arm64 up -d

MCP Client Configuration (Cursor AI)

Step 1: Build Docker Image

The unified Dockerfile automatically detects your system architecture:

# Automatic architecture detection (works for all platforms)
docker build -t reversecore-mcp:latest .

# Or use the convenience script
./scripts/run-docker.sh

Step 2: Configure MCP Client

Add to ~/.cursor/mcp.json:

๐ŸŽ macOS (All Processors)
{
  "mcpServers": {
    "reversecore": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/Users/YOUR_USERNAME/Reversecore_Workspace:/app/workspace",
        "-e", "REVERSECORE_WORKSPACE=/app/workspace",
        "-e", "MCP_TRANSPORT=stdio",
        "reversecore-mcp:latest"
      ]
    }
  }
}
๐Ÿง Linux
{
  "mcpServers": {
    "reversecore": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/path/to/workspace:/app/workspace",
        "-e", "REVERSECORE_WORKSPACE=/app/workspace",
        "-e", "MCP_TRANSPORT=stdio",
        "reversecore-mcp:latest"
      ]
    }
  }
}
๐ŸชŸ Windows
{
  "mcpServers": {
    "reversecore": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "C:/Reversecore_Workspace:/app/workspace",
        "-e", "REVERSECORE_WORKSPACE=/app/workspace",
        "-e", "MCP_TRANSPORT=stdio",
        "reversecore-mcp:latest"
      ]
    }
  }
}

โš ๏ธ IMPORTANT: File Path Usage in Docker

The MCP server runs inside a Docker container. When using analysis tools, use only the filename, not the full local path.

โŒ Wrong โœ… Correct
run_file("/Users/john/Reversecore_Workspace/sample.exe") run_file("sample.exe")

Why? Your local path (e.g., /Users/.../Reversecore_Workspace/) is mounted to /app/workspace/ inside the container. Tools automatically look for files in the workspace directory.

Tip: Use list_workspace() to see all available files in your workspace.

โœจ Key Features

๐Ÿ” Static Analysis

Comprehensive file analysis and metadata extraction:

  • File Type Detection: Identify binary format, architecture, and compiler information (run_file)
  • String Extraction: Extract ASCII/Unicode strings with configurable limits (run_strings)
  • Firmware Analysis: Deep scan for embedded files and signatures (run_binwalk)
  • Binary Parsing: Parse PE/ELF/Mach-O headers and sections with LIEF (parse_binary_with_lief)

โš™๏ธ Disassembly & Decompilation

Multi-architecture binary analysis with intelligent tooling:

  • Radare2 Integration: Full r2 command access with connection pooling (run_radare2, Radare2_disassemble)
  • Ghidra Decompilation: Enterprise-grade decompilation with 16GB JVM heap (smart_decompile, get_pseudo_code)
  • Multi-Architecture Support: x86, x86-64, ARM, ARM64, MIPS, PowerPC via Capstone (disassemble_with_capstone)
  • Smart Fallback: Automatic Ghidra-first, r2-fallback strategy for best results

๐Ÿงฌ Advanced Analysis

Deep code analysis and behavior understanding:

  • Cross-Reference Analysis: Track function calls, data references, and control flow (analyze_xrefs)
  • Structure Recovery: Infer data structures from pointer arithmetic and memory access patterns (recover_structures)
  • Emulation: ESIL-based code emulation for dynamic behavior analysis (emulate_machine_code)
  • Binary Comparison: Diff binaries and match library functions (diff_binaries, match_libraries)

๐Ÿฆ  Malware Analysis & Defense

Specialized tools for threat detection and mitigation:

  • Dormant Threat Detection: Find hidden backdoors, orphan functions, and logic bombs (dormant_detector)
  • IOC Extraction: Automatically extract IPs, URLs, domains, emails, hashes, and crypto addresses (extract_iocs)
  • YARA Scanning: Pattern-based malware detection with custom rules (run_yara)
  • Adaptive Vaccine: Generate defensive measures (YARA rules, binary patches, NOP injection) (adaptive_vaccine)
  • Vulnerability Hunter: Detect dangerous API patterns and exploit paths (vulnerability_hunter)

๐Ÿ“Š Server Health & Monitoring

Built-in observability tools for enterprise environments:

  • Health Check: Monitor uptime, memory usage, and operational status (get_server_health)
  • Performance Metrics: Track tool execution times, error rates, and call counts (get_tool_metrics)
  • Auto-Recovery: Automatic retry mechanism with exponential backoff for transient failures

๐Ÿ–ฅ๏ธ Web Dashboard (NEW)

Visual interface for binary analysis without LLM:

# Start server in HTTP mode
MCP_TRANSPORT=http MCP_API_KEY=your-secret-key python server.py

# Access dashboard
open http://localhost:8000/dashboard/

Features:

  • Overview: File list with upload stats
  • Analysis: Functions list, disassembly viewer
  • IOCs: Extracted URLs, IPs, emails, strings

Security:

  • XSS protection with HTML sanitization
  • Path traversal prevention
  • API key authentication (optional)

๐Ÿ“ Report Generation (v3.1)

Professional malware analysis report generation with accurate timestamps:

  • One-Shot Submission: Generate standardized JSON reports with a single command (generate_malware_submission)
  • Session Tracking: Start/end analysis sessions with automatic duration calculation (start_analysis_session, end_analysis_session)
  • IOC Collection: Collect and organize indicators during analysis (add_session_ioc)
  • MITRE ATT&CK Mapping: Document techniques with proper framework references (add_session_mitre)
  • Email Delivery: Send reports directly to security teams with SMTP support (send_report_email)
  • Multiple Templates: Full analysis, quick triage, IOC summary, executive brief
# Example 1: One-Shot JSON Submission
generate_malware_submission(
    file_path="wannacry.exe",
    analyst_name="Hunter",
    tags="ransomware,critical"
)

# Example 2: Interactive Session Workflow
get_system_time()
start_analysis_session(sample_path="malware.exe")
add_session_ioc("ips", "192.168.1.100")
add_session_mitre("T1059.001", "PowerShell", "Execution")
end_analysis_session(summary="Ransomware detected")
create_analysis_report(template_type="full_analysis")
send_report_email(to="security-team@company.com")

โšก Performance & Reliability (v3.1)

  • Resource Management:
    • Zombie Killer: Guaranteed subprocess termination with try...finally blocks
    • Memory Guard: Strict 2MB limit on strings output to prevent OOM
    • Crash Isolation: LIEF parser runs in isolated process to handle segfaults safely
  • Optimizations:
    • Dynamic Timeout: Auto-scales with file size (base + 2s/MB, max +600s)
    • Ghidra JVM: 16GB heap for modern systems (24-32GB RAM)
    • Sink-Aware Pruning: 39 dangerous sink APIs for intelligent path prioritization
    • Trace Depth Optimization: Reduced from 3 to 2 for faster execution path analysis
  • Infrastructure:
    • Stateless Reports: Timezone-aware reporting without global state mutation
    • Robust Retries: Decorators now correctly propagate exceptions for auto-recovery
    • Config-Driven: Validation limits synchronized with central configuration

๐Ÿ› ๏ธ Core Tools

Category Tools
File Operations list_workspace, get_file_info
Static Analysis run_file, run_strings, run_binwalk
Disassembly run_radare2, Radare2_disassemble, disassemble_with_capstone
Decompilation smart_decompile, get_pseudo_code
Advanced Analysis analyze_xrefs, recover_structures, emulate_machine_code
Binary Parsing parse_binary_with_lief
Binary Comparison diff_binaries, match_libraries
Malware Analysis dormant_detector, extract_iocs, run_yara, adaptive_vaccine, vulnerability_hunter
Report Generation get_system_time, set_timezone, start_analysis_session, add_session_ioc, add_session_mitre, end_analysis_session, create_analysis_report, send_report_email, generate_malware_submission
Server Management get_server_health, get_tool_metrics

๐Ÿ“Š Analysis Workflow

๐Ÿ“ฅ Upload โ†’ ๐Ÿ” Triage โ†’ ๐Ÿ”— X-Refs โ†’ ๐Ÿ—๏ธ Structures โ†’ ๐Ÿ“ Decompile โ†’ ๐Ÿ›ก๏ธ Defense

Use built-in prompts for guided analysis:

  • full_analysis_mode - Comprehensive malware analysis with 6-phase expert reasoning and evidence classification
  • basic_analysis_mode - Quick triage for fast initial assessment
  • game_analysis_mode - Game client analysis with cheat detection guidance
  • firmware_analysis_mode - IoT/Firmware security analysis with embedded system focus
  • report_generation_mode - Professional report generation workflow with MITRE ATT&CK mapping

๐Ÿ’ก AI Reasoning Enhancement: Analysis prompts use expert persona priming, Chain-of-Thought checkpoints, structured reasoning phases, and evidence classification (OBSERVED/INFERRED/POSSIBLE) to maximize AI analysis capabilities and ensure thorough documentation.

๐Ÿ—๏ธ Architecture

reversecore_mcp/
โ”œโ”€โ”€ core/                           # Infrastructure & Services
โ”‚   โ”œโ”€โ”€ config.py                   # Configuration management
โ”‚   โ”œโ”€โ”€ ghidra.py, ghidra_manager.py, ghidra_helper.py  # Ghidra integration (16GB JVM)
โ”‚   โ”œโ”€โ”€ r2_helpers.py, r2_pool.py   # Radare2 connection pooling
โ”‚   โ”œโ”€โ”€ security.py                 # Path validation & input sanitization
โ”‚   โ”œโ”€โ”€ result.py                   # ToolSuccess/ToolError response models
โ”‚   โ”œโ”€โ”€ metrics.py                  # Tool execution metrics
โ”‚   โ”œโ”€โ”€ report_generator.py         # Report generation service
โ”‚   โ”œโ”€โ”€ plugin.py                   # Plugin interface for extensibility
โ”‚   โ”œโ”€โ”€ decorators.py               # @log_execution, @track_metrics
โ”‚   โ”œโ”€โ”€ error_handling.py           # @handle_tool_errors decorator
โ”‚   โ”œโ”€โ”€ logging_config.py           # Structured logging setup
โ”‚   โ”œโ”€โ”€ memory.py                   # AI memory store (async SQLite)
โ”‚   โ”œโ”€โ”€ mitre_mapper.py             # MITRE ATT&CK framework mapping
โ”‚   โ”œโ”€โ”€ resource_manager.py         # Subprocess lifecycle management
โ”‚   โ””โ”€โ”€ validators.py               # Input validation
โ”‚
โ”œโ”€โ”€ tools/                          # MCP Tool Implementations
โ”‚   โ”œโ”€โ”€ analysis/                   # Basic analysis tools
โ”‚   โ”‚   โ”œโ”€โ”€ static_analysis.py      # file, strings, binwalk
โ”‚   โ”‚   โ”œโ”€โ”€ lief_tools.py           # PE/ELF/Mach-O parsing
โ”‚   โ”‚   โ”œโ”€โ”€ diff_tools.py           # Binary comparison
โ”‚   โ”‚   โ””โ”€โ”€ signature_tools.py      # YARA scanning
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ radare2/                    # Radare2 integration
โ”‚   โ”‚   โ”œโ”€โ”€ r2_analysis.py          # Core r2 analysis
โ”‚   โ”‚   โ”œโ”€โ”€ radare2_mcp_tools.py    # Advanced r2 tools (CFG, ESIL)
โ”‚   โ”‚   โ”œโ”€โ”€ r2_session.py           # Session management
โ”‚   โ”‚   โ””โ”€โ”€ r2_pool.py              # Connection pooling
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ ghidra/                     # Ghidra decompilation
โ”‚   โ”‚   โ”œโ”€โ”€ decompilation.py        # smart_decompile, pseudo-code
โ”‚   โ”‚   โ””โ”€โ”€ ghidra_tools.py         # Structure/Enum management
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ malware/                    # Malware analysis & defense
โ”‚   โ”‚   โ”œโ”€โ”€ dormant_detector.py     # Hidden threat detection
โ”‚   โ”‚   โ”œโ”€โ”€ adaptive_vaccine.py     # Defense generation
โ”‚   โ”‚   โ”œโ”€โ”€ vulnerability_hunter.py # Vulnerability detection
โ”‚   โ”‚   โ”œโ”€โ”€ ioc_tools.py            # IOC extraction
โ”‚   โ”‚   โ””โ”€โ”€ yara_tools.py           # YARA rule management
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ common/                     # Cross-cutting concerns
โ”‚   โ”‚   โ”œโ”€โ”€ file_operations.py      # Workspace file management
โ”‚   โ”‚   โ”œโ”€โ”€ server_tools.py         # Health checks, metrics
โ”‚   โ”‚   โ””โ”€โ”€ memory_tools.py         # AI memory operations
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ report/                     # Report generation (v3.1)
โ”‚       โ”œโ”€โ”€ report_tools.py         # Core report engine
โ”‚       โ”œโ”€โ”€ report_mcp_tools.py     # MCP tool registration
โ”‚       โ”œโ”€โ”€ session.py              # Analysis session tracking
โ”‚       โ””โ”€โ”€ email.py                # SMTP integration
โ”‚
โ”œโ”€โ”€ prompts.py                      # AI reasoning prompts (5 modes)
โ”œโ”€โ”€ resources.py                    # Dynamic MCP resources (reversecore:// URIs)
โ””โ”€โ”€ server.py                       # FastMCP server initialization & HTTP setup

๐Ÿณ Docker Deployment

Multi-Architecture Support

The unified Dockerfile automatically detects your system architecture:

Architecture Auto-Detected Support
x86_64 (Intel/AMD) โœ… Full support
ARM64 (Apple Silicon M1-M4) โœ… Full support

Run Commands

# Using convenience script (auto-detects architecture)
./scripts/run-docker.sh              # Start
./scripts/run-docker.sh stop         # Stop
./scripts/run-docker.sh logs         # View logs
./scripts/run-docker.sh shell        # Shell access

# Manual Docker build (works for all architectures)
docker build -t reversecore-mcp:latest .

# Or using Docker Compose
docker compose up -d

Environment Variables

Variable Default Description
`MCP_TRANSPORT` `http` Transport mode (`stdio` or `http`)
`REVERSECORE_WORKSPACE` `/app/workspace` Analysis workspace path
`LOG_LEVEL` `INFO` Logging level
`GHIDRA_INSTALL_DIR` `/opt/ghidra` Ghidra installation path

๐Ÿ”’ Security

  • No shell injection: All subprocess calls use list arguments
  • Path validation: Workspace-restricted file access
  • Input sanitization: All parameters validated
  • Rate limiting: Configurable request limits (HTTP mode)

๐Ÿงช Development

# Install dependencies
pip install -r requirements-dev.txt

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=reversecore_mcp --cov-fail-under=72

# Code quality
ruff check reversecore_mcp/
black reversecore_mcp/

Test Status

  • โœ… 852 tests passed
  • ๐Ÿ“Š 76% coverage
  • โฑ๏ธ ~14 seconds execution time

๐Ÿ“š API Reference

Tool Response Format

All tools return structured `ToolResult`:

{
  "status": "success",
  "data": "...",
  "metadata": { "bytes_read": 1024 }
}
{
  "status": "error",
  "error_code": "VALIDATION_ERROR",
  "message": "File not found",
  "hint": "Check file path"
}

Common Error Codes

Code Description
`VALIDATION_ERROR` Invalid input parameters
`TIMEOUT` Operation exceeded time limit
`PARSE_ERROR` Failed to parse tool output
`TOOL_NOT_FOUND` Required CLI tool missing

๐Ÿ’ป System Requirements

Component Minimum Recommended
CPU 4 cores 8+ cores
RAM 16 GB 32 GB
Storage 512 GB SSD 1 TB NVMe
OS Linux/macOS Docker environment

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes with tests
  4. Run `pytest` and `ruff check`
  5. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE for details.

๐Ÿ”— Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_developermode_korea_reversecore_mcp-1.0.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_developermode_korea_reversecore_mcp-1.0.0.tar.gz
  • Upload date:
  • Size: 213.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_developermode_korea_reversecore_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1edaee1cc6f0af31a1db94e2ba21600a63be2b5eaaa4b423aef674c026fae959
MD5 859ddfa0da70ffb06960ed5241818c94
BLAKE2b-256 a8ce7bd9f0467152682bf389efd1f51bd316949ea0bfb5ecc44d516e8d79fb28

See more details on using hashes here.

File details

Details for the file iflow_mcp_developermode_korea_reversecore_mcp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_developermode_korea_reversecore_mcp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 250.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_developermode_korea_reversecore_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1dc4c49f5e27ecfea50062248e169b45b8afa2c51b7692baf1e2b21c87d322c2
MD5 bc872f94b4b0ce80cfb7c6f0db18071b
BLAKE2b-256 d058f772e076ea6169a08424f1baacd7fdd5489fe1a7a60253f81922bed06856

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page