Skip to content

kunaldevelopers/browser-network-traffic-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 Browser Network Traffic Logger

Python Selenium License

A powerful Python script that leverages Selenium and Chrome DevTools Protocol (CDP) to capture, log, and analyze network traffic (Requests, Responses, and Headers) from a browser session. Ideally suited for debugging, monitoring, or analyzing web traffic with proxy support.


🚀 Features

  • Full Network Capture: Logs all HTTP requests, responses, and headers.
  • Session Management: Automatically creates timestamped folders (e.g., session_20231027_123000) for each run to keep logs organized.
  • Proxy Support: Native support for authenticated proxies (ip:port:user:pass) with automatic extension generation.
  • Stealth Mode: Includes basic anti-detection flags to avoid simple bot detection.
  • Real-time Logging: Writes data to files immediately as traffic is captured.

🛠️ Installation

1. Clone the Repository

git clone https://github.com/kunaldevelopers/browser-network-traffic-logger.git
cd browser-network-traffic-logger

2. Install Dependencies

Ensure you have Python installed, then run:

pip install -r requirements.txt

Note: This project requires Google Chrome to be installed on your machine.


⚙️ Configuration

Proxy Setup (Optional)

If you wish to use proxies, create a file named proxy.txt in the root directory. Add your proxies line-by-line in the following format:

ip:port:username:password

Example proxy.txt:

192.168.1.1:8080:user123:pass456
10.0.0.5:3128:admin:secret

If the file is missing or empty, the script will run without a proxy.


🏃‍♂️ Usage

Run the script directly with Python:

python network_logger.py

How it works:

  1. The script launches a Chrome browser window.
  2. It constantly monitors network events (Network.requestWillBeSent, Network.responseReceived).
  3. You can manually navigate the web in the opened window.
  4. All traffic is logged into a new session_YYYYMMDD_HHMMSS folder.
  5. Press Ctrl+C in the terminal to stop the logger.

📂 Output Structure

After a session, you will find a new folder containing:

session_20231027_153000/
├── 📄 requests.txt   # Details of all outgoing HTTP requests (URL, Method, POST Data)
├── 📄 responses.txt  # Details of incoming responses (Status, Remote IP)
└── 📄 headers.txt    # Full request and response headers

📊 Workflow Diagram

sequenceDiagram
    participant User
    participant Script
    participant Browser
    participant Network
    participant Files

    User->>Script: Run network_logger.py
    Script->>Script: Create Session Folder
    Script->>Browser: Launch Chrome (with Proxy)
    Script->>Browser: Enable Network Debugging
    Browser->>Network: Request Page
    Network-->>Browser: Return Data
    Browser->>Script: Send Network Event (CDP)
    Script->>Files: Write to requests.txt / responses.txt
    User->>Script: Ctrl+C (Stop)
    Script->>Browser: Close Browser
Loading

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

Distributed under the MIT License. See LICENSE for more information.


Repository Link: https://github.com/kunaldevelopers/browser-network-traffic-logger

About

Capture browser network traffic such as API calls, requests, responses, and headers using Selenium. Includes proxy support and helps in automation testing, API analysis, and security research.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages