Changed the web server to be on the same program than the scapy program

This commit is contained in:
Lukian 2024-12-17 15:47:57 +01:00
parent 077b4e68b8
commit 9f0101b1c3
8 changed files with 42 additions and 32 deletions

22
server/main.py Normal file
View file

@ -0,0 +1,22 @@
from scapy.all import *
import http.server
import socketserver
import threading
PORT = 80
Handler = http.server.SimpleHTTPRequestHandler
http = socketserver.TCPServer(("", PORT), Handler)
def handler(pkt):
print(pkt)
def sniff_packets():
sniff(filter=f"tcp port {PORT}", prn=handler)
if __name__ == "__main__":
sniffer = threading.Thread(target=sniff_packets)
sniffer.start()
http.serve_forever()
print("serving at port", PORT)