PentestMCP

PentestMCP

Enables LLMs to perform Active Directory penetration testing using tools like NetExec, Bloodhound, Nmap, Certipy, and John the Ripper. Automates vulnerability discovery, attack path analysis, and documentation generation for security assessments.

Category
访问服务器

README

PentestMCP

This is an MCP server developed as part of a 2-month summer internship. 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, decide the next step and the next tool/technique to use, but most importantly (for me and for the lazy red teamers out there at least) is that it documents findings for you.

🎯 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 accept more 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 human in the loop. 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 (I used stdio as the transport layer). For installation instructions, see: https://github.com/aaddrick/claude-desktop-debian. For now only stdio transport layer is implemented and explained below, to use HTTP/SSE it's suggested that you download the repo, change the mcp.run() function in server.py to implement HTTP/SSE and change the mcp configuration file to fetch the target ip and port

🛠️ 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

By 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 pentestmcp as the command.

🚀 Usage Examples

Before you run your MCP client:

  1. Start bloodhound
  2. Visit ~/.local/lib/python3.13/site-packages/pentestmcp/config/ (typical path on linux) to your configure config.json (bloodhound api creds, prject directory to save findings in, etc.)
    {
     "PROJECT_DIRECTORY": "add_absolute_path_for_your_project_directory",
     "BHE_DOMAIN": "127.0.0.1",
     "BHE_PORT": 8080,
     "BHE_TOKEN_ID": "",
     "BHE_TOKEN_KEY": ""
     }
    

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选