Skip to main content

This is an MCP server that exposes red team tools for active directory pentesting to LLMs

Project description

PentestMCP

This is an MCP server developed as part of a 2-month 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.10+ with UV package manager
  • NetExec (successor to CrackMapExec)
  • Bloodhound Community Edition
  • Nmap
  • Certipy
  • psudohash https://github.com/t3l3machus/psudohash for password list generation ( included in the package, you dont have to download it )
  • john

📦 Installation

1. Install the MCP server

Using PIP

pip install pentestmcp

Cloning the repo

git clone https://github.com/YoussefSahnoun/PentestMCP.git
cd PentestMCP
pip install -e .

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", "pentestmcp"]
    }
  }
}

For Other MCP Clients

Configure according to your client's documentation, pointing to server.py as the entry point.

🚀 Usage Examples

Before you run your MCP client:

  1. Start bloodhound
  2. configure config.json with your bloodhound api creds, prject directory to save findings in etc

Example Workflow

  1. Start with Network Discovery
"Scan the network 192.168.1.0/24 for SMB services and check signing status"
  1. Enumerate Users
"Find all users in the domain at 192.168.1.10"
  1. Credential Attacks
"Try password spraying with common passwords against the discovered users"
  1. 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 configuration
  • enumerate_domain_users: Discover Active Directory users
  • bruteforce_rid_users: RID cycling for user enumeration
  • password_spray: Multi-target password attacks

Kerberos Attacks:

  • ASREPRoast: Extract AS-REP hashes for offline cracking
  • kerberoast: Extract TGS tickets for service accounts

Post-Exploitation:

  • spider_smb_shares: Comprehensive share enumeration and file collection
  • dump_ntds_dit: Extract domain credential database (NTDS.dit)
  • dump_sam_hashes: Local account hash extraction
  • command_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 parameters
  • use_module: Execute NetExec modules with custom options

🩸 Bloodhound (Attack Path Analysis)

  • test_bloodhound_connection: Verify API connectivity and version
  • upload_zip_to_bloodhound: Import collected data into Bloodhound
  • list_saved_queries: View saved Cypher queries
  • run_bloodhound_query: Execute custom Cypher queries for attack path discovery

🔓 John the Ripper (Hash Cracking)

  • get_john_formats: List available hash formats for cracking
  • john_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 results
  • get_project_directory_files: View files in current project directory
  • read_files: Access collected data and configuration files
  • generate_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

MCP Badge

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

pentestmcp-0.1.1.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

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

pentestmcp-0.1.1-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file pentestmcp-0.1.1.tar.gz.

File metadata

  • Download URL: pentestmcp-0.1.1.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for pentestmcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 34899492b7627e1eeacc868b97c2f1ddb4824915704bcaa1868946ee950a5b7a
MD5 547bfaf175ed1eb89ca50e974484e1ca
BLAKE2b-256 5975cb978217f20a1b852b7bd2240adf562f87d3e328f3e15857f3e2dde123de

See more details on using hashes here.

File details

Details for the file pentestmcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pentestmcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for pentestmcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b678e4f9e9558f48664c07ac291bab077f30a1a8cffd8745e21fdf0a0bbee583
MD5 8abe6fc82d27f38f4250458b2325e17c
BLAKE2b-256 8a0556a408f9feb96510b05b77204de346ecb28e2247285b360185503ccd9fe4

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