#!/usr/bin/env python3
# Serves attacker.html / victim.html on 127.0.0.1:8080. Map two hostnames to
# 127.0.0.1 (Chrome treats *.localhost as loopback automatically):
#   http://attacker.localhost:8080/attacker.html
#   http://victim.localhost:8080/victim.html
import http.server, socketserver, os

os.chdir(os.path.dirname(os.path.abspath(__file__)))
PORT = 8080

class H(http.server.SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_header('Cache-Control', 'no-store')
        super().end_headers()

with socketserver.TCPServer(('127.0.0.1', PORT), H) as httpd:
    httpd.allow_reuse_address = True
    print(f'Serving on http://127.0.0.1:{PORT}')
    print(f'  attacker: http://attacker.localhost:{PORT}/attacker.html')
    print(f'  victim:   http://victim.localhost:{PORT}/victim.html')
    httpd.serve_forever()
