|
| 1 | +# NetExec MCP Server |
| 2 | + |
| 3 | +[](https://modelcontextprotocol.io) |
| 4 | +[](https://opensource.org/licenses/MIT) |
| 5 | +[](https://www.typescriptlang.org/) |
| 6 | +[](https://www.netexec.wiki/) |
| 7 | + |
| 8 | +A Model Context Protocol (MCP) server that provides AI assistants with access to [NetExec](https://github.com/Pennyw0rth/NetExec) (nxc), the powerful network execution and penetration testing tool formerly known as CrackMapExec. |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +This MCP server enables AI assistants to execute NetExec commands via SSH to a Kali Linux machine, supporting: |
| 13 | + |
| 14 | +| Protocol | Capabilities | |
| 15 | +|----------|-------------| |
| 16 | +| **SMB** | Windows enumeration, credential dumping (SAM/LSA/NTDS), command execution, pass-the-hash | |
| 17 | +| **WinRM** | Remote Windows management, PowerShell execution, credential dumping | |
| 18 | +| **SSH** | Linux/Unix authentication, key-based auth, remote command execution | |
| 19 | +| **LDAP** | Active Directory enumeration, Kerberoasting, ASREPRoast, BloodHound collection | |
| 20 | +| **MSSQL** | SQL Server queries, xp_cmdshell execution, login enumeration | |
| 21 | +| **RDP** | Credential validation, screenshot capture | |
| 22 | +| **WMI** | Windows Management Instrumentation command execution | |
| 23 | + |
| 24 | +Additional features: |
| 25 | +- Password spraying across all protocols |
| 26 | +- Module management and execution |
| 27 | +- SMB share enumeration and file operations |
| 28 | +- NetExec credential database queries |
| 29 | + |
| 30 | +## Prerequisites |
| 31 | + |
| 32 | +- Node.js 18+ |
| 33 | +- SSH access to a Kali Linux machine with NetExec installed |
| 34 | +- SSH key-based authentication (recommended) or password |
| 35 | + |
| 36 | +## Installation |
| 37 | + |
| 38 | +```bash |
| 39 | +# Clone the repository |
| 40 | +git clone https://github.com/schwarztim/sec-netexec-mcp.git |
| 41 | +cd sec-netexec-mcp |
| 42 | + |
| 43 | +# Install dependencies |
| 44 | +npm install |
| 45 | + |
| 46 | +# Build the project |
| 47 | +npm run build |
| 48 | +``` |
| 49 | + |
| 50 | +## Configuration |
| 51 | + |
| 52 | +### Environment Variables |
| 53 | + |
| 54 | +| Variable | Description | Default | |
| 55 | +|----------|-------------|---------| |
| 56 | +| `KALI_HOST` | SSH hostname or IP for Kali machine | `kali` | |
| 57 | +| `SSH_USER` | SSH username | (none) | |
| 58 | +| `SSH_KEY` | Path to SSH private key file | (none) | |
| 59 | +| `SSH_TIMEOUT` | Command timeout in seconds | `300` | |
| 60 | + |
| 61 | +### Claude Desktop Configuration |
| 62 | + |
| 63 | +Add to your `claude_desktop_config.json`: |
| 64 | + |
| 65 | +```json |
| 66 | +{ |
| 67 | + "mcpServers": { |
| 68 | + "netexec": { |
| 69 | + "command": "node", |
| 70 | + "args": ["/path/to/sec-netexec-mcp/dist/index.js"], |
| 71 | + "env": { |
| 72 | + "KALI_HOST": "your-kali-host", |
| 73 | + "SSH_USER": "kali", |
| 74 | + "SSH_KEY": "/path/to/ssh/key" |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +## Available Tools |
| 82 | + |
| 83 | +### `nxc_smb` |
| 84 | +SMB protocol operations including enumeration, share listing, user/group/session enumeration, credential dumping (SAM, LSA, NTDS), and command execution. |
| 85 | + |
| 86 | +### `nxc_winrm` |
| 87 | +WinRM remote management for authentication testing, cmd/PowerShell execution, and credential dumping. |
| 88 | + |
| 89 | +### `nxc_ssh` |
| 90 | +SSH protocol for authentication testing, key-based auth, and remote command execution. |
| 91 | + |
| 92 | +### `nxc_ldap` |
| 93 | +LDAP/Active Directory operations including user/group/computer enumeration, Kerberoasting, ASREPRoast, BloodHound collection, and trust enumeration. |
| 94 | + |
| 95 | +### `nxc_mssql` |
| 96 | +SQL Server operations including queries, xp_cmdshell execution, and login enumeration. |
| 97 | + |
| 98 | +### `nxc_rdp` |
| 99 | +RDP credential validation and screenshot capture. |
| 100 | + |
| 101 | +### `nxc_wmi` |
| 102 | +WMI-based command execution on Windows targets. |
| 103 | + |
| 104 | +### `nxc_modules` |
| 105 | +List and query available NetExec modules for each protocol. |
| 106 | + |
| 107 | +### `nxc_spray` |
| 108 | +Password spraying with configurable options including user/password lists, jitter, and continue-on-success. |
| 109 | + |
| 110 | +### `nxc_shares` |
| 111 | +SMB share enumeration and file operations (spider, get, put). |
| 112 | + |
| 113 | +### `nxc_raw` |
| 114 | +Execute raw NetExec commands for advanced scenarios not covered by other tools. |
| 115 | + |
| 116 | +### `nxc_database` |
| 117 | +Query the NetExec credential database for stored hosts and credentials. |
| 118 | + |
| 119 | +## Usage Examples |
| 120 | + |
| 121 | +### Enumerate SMB Hosts |
| 122 | +```json |
| 123 | +{ |
| 124 | + "tool": "nxc_smb", |
| 125 | + "arguments": { |
| 126 | + "target": "192.168.1.0/24" |
| 127 | + } |
| 128 | +} |
| 129 | +``` |
| 130 | + |
| 131 | +### List Shares with Credentials |
| 132 | +```json |
| 133 | +{ |
| 134 | + "tool": "nxc_smb", |
| 135 | + "arguments": { |
| 136 | + "target": "192.168.1.10", |
| 137 | + "username": "admin", |
| 138 | + "password": "P@ssw0rd", |
| 139 | + "domain": "CORP", |
| 140 | + "action": "shares" |
| 141 | + } |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +### Pass-the-Hash Attack |
| 146 | +```json |
| 147 | +{ |
| 148 | + "tool": "nxc_smb", |
| 149 | + "arguments": { |
| 150 | + "target": "192.168.1.10", |
| 151 | + "username": "admin", |
| 152 | + "hash": "aad3b435b51404eeaad3b435b51404ee:5fbc3d5fec8206a30f4b6c473d68ae76", |
| 153 | + "domain": "CORP", |
| 154 | + "action": "shares" |
| 155 | + } |
| 156 | +} |
| 157 | +``` |
| 158 | + |
| 159 | +### Password Spray |
| 160 | +```json |
| 161 | +{ |
| 162 | + "tool": "nxc_spray", |
| 163 | + "arguments": { |
| 164 | + "protocol": "smb", |
| 165 | + "target": "192.168.1.0/24", |
| 166 | + "userList": "/tmp/users.txt", |
| 167 | + "password": "Summer2024!", |
| 168 | + "domain": "CORP", |
| 169 | + "continueOnSuccess": true |
| 170 | + } |
| 171 | +} |
| 172 | +``` |
| 173 | + |
| 174 | +### BloodHound Collection |
| 175 | +```json |
| 176 | +{ |
| 177 | + "tool": "nxc_ldap", |
| 178 | + "arguments": { |
| 179 | + "target": "dc01.corp.local", |
| 180 | + "username": "user", |
| 181 | + "password": "password", |
| 182 | + "domain": "CORP", |
| 183 | + "action": "bloodhound", |
| 184 | + "bloodhoundCollection": "All" |
| 185 | + } |
| 186 | +} |
| 187 | +``` |
| 188 | + |
| 189 | +### Dump NTDS from Domain Controller |
| 190 | +```json |
| 191 | +{ |
| 192 | + "tool": "nxc_smb", |
| 193 | + "arguments": { |
| 194 | + "target": "dc01.corp.local", |
| 195 | + "username": "admin", |
| 196 | + "password": "P@ssw0rd", |
| 197 | + "domain": "CORP", |
| 198 | + "action": "ntds" |
| 199 | + } |
| 200 | +} |
| 201 | +``` |
| 202 | + |
| 203 | +## Security Considerations |
| 204 | + |
| 205 | +This tool is intended for **authorized security testing only**. Always ensure you have: |
| 206 | + |
| 207 | +- Written authorization to test target systems |
| 208 | +- Proper scope definition for penetration testing engagements |
| 209 | +- Compliance with applicable laws and regulations |
| 210 | + |
| 211 | +**Never use this tool against systems you do not have explicit permission to test.** |
| 212 | + |
| 213 | +## Development |
| 214 | + |
| 215 | +```bash |
| 216 | +# Watch mode for development |
| 217 | +npm run dev |
| 218 | + |
| 219 | +# Build for production |
| 220 | +npm run build |
| 221 | + |
| 222 | +# Start the server |
| 223 | +npm start |
| 224 | +``` |
| 225 | + |
| 226 | +## Architecture |
| 227 | + |
| 228 | +``` |
| 229 | +┌─────────────────┐ ┌──────────────────┐ ┌────────────────┐ |
| 230 | +│ AI Assistant │────▶│ NetExec MCP │────▶│ Kali Linux │ |
| 231 | +│ (Claude, etc.) │ │ Server (Node.js)│ SSH │ (nxc) │ |
| 232 | +└─────────────────┘ └──────────────────┘ └────────────────┘ |
| 233 | + │ |
| 234 | + │ stdio |
| 235 | + ▼ |
| 236 | + ┌──────────────┐ |
| 237 | + │ MCP Protocol │ |
| 238 | + └──────────────┘ |
| 239 | +``` |
| 240 | + |
| 241 | +## References |
| 242 | + |
| 243 | +- [NetExec Official Wiki](https://www.netexec.wiki/) |
| 244 | +- [NetExec GitHub Repository](https://github.com/Pennyw0rth/NetExec) |
| 245 | +- [Model Context Protocol](https://modelcontextprotocol.io) |
| 246 | +- [NetExec Cheat Sheet](https://www.stationx.net/netexec-cheat-sheet/) |
| 247 | +- [Kali Linux NetExec](https://www.kali.org/tools/netexec/) |
| 248 | + |
| 249 | +## License |
| 250 | + |
| 251 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 252 | + |
| 253 | +## Disclaimer |
| 254 | + |
| 255 | +This software is provided for educational and authorized security testing purposes only. The authors are not responsible for any misuse or damage caused by this program. Users are responsible for ensuring compliance with all applicable laws and regulations. |
0 commit comments