hacktricks-mcp-server 1.3.1 â 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -12
- package/package.json +4 -3
- package/scripts/postinstall.js +92 -0
- package/.github/workflows/publish-mcp.yml +0 -49
- package/.github/workflows/test-event.json +0 -9
- package/.gitmodules +0 -3
- package/.mcp.json +0 -11
- package/CHANGELOG.md +0 -30
- package/TESTING.md +0 -188
- package/bun.lock +0 -202
- package/example-settings.json +0 -9
- package/server.json +0 -21
- package/src/index.ts +0 -952
- package/test-mcp.js +0 -127
- package/tsconfig.json +0 -16
package/README.md
CHANGED
|
@@ -15,27 +15,26 @@ MCP (Model Context Protocol) server for searching and querying [HackTricks](http
|
|
|
15
15
|
|
|
16
16
|
## Setup
|
|
17
17
|
|
|
18
|
-
### 1
|
|
18
|
+
### Option 1: Install from npm (Recommended)
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
git submodule update --init --recursive
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### 2. Install Dependencies
|
|
21
|
+
# Install the package
|
|
22
|
+
npm install -g hacktricks-mcp-server
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
bun install
|
|
24
|
+
# The postinstall script will automatically clone HackTricks repository
|
|
30
25
|
```
|
|
31
26
|
|
|
32
|
-
###
|
|
27
|
+
### Option 2: Install from source
|
|
33
28
|
|
|
34
29
|
```bash
|
|
35
|
-
|
|
30
|
+
git clone https://github.com/Xplo8E/hacktricks-mcp-server.git
|
|
31
|
+
cd hacktricks-mcp-server
|
|
32
|
+
git submodule update --init --recursive
|
|
33
|
+
npm install
|
|
34
|
+
npm run build
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
###
|
|
37
|
+
### Configure Claude
|
|
39
38
|
|
|
40
39
|
Add to your Claude settings (`~/.claude/settings.json`):
|
|
41
40
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hacktricks-mcp-server",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "MCP server for searching HackTricks documentation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"mcpName": "io.github.
|
|
7
|
+
"mcpName": "io.github.Xplo8E/hacktricks-mcp-server",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/Xplo8E/hacktricks-mcp-server.git"
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc",
|
|
14
14
|
"dev": "tsc --watch",
|
|
15
|
-
"start": "node dist/index.js"
|
|
15
|
+
"start": "node dist/index.js",
|
|
16
|
+
"postinstall": "node scripts/postinstall.js"
|
|
16
17
|
},
|
|
17
18
|
"keywords": [
|
|
18
19
|
"mcp",
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, rmSync } from 'fs';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { join, dirname } from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
const rootDir = join(__dirname, '..');
|
|
11
|
+
const hacktricksPath = join(rootDir, 'hacktricks');
|
|
12
|
+
|
|
13
|
+
console.log('đĻ Setting up HackTricks MCP Server...');
|
|
14
|
+
|
|
15
|
+
// Check if hacktricks directory already exists and is valid
|
|
16
|
+
if (existsSync(hacktricksPath)) {
|
|
17
|
+
// Verify it's a valid git repo with content
|
|
18
|
+
const gitDir = join(hacktricksPath, '.git');
|
|
19
|
+
const srcDir = join(hacktricksPath, 'src');
|
|
20
|
+
|
|
21
|
+
if (existsSync(gitDir) && existsSync(srcDir)) {
|
|
22
|
+
console.log('â HackTricks repository already exists');
|
|
23
|
+
process.exit(0);
|
|
24
|
+
} else {
|
|
25
|
+
console.log('â ī¸ Incomplete HackTricks directory found, removing...');
|
|
26
|
+
try {
|
|
27
|
+
rmSync(hacktricksPath, { recursive: true, force: true });
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.error('â Could not remove incomplete directory');
|
|
30
|
+
console.error(` Please remove manually: ${hacktricksPath}`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Check if git is installed
|
|
37
|
+
try {
|
|
38
|
+
execSync('git --version', { stdio: 'ignore' });
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('â Git is not installed');
|
|
41
|
+
console.error(' Please install git: https://git-scm.com/downloads');
|
|
42
|
+
console.error(' Then run: npm rebuild hacktricks-mcp-server');
|
|
43
|
+
process.exit(0); // Exit 0 to not fail npm install
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Check for SKIP_POSTINSTALL environment variable
|
|
47
|
+
if (process.env.SKIP_POSTINSTALL === 'true') {
|
|
48
|
+
console.log('âšī¸ Skipping HackTricks clone (SKIP_POSTINSTALL=true)');
|
|
49
|
+
console.log(' Run manually: git clone https://github.com/carlospolop/hacktricks.git');
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log('đĨ Cloning HackTricks repository (this may take a minute)...');
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
execSync(
|
|
57
|
+
'git clone --depth 1 --single-branch https://github.com/carlospolop/hacktricks.git',
|
|
58
|
+
{
|
|
59
|
+
cwd: rootDir,
|
|
60
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
61
|
+
timeout: 120000 // 2 minute timeout
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// Verify clone was successful
|
|
66
|
+
if (existsSync(join(hacktricksPath, 'src'))) {
|
|
67
|
+
console.log('â HackTricks repository cloned successfully');
|
|
68
|
+
console.log('â Setup complete! You can now use the HackTricks MCP server.');
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error('Clone incomplete - src directory not found');
|
|
71
|
+
}
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('â Failed to clone HackTricks repository');
|
|
74
|
+
console.error(` Error: ${error.message}`);
|
|
75
|
+
console.error('');
|
|
76
|
+
console.error(' Please run manually:');
|
|
77
|
+
console.error(` cd ${rootDir}`);
|
|
78
|
+
console.error(' git clone https://github.com/carlospolop/hacktricks.git');
|
|
79
|
+
console.error('');
|
|
80
|
+
console.error(' Or set SKIP_POSTINSTALL=true to skip this step');
|
|
81
|
+
|
|
82
|
+
// Clean up partial clone
|
|
83
|
+
if (existsSync(hacktricksPath)) {
|
|
84
|
+
try {
|
|
85
|
+
rmSync(hacktricksPath, { recursive: true, force: true });
|
|
86
|
+
} catch (e) {
|
|
87
|
+
// Ignore cleanup errors
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
process.exit(0); // Exit 0 to not fail npm install
|
|
92
|
+
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
name: Publish to MCP Registry
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- 'v*'
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
permissions:
|
|
12
|
-
id-token: write # Required for OIDC token generation
|
|
13
|
-
contents: read
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout repository
|
|
17
|
-
uses: actions/checkout@v4
|
|
18
|
-
|
|
19
|
-
- name: Set up Node.js
|
|
20
|
-
uses: actions/setup-node@v4
|
|
21
|
-
with:
|
|
22
|
-
node-version: '18'
|
|
23
|
-
registry-url: 'https://registry.npmjs.org'
|
|
24
|
-
|
|
25
|
-
- name: Install dependencies
|
|
26
|
-
run: npm install
|
|
27
|
-
|
|
28
|
-
- name: Build package
|
|
29
|
-
run: npm run build
|
|
30
|
-
|
|
31
|
-
- name: Publish to npm
|
|
32
|
-
run: npm publish --access public
|
|
33
|
-
env:
|
|
34
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
35
|
-
|
|
36
|
-
- name: Download mcp-publisher CLI
|
|
37
|
-
run: |
|
|
38
|
-
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v1.0.0/mcp-publisher_1.0.0_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz
|
|
39
|
-
chmod +x mcp-publisher
|
|
40
|
-
|
|
41
|
-
- name: Publish to MCP Registry
|
|
42
|
-
env:
|
|
43
|
-
ACTIONS_ID_TOKEN_REQUEST_TOKEN: ${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN }}
|
|
44
|
-
ACTIONS_ID_TOKEN_REQUEST_URL: ${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }}
|
|
45
|
-
run: |
|
|
46
|
-
./mcp-publisher publish \
|
|
47
|
-
--registry-url "https://registry.modelcontextprotocol.io" \
|
|
48
|
-
--mcp-file "./server.json" \
|
|
49
|
-
--auth-method github-oidc
|
package/.gitmodules
DELETED
package/.mcp.json
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [1.3.0] - 2025-12-26
|
|
4
|
-
|
|
5
|
-
### Tools
|
|
6
|
-
|
|
7
|
-
| Tool | Description |
|
|
8
|
-
|------|-------------|
|
|
9
|
-
| `search_hacktricks` | Search with results grouped by file, showing title, match count, and relevant sections |
|
|
10
|
-
| `get_hacktricks_page` | Get full page content |
|
|
11
|
-
| `get_hacktricks_outline` | Get table of contents (section headers) |
|
|
12
|
-
| `get_hacktricks_section` | Extract specific section by name |
|
|
13
|
-
| `get_hacktricks_cheatsheet` | Extract only code blocks/payloads |
|
|
14
|
-
| `list_hacktricks_categories` | Browse categories and file structure |
|
|
15
|
-
| `hacktricks_quick_lookup` | ⥠One-shot exploitation lookup with alias support |
|
|
16
|
-
|
|
17
|
-
### Features
|
|
18
|
-
|
|
19
|
-
- **Grouped search results** - Results aggregated by file with title, match count, sections, and top matches
|
|
20
|
-
- **Section extraction** - Read specific sections (~200 tokens) instead of full pages (~3000 tokens)
|
|
21
|
-
- **Quick lookup** - One-shot "how do I exploit X" answers with alias expansion (sqli, xss, rce, etc.)
|
|
22
|
-
- **Smart tool descriptions** - Guide Claude toward efficient usage patterns
|
|
23
|
-
- **Category filtering** - Narrow searches to specific categories
|
|
24
|
-
- **Code block extraction** - Get just the commands/payloads
|
|
25
|
-
|
|
26
|
-
### Security
|
|
27
|
-
|
|
28
|
-
- Command injection protection via `execFile()`
|
|
29
|
-
- Path traversal prevention
|
|
30
|
-
- Input validation on all parameters
|
package/TESTING.md
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# Testing the HackTricks MCP Server
|
|
2
|
-
|
|
3
|
-
This document describes how to test the MCP server functionality.
|
|
4
|
-
|
|
5
|
-
## Manual Testing
|
|
6
|
-
|
|
7
|
-
### Prerequisites
|
|
8
|
-
```bash
|
|
9
|
-
cd ~/projects/hacktricks-mcp
|
|
10
|
-
bun install
|
|
11
|
-
bun run build
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### Test 1: Verify Build Output
|
|
15
|
-
```bash
|
|
16
|
-
ls -la dist/
|
|
17
|
-
# Should show index.js
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Test 2: Test Search Functionality (CLI)
|
|
21
|
-
```bash
|
|
22
|
-
# Test basic search
|
|
23
|
-
rg -n -i --type md "SUID" hacktricks/ | head -10
|
|
24
|
-
|
|
25
|
-
# Test regex search
|
|
26
|
-
rg -n -i --type md "docker.*escape" hacktricks/ | head -5
|
|
27
|
-
|
|
28
|
-
# Test no results
|
|
29
|
-
rg -n -i --type md "xyznotfound12345" hacktricks/
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### Test 3: Test File Reading
|
|
33
|
-
```bash
|
|
34
|
-
# Test reading a valid file
|
|
35
|
-
cat hacktricks/src/linux-hardening/privilege-escalation/README.md | head -20
|
|
36
|
-
|
|
37
|
-
# Test path traversal protection (should fail)
|
|
38
|
-
cat hacktricks/../../../etc/passwd 2>&1
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Test 4: List Categories
|
|
42
|
-
```bash
|
|
43
|
-
ls hacktricks/src/ | grep -v "\.md$" | grep -v "^images$" | sort
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Integration Testing with Claude Code
|
|
47
|
-
|
|
48
|
-
### 1. Add to Claude Code Settings
|
|
49
|
-
|
|
50
|
-
Edit `~/.claude/settings.json`:
|
|
51
|
-
```json
|
|
52
|
-
{
|
|
53
|
-
"mcpServers": {
|
|
54
|
-
"hacktricks": {
|
|
55
|
-
"command": "node",
|
|
56
|
-
"args": ["/Users/vinay/projects/hacktricks-mcp/dist/index.js"],
|
|
57
|
-
"disabled": false
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### 2. Restart Claude Code
|
|
64
|
-
|
|
65
|
-
### 3. Test Commands
|
|
66
|
-
|
|
67
|
-
Try these queries with Claude Code:
|
|
68
|
-
|
|
69
|
-
**Search Test:**
|
|
70
|
-
```
|
|
71
|
-
"Search HackTricks for SUID privilege escalation"
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Category List Test:**
|
|
75
|
-
```
|
|
76
|
-
"What categories are available in HackTricks?"
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**Page Retrieval Test:**
|
|
80
|
-
```
|
|
81
|
-
"Show me the Linux privilege escalation page from HackTricks"
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
**Edge Cases:**
|
|
85
|
-
```
|
|
86
|
-
"Search HackTricks for: XXE|SSRF|CSRF" # Regex test
|
|
87
|
-
"Search HackTricks for: docker.*escape" # Regex test
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Expected Results
|
|
91
|
-
|
|
92
|
-
### Search Results Format
|
|
93
|
-
```
|
|
94
|
-
Found X matches for: "query"
|
|
95
|
-
|
|
96
|
-
đ path/to/file.md:123
|
|
97
|
-
Content of matching line
|
|
98
|
-
|
|
99
|
-
đ path/to/another.md:456
|
|
100
|
-
Another matching line
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Category List Format
|
|
104
|
-
```
|
|
105
|
-
Available HackTricks Categories (X):
|
|
106
|
-
|
|
107
|
-
- AI
|
|
108
|
-
- binary-exploitation
|
|
109
|
-
- crypto
|
|
110
|
-
- linux-hardening
|
|
111
|
-
...
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Page Content Format
|
|
115
|
-
```
|
|
116
|
-
[Full markdown content of the page]
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Debugging
|
|
120
|
-
|
|
121
|
-
Check MCP server logs in Claude Code console:
|
|
122
|
-
```
|
|
123
|
-
[HackTricks MCP] Searching for: "query"
|
|
124
|
-
[HackTricks MCP] Found X results (showing Y)
|
|
125
|
-
[HackTricks MCP] Reading file: path/to/file.md
|
|
126
|
-
[HackTricks MCP] File size: XXXX bytes
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Error Testing
|
|
130
|
-
|
|
131
|
-
### Test Empty Query
|
|
132
|
-
```
|
|
133
|
-
search_hacktricks("")
|
|
134
|
-
# Expected: "Search query cannot be empty"
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Test Invalid Path
|
|
138
|
-
```
|
|
139
|
-
get_hacktricks_page("../../../etc/passwd")
|
|
140
|
-
# Expected: "Invalid file path: directory traversal not allowed"
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Test Non-existent File
|
|
144
|
-
```
|
|
145
|
-
get_hacktricks_page("src/nonexistent.md")
|
|
146
|
-
# Expected: "File not found: src/nonexistent.md"
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Test Invalid Regex
|
|
150
|
-
```
|
|
151
|
-
search_hacktricks("[[invalid")
|
|
152
|
-
# Expected: "Invalid search pattern: ..."
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## Performance Testing
|
|
156
|
-
|
|
157
|
-
### Large Query Results
|
|
158
|
-
```bash
|
|
159
|
-
# Search for common term
|
|
160
|
-
rg -n -i --type md "privilege" hacktricks/ | wc -l
|
|
161
|
-
# Should handle large result sets (limited to 50)
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### File Size Limits
|
|
165
|
-
```bash
|
|
166
|
-
# Find largest markdown file
|
|
167
|
-
find hacktricks/src -name "*.md" -type f -exec du -h {} + | sort -rh | head -5
|
|
168
|
-
# Ensure server can handle large files
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## Security Testing
|
|
172
|
-
|
|
173
|
-
### Command Injection Prevention
|
|
174
|
-
Test that special characters in queries don't execute commands:
|
|
175
|
-
```
|
|
176
|
-
search_hacktricks("test; ls -la")
|
|
177
|
-
search_hacktricks("test && whoami")
|
|
178
|
-
search_hacktricks("test $(whoami)")
|
|
179
|
-
```
|
|
180
|
-
All should search for the literal strings, not execute commands.
|
|
181
|
-
|
|
182
|
-
### Path Traversal Prevention
|
|
183
|
-
```
|
|
184
|
-
get_hacktricks_page("../../../etc/passwd")
|
|
185
|
-
get_hacktricks_page("/etc/passwd")
|
|
186
|
-
get_hacktricks_page("src/../../..")
|
|
187
|
-
```
|
|
188
|
-
All should be rejected with appropriate error messages.
|