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

View file

@ -1,28 +1,9 @@
services: services:
proxy-server: web:
build: build:
context: ./proxy-server context: .
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: proxy-server container_name: web
networks:
server:
ipv4_address: 172.16.150.100
ports:
- 8080:80
web-server:
image: nginx:latest
container_name: web-server
networks:
server:
ipv4_address: 172.16.150.101
ports: ports:
- 80:80 - 80:80
networks:
server:
ipam:
driver: default
config:
- subnet: 172.16.150.0/24

11
server/index.html Normal file
View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic web server</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>

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)

View file

@ -1,10 +0,0 @@
from scapy.all import *
PORT = 80
def handler(pkt):
print(pkt)
if __name__ == "__main__":
sniff(filter=f"tcp port {PORT}", prn=handler)

6
server/style.css Normal file
View file

@ -0,0 +1,6 @@
body {
background-color: black;
color: white;
font-family: "Comic Sans MS";
text-align: center;
}