@modular-intelligence/waf-detect 1.0.0

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.
Files changed (3) hide show
  1. package/README.md +412 -0
  2. package/dist/index.js +45025 -0
  3. package/package.json +35 -0
package/README.md ADDED
@@ -0,0 +1,412 @@
1
+ # WAF Detection MCP Server
2
+
3
+ A Model Context Protocol (MCP) server for Web Application Firewall (WAF) fingerprinting and detection. This server provides comprehensive tools for identifying, analyzing, and testing WAF deployments using both the wafw00f CLI tool and native HTTP analysis.
4
+
5
+ ## Features
6
+
7
+ This is a **hybrid security testing tool** that combines:
8
+
9
+ - **wafw00f CLI integration** for WAF fingerprinting using known signatures
10
+ - **Native HTTP analysis** for header inspection, response comparison, and bypass testing
11
+ - **Comprehensive security controls** including authorization checks, rate limiting, and input validation
12
+ - **Six specialized tools** covering different aspects of WAF detection and analysis
13
+
14
+ ## Prerequisites
15
+
16
+ ### Required
17
+
18
+ - **Bun** runtime (v1.0+)
19
+ - **wafw00f** CLI tool: `pip install wafw00f`
20
+
21
+ ### Verification
22
+
23
+ ```bash
24
+ # Verify wafw00f installation
25
+ wafw00f --version
26
+
27
+ # Verify Bun installation
28
+ bun --version
29
+ ```
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ cd waf-detect
35
+ bun install
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### Starting the Server
41
+
42
+ ```bash
43
+ # Development mode
44
+ bun run src/index.ts
45
+
46
+ # Production mode (after building)
47
+ bun run build
48
+ bun run dist/index.js
49
+ ```
50
+
51
+ ### Configuration in Claude Desktop
52
+
53
+ Add to your Claude Desktop config file:
54
+
55
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
56
+
57
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
58
+
59
+ ```json
60
+ {
61
+ "mcpServers": {
62
+ "waf-detect": {
63
+ "command": "bun",
64
+ "args": ["run", "/absolute/path/to/waf-detect/src/index.ts"]
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Available Tools
71
+
72
+ ### 1. waf_fingerprint
73
+
74
+ Identifies the Web Application Firewall protecting a target URL using wafw00f.
75
+
76
+ **Parameters:**
77
+ - `url` (string, required): Target URL to fingerprint
78
+ - `authorized` (boolean, required): Confirmation of authorization (must be `true`)
79
+ - `timeout` (number, optional): Max scan duration in seconds (10-300, default: 60)
80
+
81
+ **Returns:**
82
+ ```json
83
+ {
84
+ "target": "https://example.com",
85
+ "detected": true,
86
+ "waf_name": "Cloudflare",
87
+ "manufacturer": "Cloudflare Inc.",
88
+ "http_status": 200
89
+ }
90
+ ```
91
+
92
+ **Example:**
93
+ ```typescript
94
+ await use_mcp_tool({
95
+ server: "waf-detect",
96
+ tool: "waf_fingerprint",
97
+ arguments: {
98
+ url: "https://example.com",
99
+ authorized: true,
100
+ timeout: 60
101
+ }
102
+ });
103
+ ```
104
+
105
+ ### 2. waf_bypass_check
106
+
107
+ Tests WAF bypass techniques using various encoding and obfuscation methods.
108
+
109
+ **Parameters:**
110
+ - `url` (string, required): Target URL to test
111
+ - `authorized` (boolean, required): Confirmation of authorization
112
+ - `payloads` (array, optional): Custom test payloads (max 20, 10KB each)
113
+ - `timeout` (number, optional): Max scan duration (10-300, default: 60)
114
+
115
+ **Encoding techniques tested:**
116
+ - Original payload
117
+ - URL encoding
118
+ - Double URL encoding
119
+ - Unicode encoding
120
+ - Mixed case
121
+ - HTML entities
122
+
123
+ **Returns:**
124
+ ```json
125
+ {
126
+ "target": "https://example.com",
127
+ "baseline_status": 200,
128
+ "results": [
129
+ {
130
+ "payload_type": "url_encoded",
131
+ "encoded_payload": "%3Cscript%3Ealert(1)%3C%2Fscript%3E",
132
+ "status_code": 403,
133
+ "blocked": true,
134
+ "response_size": 1234
135
+ }
136
+ ],
137
+ "bypass_found": false
138
+ }
139
+ ```
140
+
141
+ ### 3. waf_rule_test
142
+
143
+ Tests WAF detection rules against specific attack categories.
144
+
145
+ **Parameters:**
146
+ - `url` (string, required): Target URL to test
147
+ - `authorized` (boolean, required): Confirmation of authorization
148
+ - `attack_type` (enum, required): Type of attack pattern - one of:
149
+ - `xss`: Cross-Site Scripting
150
+ - `sqli`: SQL Injection
151
+ - `rfi`: Remote File Inclusion
152
+ - `lfi`: Local File Inclusion
153
+ - `rce`: Remote Code Execution
154
+ - `xxe`: XML External Entity
155
+ - `ssrf`: Server-Side Request Forgery
156
+ - `timeout` (number, optional): Max scan duration (10-300, default: 60)
157
+
158
+ **Returns:**
159
+ ```json
160
+ {
161
+ "target": "https://example.com",
162
+ "attack_type": "xss",
163
+ "results": [
164
+ {
165
+ "payload": "<script>alert('XSS')</script>",
166
+ "blocked": true,
167
+ "status_code": 403,
168
+ "evidence": "Status 403, x-waf-event-id: abc123"
169
+ }
170
+ ],
171
+ "block_rate": 0.83
172
+ }
173
+ ```
174
+
175
+ ### 4. waf_response_analysis
176
+
177
+ Analyzes and compares WAF responses to normal vs malicious requests.
178
+
179
+ **Parameters:**
180
+ - `url` (string, required): Target URL to analyze
181
+ - `authorized` (boolean, required): Confirmation of authorization
182
+ - `timeout` (number, optional): Max scan duration (10-300, default: 60)
183
+
184
+ **Returns:**
185
+ ```json
186
+ {
187
+ "target": "https://example.com",
188
+ "normal_response": {
189
+ "status": 200,
190
+ "headers": {
191
+ "server": "cloudflare",
192
+ "content-type": "text/html"
193
+ },
194
+ "size": 5432,
195
+ "time_ms": 123
196
+ },
197
+ "blocked_response": {
198
+ "status": 403,
199
+ "headers": {
200
+ "server": "cloudflare",
201
+ "x-waf-event-id": "abc123"
202
+ },
203
+ "size": 234,
204
+ "time_ms": 89
205
+ },
206
+ "differences": [
207
+ "Status code changed: 200 -> 403",
208
+ "Response size changed significantly: 5432 -> 234 bytes (96%)",
209
+ "New headers in blocked response: x-waf-event-id"
210
+ ],
211
+ "waf_indicators": [
212
+ "Cloudflare: server=cloudflare"
213
+ ]
214
+ }
215
+ ```
216
+
217
+ ### 5. waf_all_scan
218
+
219
+ Scans target against all known WAF signatures for comprehensive detection.
220
+
221
+ **Parameters:**
222
+ - `url` (string, required): Target URL to scan
223
+ - `authorized` (boolean, required): Confirmation of authorization
224
+ - `timeout` (number, optional): Max scan duration (30-300, default: 120)
225
+
226
+ **Returns:**
227
+ ```json
228
+ {
229
+ "target": "https://example.com",
230
+ "results": [
231
+ {
232
+ "waf_name": "Cloudflare",
233
+ "detected": true,
234
+ "manufacturer": "Cloudflare Inc."
235
+ },
236
+ {
237
+ "waf_name": "ModSecurity",
238
+ "detected": false,
239
+ "manufacturer": "Trustwave"
240
+ }
241
+ ],
242
+ "total_tested": 87
243
+ }
244
+ ```
245
+
246
+ ### 6. waf_header_analysis
247
+
248
+ Analyzes HTTP response headers for WAF and CDN indicators.
249
+
250
+ **Parameters:**
251
+ - `url` (string, required): Target URL to analyze
252
+ - `authorized` (boolean, required): Confirmation of authorization
253
+ - `timeout` (number, optional): Max scan duration (10-300, default: 60)
254
+
255
+ **Detects:**
256
+ - Cloudflare
257
+ - Akamai
258
+ - AWS WAF/CloudFront
259
+ - Incapsula
260
+ - Sucuri
261
+ - Fastly
262
+ - Azure WAF
263
+ - ModSecurity
264
+ - F5 BIG-IP
265
+ - Barracuda
266
+ - Imperva
267
+ - StackPath
268
+ - Generic WAF headers
269
+
270
+ **Returns:**
271
+ ```json
272
+ {
273
+ "target": "https://example.com",
274
+ "headers": {
275
+ "server": "cloudflare",
276
+ "cf-ray": "abc123-SJC",
277
+ "cf-cache-status": "HIT"
278
+ },
279
+ "waf_indicators": [
280
+ {
281
+ "header": "server",
282
+ "value": "cloudflare",
283
+ "waf_hint": "Cloudflare"
284
+ },
285
+ {
286
+ "header": "cf-ray",
287
+ "value": "abc123-SJC",
288
+ "waf_hint": "Cloudflare"
289
+ }
290
+ ],
291
+ "detected_technologies": [
292
+ "Cloudflare"
293
+ ]
294
+ }
295
+ ```
296
+
297
+ ## Security Features
298
+
299
+ ### Authorization Required
300
+
301
+ All tools require explicit authorization confirmation. You must set `authorized: true` to confirm you have permission to test the target.
302
+
303
+ ### Input Validation
304
+
305
+ - **URL validation**: Only `http` and `https` protocols allowed
306
+ - **Private IP blocking**: Prevents scanning of private IP ranges:
307
+ - 10.0.0.0/8
308
+ - 172.16.0.0/12
309
+ - 192.168.0.0/16
310
+ - 127.0.0.0/8
311
+ - localhost, ::1, fe80:
312
+ - **Payload size limits**: Maximum 10KB per payload
313
+ - **Payload count limits**: Maximum 20 payloads per request
314
+ - **Timeout constraints**: 10-300 seconds
315
+
316
+ ### Rate Limiting
317
+
318
+ Built-in rate limiter restricts requests to 10 per second to prevent abuse.
319
+
320
+ ### Process Controls
321
+
322
+ - Maximum buffer size: 10MB
323
+ - Command timeout enforcement
324
+ - SIGKILL for hung processes
325
+ - Thread count validation (max 10)
326
+
327
+ ## Ethical Use
328
+
329
+ This tool is designed for **authorized security testing only**. Users must:
330
+
331
+ 1. ✅ Have explicit permission to test the target system
332
+ 2. ✅ Comply with all applicable laws and regulations
333
+ 3. ✅ Follow responsible disclosure practices
334
+ 4. ✅ Respect rate limits and avoid DoS conditions
335
+ 5. ❌ Never use against systems without authorization
336
+
337
+ **Unauthorized testing may be illegal and result in criminal prosecution.**
338
+
339
+ ## Error Handling
340
+
341
+ All tools return structured error messages:
342
+
343
+ ```json
344
+ {
345
+ "content": [{
346
+ "type": "text",
347
+ "text": "Error: Authorization required: You must explicitly set authorized=true"
348
+ }],
349
+ "isError": true
350
+ }
351
+ ```
352
+
353
+ Common errors:
354
+ - `wafw00f command not found`: Install wafw00f with `pip install wafw00f`
355
+ - `Invalid protocol`: Only http/https allowed
356
+ - `Access to private IP addresses is blocked`: Target must be publicly accessible
357
+ - `Rate limit exceeded`: Wait before making more requests
358
+ - `Payload size exceeds maximum`: Reduce payload size below 10KB
359
+
360
+ ## Development
361
+
362
+ ### Building
363
+
364
+ ```bash
365
+ bun run build
366
+ ```
367
+
368
+ ### Project Structure
369
+
370
+ ```
371
+ waf-detect/
372
+ ├── package.json
373
+ ├── tsconfig.json
374
+ ├── README.md
375
+ ├── src/
376
+ │ ├── index.ts # Main server entry point
377
+ │ ├── schemas.ts # Zod validation schemas
378
+ │ ├── security.ts # Security validation utilities
379
+ │ ├── cli-executor.ts # wafw00f CLI wrapper
380
+ │ └── tools/
381
+ │ ├── waf-fingerprint.ts
382
+ │ ├── waf-bypass-check.ts
383
+ │ ├── waf-rule-test.ts
384
+ │ ├── waf-response-analysis.ts
385
+ │ ├── waf-all-scan.ts
386
+ │ └── waf-header-analysis.ts
387
+ └── dist/ # Compiled output
388
+ ```
389
+
390
+ ## Use Cases
391
+
392
+ 1. **Security Auditing**: Verify WAF deployment and configuration
393
+ 2. **Penetration Testing**: Test WAF effectiveness during authorized assessments
394
+ 3. **Red Team Operations**: Identify defensive controls during authorized engagements
395
+ 4. **Blue Team Validation**: Verify WAF rules are working as expected
396
+ 5. **Research**: Study WAF behavior and bypass techniques in authorized environments
397
+
398
+ ## Limitations
399
+
400
+ - Requires wafw00f to be installed and in PATH
401
+ - Only tests publicly accessible targets
402
+ - Rate limited to prevent abuse
403
+ - Some advanced WAF bypass techniques may require manual testing
404
+ - Results depend on wafw00f signature database currency
405
+
406
+ ## License
407
+
408
+ MIT
409
+
410
+ ## Disclaimer
411
+
412
+ This tool is provided for educational and authorized security testing purposes only. The authors and contributors are not responsible for misuse or damage caused by this tool. Always ensure you have proper authorization before testing any system.