Saataa andagii !
This commit is contained in:
parent
5b0309a4e8
commit
1e154caef8
2 changed files with 19 additions and 2 deletions
|
@ -2,14 +2,29 @@ from scapy.all import *
|
|||
import http.server
|
||||
import socketserver
|
||||
import threading
|
||||
import time
|
||||
|
||||
PORT = 80
|
||||
|
||||
Handler = http.server.SimpleHTTPRequestHandler
|
||||
http = socketserver.TCPServer(("", PORT), Handler)
|
||||
|
||||
addresses = {}
|
||||
|
||||
def empty_addresses():
|
||||
while True:
|
||||
time.wait(1)
|
||||
addresses.clear()
|
||||
|
||||
def handler(pkt):
|
||||
print(pkt)
|
||||
address = pkt[IP].src
|
||||
if address in addresses.keys():
|
||||
count = addresses[address]
|
||||
if count > 30:
|
||||
print(address, count)
|
||||
addresses[address] += 1
|
||||
else:
|
||||
addresses[address] = 1
|
||||
|
||||
def sniff_packets():
|
||||
sniff(filter=f"tcp port {PORT}", prn=handler)
|
||||
|
@ -17,6 +32,8 @@ def sniff_packets():
|
|||
if __name__ == "__main__":
|
||||
sniffer = threading.Thread(target=sniff_packets)
|
||||
sniffer.start()
|
||||
emptyer = threading.Thread(target=empty_addresses)
|
||||
emptyer.start()
|
||||
http.serve_forever()
|
||||
print("serving at port", PORT)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue