
A headless , scriptable, command-line based MITM proxy designed for network traffic interception, analysis, and modification on Windows systems.

A headless , scriptable, command-line based MITM proxy designed for network traffic interception, analysis, and modification on Windows systems. It operates similarly to industry-standard GUI proxies but is optimized for automation environments, headless operation, and integration with development workflows.
Note: This is a standalone, dependency-free tool implemented in Node.js.
PacketPirate is a system-wide network interception tool. By leveraging the Windows HTTP Proxy settings, it can capture traffic from any application running on your machine—including web browsers (Chrome, Edge), CLI tools (curl, git), and desktop applications (Spotify, VS Code, Discord).
Global System Interception: Captures HTTP/HTTPS traffic from any process respecting the system proxy.
Process-Aware: identify exactly which application is generating traffic.
Dynamic Rule Engine: Configurable via JSON to perform specific actions on matching traffic (e.g., token extraction, request logging).
Full Traffic Logging: Capable of dumping full request and response bodies (HTML, JSON, Binary) for analysis.
Headless Architecture: Runs entirely from the CLI, suitable for background services and automated testing pipelines.
Custom Certificate Management: Includes utilities for generating and trusting self-signed Root CAs for HTTPS decryption.
Clone the repository and initialize the environment:
# 1. Generate local SSL certificates
npm run setup
# 2. Trust the generated Root CA
npm run trust
# Note: Requires administrative approval to add the certificate to the Trusted Root Store.
Start the proxy server:
npm start
This launches the standard CLI interface.
The interactive menu provides the following controls:
code.exe).Bearer tokens in Authorization headers.jsonl log files.Interception logic is defined in config/rules.json. This file allows for persistent configuration of traffic handling.
Schema:
{
"rules": [
{
"name": "Description of rule",
"host": "hostname.match",
"urlPattern": "regex_pattern",
"action": "log | save_token",
"outputFile": "path/to/output.txt",
"tokenFilter": "regex_filter"
}
]
}
Example:
{
"rules": [
{
"name": "Test API",
"host": "jsonplaceholder.typicode.com",
"action": "save_token",
"outputFile": "test_tokens.txt"
}
]
}
The tool uses a dual-server architecture:
CONNECT tunneling request and performs host filtering.EADDRINUSE errors and increments the port number until a free port is found.SIGINT/SIGTERM handlers to ensure proxy settings are reverted upon exit, preventing network connectivity issues.The tool relies on a dual-certificate model for HTTPS interception:
npm run setup creates a self-signed Root CA (PacketPirateRoot).
New-SelfSignedCertificate to generate a key-pair valid for 5 years.src/certs/server.pfx (PKCS#12 format) with the password "headless".npm run trust injects this Root CA into the Windows CurrentUser\Root store.
CurrentUser rather than LocalMachine, we limit the trust radius to your specific user profile, reducing system-wide risk.security.enterprise_roots.enabled) to respect Windows trust store.npm run untrust provides a clean teardown.
FriendlyName ("PacketPirateRoot"), ensuring we never touch other user certificates.This project is a practical example of System Programming using Node.js. It moves beyond typical web servers to interact with the Operating System and Network Stack at a lower level.
participant App as Application (VS Code)
participant OS as Windows OS
participant Proxy as Proxy Server
participant MITM as MITM Server
participant Web as Internet
Note over App,Proxy: 1. Plain HTTP Tunneling
App->>Proxy: CONNECT google.com:443
Proxy-->>App: 200 Connection Established
Note over Proxy,MITM: 2. The "Hand-Off" Trick
Proxy->>MITM: Pipe socket data (raw encrypted bytes)
Note over App,MITM: 3. TLS Handshake and Decryption
MITM-->>App: ServerHello (signed by local root CA)
App->>MITM: Encrypted request (GET /)
Note over MITM: 4. Interception Logic
MITM->>MITM: Decrypt → Inspect headers → Log
Note over MITM,Web: 5. Upstream Forwarding
MITM->>Web: New HTTPS request (GET /)
Web-->>MITM: Response
MITM-->>App: Response

Node.js's standard http module cannot handle the CONNECT method (used for HTTPS tunnels) and normal HTTPS traffic on the same server instance easily.
CONNECT request. It acts as a dumb TCP pipe.netstat Hack)How do we know which app is sending traffic? The TCP packets themselves don't have a "Process ID" sticker on them.
netstat -ano to find which PID owns port 54321.We use Node.js Streams to handle data efficiently. Instead of waiting for the full 10MB response to download before showing it, we "fork" the stream:
PassThrough streams, allowing real-time monitoring with minimal added latency.GNU GPL v3.0