๐ฅท Lightweight Chrome DevTools Protocol bridge for browser debugging and security testing
Reason this release was yanked:
missing agents
Project description
CDP Ninja ๐ฅท
A lightweight Chrome DevTools Protocol bridge that gives you powerful browser debugging capabilities without the bloat of Puppeteer or Playwright.
โ ๏ธ SECURITY WARNING โ ๏ธ
CDP Ninja is intentionally dangerous for security testing and fuzzing. It allows:
- ๐จ No Input Validation: Send malformed selectors, injection attempts, null bytes, XSS payloads
- ๐จ No Rate Limiting: Flood with requests, infinite loops, memory bombs
- ๐จ PowerShell Execution: Remote code execution when
ENABLE_POWERSHELL=true - ๐จ Any URL Navigation: javascript:, data:, file:// protocols allowed
- ๐จ Raw DOM Manipulation: HTML injection, script injection, attribute modification
Philosophy: If we can break it with malformed data, it has bugs. This tool crashes things on purpose.
Only use CDP Ninja in secure, isolated environments for testing purposes.
Why CDP Ninja?
- No Chromium Download: Uses your existing Chrome installation (saves 300MB)
- Minimal Dependencies: Only 16MB of Python packages vs 350MB+ for alternatives
- Direct CDP Access: No abstraction layers, just raw Chrome DevTools power
- Remote Debugging: SSH tunnel support for debugging from anywhere
- Claude Code Integration: Works as a specialized debugging agent
Architecture
Your Chrome โ CDP WebSocket โ Python Bridge โ HTTP API โ SSH Tunnel โ Claude/Tools
โ โ โ โ โ
Already Built-in 16MB deps REST API Remote access
installed protocol
Features
- ๐ฑ๏ธ Full Browser Control: Click, type, scroll, hover, drag and drop
- ๐ Network Monitoring: Capture all requests, responses, and timing
- ๐ Performance Profiling: Memory, CPU, rendering metrics
- ๐ Console Access: Capture logs, errors, warnings
- ๐ธ Screenshots: Full page or viewport captures
- ๐ DOM Inspection: Query, modify, and analyze page structure
- โก JavaScript Execution: Run code in page context
- ๐ Form Handling: Fill, submit, and extract form data
- ๐ฏ Bug Reproduction: Automated workflows for reproducing issues
Quick Start
Prerequisites
- Chrome installed
- Python 3.8+ installed
Installation
# Install CDP Ninja
pip install git+https://github.com/travofoz/cdp-ninja.git
# Start Chrome with debugging enabled
# Windows PowerShell:
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --remote-allow-origins=* --user-data-dir="C:\temp\chrome-debug"
# Linux/macOS:
google-chrome --remote-debugging-port=9222 --remote-allow-origins=* --user-data-dir=/tmp/chrome-debug
# Start CDP Ninja
cdp-ninja
Test it works:
curl http://localhost:8888/cdp/status
Custom Settings
# Use different ports
cdp-ninja --bridge-port 9999 --cdp-port 9222
# Enable debug mode
cdp-ninja --debug
# Set timeout (for heavy analytics, pingtrees, etc.)
cdp-ninja --timeout 1200
# Environment variables
export CHROME_TIMEOUT=600
cdp-ninja
SSH Tunnel Setup
To expose your local CDP Ninja to a remote server:
# From your local machine (where CDP Ninja runs)
ssh -R 8888:localhost:8888 user@your-server
# Now on the remote server:
curl http://localhost:8888/cdp/status
Usage Examples
Click a Button
import requests
# Click by CSS selector
response = requests.post("http://localhost:8888/cdp/click",
json={"selector": "#submit-button"})
# Click by coordinates
response = requests.post("http://localhost:8888/cdp/click",
json={"x": 100, "y": 200})
Drag and Drop
# Drag by coordinates
response = requests.post("http://localhost:8888/cdp/drag",
json={"startX": 100, "startY": 100, "endX": 300, "endY": 300})
# Drag by selectors
response = requests.post("http://localhost:8888/cdp/drag",
json={"startSelector": "#drag-handle", "endSelector": "#drop-zone"})
DOM Manipulation
# Set element attribute
response = requests.post("http://localhost:8888/cdp/dom/set_attribute",
json={"selector": "#element", "name": "data-test", "value": "modified"})
# Set element HTML content
response = requests.post("http://localhost:8888/cdp/dom/set_html",
json={"selector": "#content", "html": "<h1>New Content</h1>"})
# Query DOM elements
response = requests.post("http://localhost:8888/cdp/dom/query",
json={"selector": ".item"})
Capture Screenshot
# Take screenshot
response = requests.get("http://localhost:8888/cdp/screenshot")
with open("screenshot.png", "wb") as f:
f.write(response.content)
# Full page screenshot
response = requests.get("http://localhost:8888/cdp/screenshot?full_page=true")
Execute JavaScript (โ ๏ธ No Validation)
# Normal JavaScript execution
response = requests.post("http://localhost:8888/cdp/execute",
json={"code": "document.querySelector('#result').innerText"})
result = response.json()
# โ ๏ธ Security Testing Examples (will attempt execution):
# Infinite loop test
requests.post("http://localhost:8888/cdp/execute",
json={"code": "while(true) { console.log('crash test'); }"})
# Memory bomb test
requests.post("http://localhost:8888/cdp/execute",
json={"code": "let a = []; while(true) a.push('x'.repeat(1000000));"})
# XSS injection test
requests.post("http://localhost:8888/cdp/execute",
json={"code": "alert('XSS test: ' + document.cookie)"})
Monitor Network Traffic
# Get all recent network requests
response = requests.get("http://localhost:8888/cdp/network/requests")
for request in response.json():
print(f"{request['method']} {request['url']} - Status: {request.get('response', {}).get('status')}")
# Block specific URLs
requests.post("http://localhost:8888/cdp/network/block",
json={"patterns": ["*://*.doubleclick.net/*", "*://analytics.google.com/*"]})
Fill Forms (โ ๏ธ No Sanitization)
# Normal form filling
requests.post("http://localhost:8888/cdp/form/fill", json={
"fields": {
"#email": "test@example.com",
"#password": "secret123",
"#username": "testuser"
}
})
# โ ๏ธ Security Testing Examples:
# Malformed selectors and values with null bytes
requests.post("http://localhost:8888/cdp/form/fill", json={
"fields": {
">>>invalid_selector<<<": "test\0null\nbytes",
"#input": "x" * 1000000, # Huge value test
"#other": "'; DROP TABLE users; --" # SQL injection attempt
}
})
# Test malformed form submission
requests.post("http://localhost:8888/cdp/form/submit",
json={"selector": ">>>invalid<<<"})
Bug Reproduction Workflow
# Automated bug reproduction with screenshots
response = requests.post("http://localhost:8888/debug/reproduce", json={
"steps": [
{"action": "navigate", "url": "http://localhost:3000"},
{"action": "click", "selector": "#login-btn"},
{"action": "type", "selector": "#email", "text": "test@example.com"},
{"action": "click", "selector": "#submit"},
{"action": "wait", "duration": 2},
{"action": "click", "selector": "#submit"}, # Double-click bug
{"action": "click", "selector": "#submit"} # Triple-click bug
],
"screenshots": True,
"capture_console": True
})
print(f"Bug reproduced: {response.json()['completed']}")
Claude Code Integration
Add to your Claude Code agent configuration:
cdp-debugger: Browser debugging specialist using Chrome DevTools Protocol.
Captures network requests, console logs, executes JavaScript, takes screenshots,
clicks elements, fills forms. Use PROACTIVELY for debugging client-side issues,
reproducing bugs, and automated browser interaction. (Tools: WebFetch to CDP bridge)
Usage:
from tools import Task
# Use the debugging agent
Task(
subagent_type="cdp-debugger",
description="Debug login form",
prompt="Click login button 5 times rapidly and capture any console errors or network failures"
)
Timeout Configuration
CDP Ninja uses configurable timeouts to handle different use cases:
Default Timeout
- 900 seconds (15 minutes) - Suitable for heavy analytics, pingtrees, and business reporting
Configuration Options
CLI Flag:
# Quick testing (30 seconds)
cdp-ninja --timeout 30
# Heavy analytics (20 minutes)
cdp-ninja --timeout 1200
# Pingtree debugging (30 minutes)
cdp-ninja --timeout 1800
Environment Variable:
# Set via environment
export CHROME_TIMEOUT=600
cdp-ninja
# Or inline
CHROME_TIMEOUT=300 cdp-ninja
Use Cases
- CI/CD Testing: 30-60 seconds for fast feedback
- Development: 900 seconds (default) for complex applications
- Analytics/Reporting: 1200+ seconds for heavy database queries
- Pingtree Debugging: 1800+ seconds for multi-channel operations
Note: HTTP clients (curl, WebFetch) can set their own timeouts independently. CDP Ninja's timeout only prevents internal hangs.
API Reference
Core Operations
GET /health- Health checkGET /cdp/status- CDP connection statusPOST /cdp/command- Execute raw CDP command
Browser Interaction
POST /cdp/click- Click element (selector or coordinates)POST /cdp/type- Type text into elementPOST /cdp/scroll- Scroll pagePOST /cdp/hover- Hover over elementPOST /cdp/drag- Drag from start to end (coordinates or selectors)GET /cdp/screenshot- Capture screenshot
Debugging Operations
GET /cdp/console/logs- Get console outputGET /cdp/network/requests- Get network activityPOST /cdp/execute- Execute JavaScriptGET /cdp/dom/snapshot- Get DOM treePOST /cdp/dom/query- Query DOM elementsPOST /cdp/dom/set_attribute- Set element attributesPOST /cdp/dom/set_html- Set element innerHTML
Form Operations
POST /cdp/form/fill- Fill form fieldsPOST /cdp/form/submit- Submit formGET /cdp/form/values- Get form field values
Page Navigation
POST /cdp/page/navigate- Navigate to URLGET /cdp/page/reload- Reload pageGET /cdp/page/back- Go backGET /cdp/page/forward- Go forward
Network Control
POST /cdp/network/block- Block URLsPOST /cdp/network/throttle- Simulate slow networkGET /cdp/network/clear- Clear network cache
System Integration (โ ๏ธ DANGEROUS)
POST /system/execute- Execute RAW PowerShell/CMD/Bash commands (requiresENABLE_POWERSHELL=true)GET /system/info- System information and capabilitiesGET /system/processes- Browser process informationGET /system/chrome/info- Chrome debugging information
โ ๏ธ PowerShell/Command Execution Setup:
# Enable dangerous system commands (REQUIRED for /system/execute)
export ENABLE_POWERSHELL=true # Linux/macOS
# OR
set ENABLE_POWERSHELL=true # Windows CMD
# OR
$env:ENABLE_POWERSHELL="true" # PowerShell
Advanced Debugging
POST /debug/reproduce- Automated bug reproductionGET /debug/performance- Performance metricsGET /debug/memory- Memory usage analysis
Testing Philosophy
CDP Ninja is designed for security testing and fuzzing:
- No Input Validation: All endpoints accept ANY data to test application limits
- Intentional Code Injection: JavaScript string interpolation allows arbitrary code execution for testing
- Crash Reporting: When malformed data crashes Chrome, that's valuable debugging data
- Raw Pass-Through: Commands are sent exactly as provided to Chrome DevTools
- Edge Case Testing: Null bytes, huge values, malformed selectors are encouraged
- Security Research: XSS, injection attempts, protocol violations are allowed
- Browser Vulnerability Discovery: Test how browsers handle malformed CSS selectors and JavaScript
The "vulnerabilities" in CDP Ninja are features, not bugs.
If CDP Ninja can break your application with malformed data, your application has bugs.
This tool is intentionally permissive to help find vulnerabilities and edge cases through aggressive testing.
Project Structure
cdp-ninja/
โโโ core/
โ โโโ __init__.py
โ โโโ cdp_client.py # WebSocket CDP client with auto-reconnect
โ โโโ cdp_pool.py # Connection pooling for performance
โโโ api/
โ โโโ __init__.py
โ โโโ server.py # Main Flask application
โ โโโ config.py # Configuration with PowerShell toggle
โ โโโ routes/
โ โ โโโ __init__.py
โ โ โโโ browser.py # RAW browser interaction (click, type, screenshot)
โ โ โโโ debugging.py # RAW JavaScript execution and console access
โ โ โโโ navigation.py # RAW navigation (any URL, any protocol)
โ โ โโโ dom.py # RAW DOM manipulation (no sanitization)
โ โ โโโ system.py # RAW system commands (PowerShell/Bash)
โ โโโ utils/
โ โโโ error_reporter.py # Crash telemetry (not prevention)
โโโ setup/
โ โโโ setup_windows.ps1 # Windows PowerShell installer
โ โโโ setup_unix.sh # Linux/macOS bash installer
โโโ agent/
โ โโโ claude_agent.md # Claude Code agent specification
โโโ examples/
โ โโโ basic_usage.py # Getting started examples
โ โโโ debug_nextjs.py # Next.js debugging workflows
โโโ requirements.txt # Python dependencies (16MB total)
โโโ README.md
โโโ LICENSE
โโโ setup.py
Comparison with Alternatives
| Feature | CDP Ninja | Playwright | Puppeteer | Selenium |
|---|---|---|---|---|
| Browser Download | 0 MB (uses your Chrome) | 300MB | 170MB | 0 MB |
| Python Package | 16MB | 50MB | N/A | 15MB |
| Memory Usage | ~50MB | ~500MB | ~400MB | ~200MB |
| Setup Time | <1 minute | 5+ minutes | 3+ minutes | 2+ minutes |
| Direct CDP Access | โ | โ (abstracted) | โ (abstracted) | โ (WebDriver) |
| Remote Debugging | โ SSH tunnel | โ Complex | โ Complex | โ Grid |
| Learning Curve | Low (REST API) | High | High | Medium |
Common Issues & Solutions
Installation Issues
Problem: ModuleNotFoundError when running cdp-ninja
# Solution: Force reinstall with no cache
pip install --force-reinstall --no-cache-dir git+https://github.com/travofoz/cdp-ninja.git
Problem: ImportError: cannot import name 'config'
# Solution: You have an old version, update to latest
pip uninstall cdp-ninja -y
pip install git+https://github.com/travofoz/cdp-ninja.git
Connection Issues
Problem: Chrome DevTools connection failed (403 Forbidden)
# Solution: Chrome requires --remote-allow-origins flag
# Kill all Chrome processes first
Get-Process chrome | Stop-Process -Force # Windows PowerShell
pkill chrome # Linux/macOS
# Start Chrome with correct flags
chrome --remote-debugging-port=9222 --remote-allow-origins=*
# Windows PowerShell:
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --remote-allow-origins=* --user-data-dir="C:\temp\chrome-debug"
Problem: Connection timeout on Windows
# Chrome can be slow to respond on Windows
# This is fixed in v1.0.1+ (timeout increased to 30s)
pip install --upgrade git+https://github.com/travofoz/cdp-ninja.git
Problem: Bridge server won't start on port 8888
# Solution: Use a different port
cdp-ninja --bridge-port 9999
Windows-Specific Issues
Problem: PowerShell script execution disabled
# Solution: Enable script execution (run as Administrator)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Problem: Python not in PATH
# Solution: Use full path to Python
C:\Users\YourName\AppData\Local\Programs\Python\Python311\python.exe -m pip install git+https://github.com/travofoz/cdp-ninja.git
Verification Steps
# 1. Verify Chrome is accessible
curl http://localhost:9222/json
# Should return JSON with browser tabs
# 2. Verify CDP Ninja is running
curl http://localhost:8888/health
# Should return {"status": "ok"}
# 3. Test CDP connection
curl http://localhost:8888/cdp/status
# Should return connection details
Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
License
MIT License - see LICENSE file for details.
Credits
Built with โค๏ธ by developers who believe debugging should be simple, not bloated.
Special thanks to Claude (Anthropic) for architectural insights and implementation guidance.
Support
- ๐ API Documentation - Complete usage guide with examples
- ๐ Issues
- ๐ฌ Discussions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cdp_ninja-1.0.5.tar.gz.
File metadata
- Download URL: cdp_ninja-1.0.5.tar.gz
- Upload date:
- Size: 71.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a1e95882acf28dd18211d26fb79d2a2486219888f2a791569eaef3a204b9aa0
|
|
| MD5 |
940c5626305fafdcfa89bbc24ecedd97
|
|
| BLAKE2b-256 |
d14c9e6f7615387a534801c3fdc68ac386a16dc52a7485d20bbb0679473497e8
|
File details
Details for the file cdp_ninja-1.0.5-py3-none-any.whl.
File metadata
- Download URL: cdp_ninja-1.0.5-py3-none-any.whl
- Upload date:
- Size: 71.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a49c5965d6a2aa0b6f34078403280354c6e1496d55cbd7392a216e28134273d
|
|
| MD5 |
89352b9c7d13ca100a008c13cb411aeb
|
|
| BLAKE2b-256 |
272365a8480a96dbcf075834915ca6afc103dd2102017467f8ba9f33dd4ba2fd
|