There are three containers; Client, Flaskr and Student, that are connected by a bridge network named cns
- Client: a container with Firefox running on it. To access Firefox from host, connect via
http://localhost:5800
. - Flaskr: is hosting an HTTP server.
- Student: this is the eavesdropper (man-in-the-middle) container.
-
Log into container repository,
export CR_PAT=<your-personal-access-token>
echo $CR_PAT | podman login ghcr.io -u <your-github-username> --password-stdin
then runpodman-compose up -d
to build and start the containers.
-
Connect to Client's Firefox instance by visiting
http://localhost:5800
on host computer. -
Access the HTTP server via
http://cns_flaskr
on the Client's Firefox instance. -
Open three instances (3 terminals or tmux) of the Student container by running
podman exec -it cns_student /bin/bash
on each terminal. -
Use the
dig
command to determine the IPs of Client and Flaskr containers.dig cns_client
dig cns_flaskr
-
With this information, run arpspoof twice, once for each bash instance.
- In the first bash window:
arpspoof –t cns_client cns_flaskr
(Tells cns_client that cns_flaskr is at cns_students MAC address)
- In the second bash window:
arpspoof –t cns_flaskr cns_client
(Tells cns_flaskr that cns_client is at cns_students MAC address)
- Reloading the page still shows the normal website, since Student is not yet blocking any packets.
- In the first bash window:
-
Now run
bash add_iptables_rule.sh
to add a rule toiptables
that forwards any packet with port 80 destination to the proxy. -
You may verify that Client's browser will give an error when reloading the page. This is because Student is not blocking the packets but forwarding them to the proxy. Since the proxy is not active yet, the packets are simply dropped.
-
Activate the proxy in a transparent mode:
mitmproxy -m transparent
-
Reload the browser page; the honest page shows again, but mitmproxy shows that the request passed through Student.
-
Inspect traffics by clicking on each listing. Press key
q
to go back. -
Shutdown the proxy and activate it again with a script.
Ctrl + c → y → Enter
(shutdown proxy)mitmproxy –m transparent –s proxy.py
-
Reload the Firefox browser; title page changes to 'Flaskr-Spoofed' instead of 'Flaskr'.
-
Alternatively running
./mirmproxy.sh
will perform the previous steps automatically. Adding the-s
flag will run mitmproxy with the studentsproxy.py
file as script.