YoussefSahnoun/PentestMCP
If you are the rightful owner of PentestMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
PentestMCP is an MCP server developed to enhance Large Language Models with active directory penetration testing capabilities.
PentestMCP
This is an MCP server developed as part of a summer internship at KEYSTONE Group. This tool gives Large Language Models the ability to use active directory penetration testing tools. The goal is to save time, have the model analyze the result for you and gives you the juicy stuff and the most important thing (for me and for the lazy red teamers out there at least) is it documents findings for you, we all hate that.
π― Overview
The server provides a unified interface to tools like NetExec (CrackMapExec), Bloodhound, john, certipy and Nmap. This is an initial version that provides decent features but will always lack sufficient tools so if you're looking for something that is able to compromise an active directory environment from 0 to 100 that's not it and I dont think that it'll be possible without user guidance and interaction( at least for now !). The MCP server was tested locally with Claude Desktop as the MCP client. It's important to note that I used Claude Desktop for Debian. For installation instructions, see: https://github.com/aaddrick/claude-desktop-debian
π οΈ Requirements
The MCP server was developed using the amazing FastMCP: https://github.com/jlowin/fastmcp
Core Dependencies
- Python 3.8+ with UV package manager
- NetExec (successor to CrackMapExec)
- Bloodhound Community Edition
- Nmap
- Certipy
- psudohash https://github.com/t3l3machus/psudohash for password list generation
- john
π¦ Installation
1. Clone and Setup
git clone <repository-url>
cd PentestMCP
uv sync
2. Install Required Tools
NetExec
# Via pipx (recommended)
pipx install netexec
# Or via pip
pip install netexec
Bloodhound Community Edition
# Download from official releases
wget https://github.com/SpecterOps/BloodHound/releases/latest/bloodhound-linux-x64.zip
unzip bloodhound-linux-x64.zip
# Follow BloodHound setup instructions
Nmap
# Ubuntu/Debian
sudo apt install nmap
# CentOS/RHEL
sudo yum install nmap
Certipy
pip install certipy-ad
John
https://github.com/openwall/john/blob/bleeding-jumbo/doc/INSTALL
3. Configure MCP Client
For Claude Desktop
Add to your ~/.config/claude-desktop/config.json
:
{
"mcpServers": {
"pentestmcp": {
"command": "uv",
"args": ["run", "python", "/path/to/PentestMCP/main.py"],
"env": {}
}
}
}
For Other MCP Clients
Configure according to your client's documentation, pointing to main.py
as the entry point.
π Usage Examples
Before you run your MCP client:
- Start bloodhound
- configure
config.json
with your bloodhound api creds, prject directory to save findings in etc
Example Workflow
- Start with Network Discovery
"Scan the network 192.168.1.0/24 for SMB services and check signing status"
- Enumerate Users
"Find all users in the domain at 192.168.1.10"
- Credential Attacks
"Try password spraying with common passwords against the discovered users"
- Bloodhound Analysis
"Collect Bloodhound data ingest it, upload zip to bloodhound and find attack paths to Domain Admins"
π§ Available Tools
πΊοΈ Nmap (Network Reconnaissance)
run_nmap_scan
: Network and service discovery with customizable flags
β‘ NetExec (SMB/LDAP Operations)
SMB Enumeration & Authentication:
check_SMB_signing
: Check SMB signing configurationenumerate_domain_users
: Discover Active Directory usersbruteforce_rid_users
: RID cycling for user enumerationpassword_spray
: Multi-target password attacks
Kerberos Attacks:
ASREPRoast
: Extract AS-REP hashes for offline crackingkerberoast
: Extract TGS tickets for service accounts
Post-Exploitation:
spider_smb_shares
: Comprehensive share enumeration and file collectiondump_ntds_dit
: Extract domain credential database (NTDS.dit)dump_sam_hashes
: Local account hash extractioncommand_execution
: Remote PowerShell command execution
Bloodhound Data Collection:
bloodhound_ingest
: Collect AD data using NetExec's BloodHound module
Module System:
check_module
: List available NetExec modules for protocols (SMB, LDAP, WinRM, etc.)check_options
: View module-specific options and parametersuse_module
: Execute NetExec modules with custom options
π©Έ Bloodhound (Attack Path Analysis)
test_bloodhound_connection
: Verify API connectivity and versionupload_zip_to_bloodhound
: Import collected data into Bloodhoundlist_saved_queries
: View saved Cypher queriesrun_bloodhound_query
: Execute custom Cypher queries for attack path discovery
π John the Ripper (Hash Cracking)
get_john_formats
: List available hash formats for crackingjohn_the_ripper
: Crack hashes with specified format and wordlist
ποΈ Certipy (Certificate Services)
certipy_scan
: Enumerate AD CS vulnerabilities and misconfigurations
π Utility & Data Management
save_partial_finding
: Organize and store assessment resultsget_project_directory_files
: View files in current project directoryread_files
: Access collected data and configuration filesgenerate_pwd_wordlist
: Create custom password wordlists based on target information
π§ Available Resources
Custom Bloodhound Queries
: Some custom bloodhound queries that you can include as a resource to your MCP client. Note that you can add any resources you want just follow this resource:
@mcp.resource("data://bloodhound_cypher_queries")
def get_custom_queries():
# Resolve path relative to this script (safer than relying on current working dir)
p = Path(__file__).parent / "custom_bloodhound_queries.json"
# use 'encoding' (not 'encode') and json.load for file -> python object (if your data isn't json load it normally)
with p.open("r", encoding="utf-8") as f:
return json.load(f)
π Security Considerations
Responsible Use
- This tool is intended for authorized security assessments only
- Ensure proper authorization before testing any systems
- Follow responsible disclosure practices for discovered vulnerabilities
Troubleshooting
Common Issues
Clock Skew Errors:
# Sync time with domain controller (requires root)
sudo ntpdate domain-controller.local
Permission Errors:
- Ensure NetExec has appropriate permissions
- Check that output directories are writable
- Verify Bloodhound API credentials
## π€ Contributing
### Adding New Tools
1. Create a new tool function following the MCP pattern
2. Add appropriate input validation
3. Update documentation and examples