Skip to content

About

A Node.js tool that uses Puppeteer to intercept and log all HTTP requests made by a browser during your interactions. Perfect for reverse engineering APIs and understanding how web applications communicate with their backends.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Puppeteer Request Interceptor

A Node.js tool that uses Puppeteer to intercept and log all HTTP requests made by a browser during your interactions. Perfect for reverse engineering APIs and understanding how web applications communicate with their backends.

Features

  • 🌐 Opens a real browser window for manual interaction
  • 📝 Logs all HTTP requests (GET, POST, PUT, DELETE, etc.)
  • 📥 Captures response data including status codes and response bodies
  • 💾 Saves everything to a structured JSON file
  • 🔧 Generates curl commands for easy API replication
  • ⚡ Real-time console logging of requests

Installation

  1. Install dependencies:
npm install

Usage

Basic Usage

npm start

Start with a specific URL

node interceptor.js example.com
# or
node interceptor.js https://example.com/login

How It Works

  1. Start the script - A browser window will open
  2. Navigate and interact - Go to any website, fill forms, click buttons, make logins, etc.
  3. Monitor in real-time - See all HTTP requests logged in your terminal
  4. Stop when done - Press Ctrl+C to stop and save all captured data

Output Files

When you stop the script, it generates:

intercepted_requests.json

Complete structured data including:

  • All requests with headers, POST data, timestamps
  • All responses with status codes, headers, response bodies
  • Combined request-response pairs
  • Session metadata

intercepted_requests.log

Real-time log file that records:

  • All HTTP requests and responses as they happen
  • Timestamps for each event
  • POST data and response bodies (when applicable)
  • Session start and end markers
  • Human-readable format for easy monitoring

Example Use Cases

  • Login Flow Analysis: See exactly what credentials are sent and how authentication works
  • API Discovery: Find hidden API endpoints used by web applications
  • Form Submission: Understand complex form data structures
  • AJAX Debugging: Capture dynamic requests made by JavaScript
  • Authentication Reverse Engineering: See how tokens, cookies, and sessions work

Log file output (intercepted_requests.log):

[2024-01-15T10:30:45.123Z] ===== Puppeteer Request Interceptor Started =====
[2024-01-15T10:30:47.456Z] REQUEST POST https://api.example.com/login
[2024-01-15T10:30:47.457Z] POST_DATA {"username":"user","password":"pass"}
[2024-01-15T10:30:48.234Z] RESPONSE 200 POST https://api.example.com/login
[2024-01-15T10:30:48.567Z] REQUEST GET https://api.example.com/dashboard
[2024-01-15T10:30:49.123Z] RESPONSE 200 GET https://api.example.com/dashboard
[2024-01-15T10:31:15.789Z] ===== Session Ended - 2 requests, 2 responses =====

Generated curl command:

curl -X POST 'https://api.example.com/login' \
  -H 'Content-Type: application/json' \
  -H 'User-Agent: Mozilla/5.0...' \
  -d '{"username":"user","password":"pass"}'

Tips

  • The browser runs in non-headless mode so you can see and interact with it normally
  • All major HTTP methods are captured (GET, POST, PUT, DELETE, PATCH, etc.)
  • Response bodies are captured for JSON and text content types
  • Use the generated curl commands to test APIs independently
  • Check the JSON file for detailed request/response analysis
  • Monitor the .log file in real-time with tail -f intercepted_requests.log
  • The log file is written immediately as requests happen, useful for live monitoring

Troubleshooting

  • If Puppeteer fails to install, try: npm install puppeteer --unsafe-perm=true
  • On Linux, you might need: sudo apt-get install -y chromium-browser
  • Make sure you have sufficient permissions to write files in the current directory

About

A Node.js tool that uses Puppeteer to intercept and log all HTTP requests made by a browser during your interactions. Perfect for reverse engineering APIs and understanding how web applications communicate with their backends.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages