Cyber MITM Attack Lab Demo AI-GENERATED UI

This page explains and simulates the behavior of the lab's packet interception and selective forwarding logic implemented in sniffer1.py.

What the Lab Does

The result is a local MITM-like redirection of outbound HTTP requests before they leave the host, enabling inspection or modification.

Packet Flow Overview

  1. User process (browser/curl) initiates GET http://example.com/... (dst port 80).
  2. iptables rule rewrites destination to local :8080 (DNAT).
  3. Sniffer receives packet, parses HTTP method line + Host: header.
  4. If payload contains the censor token frankenstein → block & log [CENSORED].
  5. Else, craft a new packet: same IP src/dst, same TCP seq/ack/options, but destination port changed back to 80; recompute checksums; send.
  6. Log success Your packet has been forwarded to port 80.

Example Console Output

[HTTP] example.com/books
Your packet has been forwarded to port 80
[HTTP] example.com/search?q=novel
[CENSORED]
[HTTP] unknown/
No Payload Found

Interactive Simulation (Client-Side)

This JavaScript demo mimics only the decision logic (it does not perform real network interception).

Send a Fake HTTP Request
Simulated
Output will appear here…

Key Code Concepts

Limitations / Next Steps

Possible extensions: add TCP stream reassembly, log to file with timestamps, bidirectional proxying, richer content filtering rules, or upgrade to a transparent proxy.

How to Run the Real Lab

  1. Install dependencies (once): pip3 install scapy
  2. As root, apply iptables rules: sudo ./lab2setup.sh
  3. Run the sniffer: sudo python3 sniffer1.py
  4. In a separate terminal (non-root), make HTTP requests to trigger behavior:
    • Forwarded example (no body → may log No Payload Found):
      curl http://example.com/books
    • Forwarded example with body (allowed):
      curl -X POST -d "q=hello" http://example.com/search
    • Censored example (body contains frankenstein):
      curl -X POST -d "q=frankenstein" http://example.com/search
  5. Observe console output in the sniffer window.
  6. Stop with Ctrl+C; optional cleanup: sudo ./lab2teardown.sh.

Notes: The DNAT rule targets non-root processes only; run your test curl commands without sudo. This lab inspects plaintext HTTP on port 80; HTTPS is not intercepted.