RITSEC-Club-Activity-Monitor/packet_processer.py
2022-10-25 21:11:45 -04:00

34 lines
923 B
Python

import pcap, dpkt
from scapy.all import Ether, ARP
from time import sleep
def process_packet(info, timestamp, packet):
src = packet.src
dst = packet.dst
print(f"{timestamp} | {src}[{1 if is_ap(src) else 0}] --> {packet.dst}[{1 if is_ap(dst) else 0}]")
#packet.display()
#sleep(.5)
def get_scapy_packet(raw_packet):
eth_frame = dpkt.ethernet.Ethernet(raw_packet)
return Ether(raw_packet)
def is_ap(mac_address):
aruba_ouis = ['94:60:D5', '48:2F:6B', '94:64:24', 'A8:5B:F7', 'F0:61:C0', 'EC:50:AA', '6C:C4:9F']
for oui in aruba_ouis:
if oui in mac_address:
return True
return False
def sniff(interface, timeout_ms=500):
info = {}
sniff = pcap.pcap(name=interface, promisc=True, timeout_ms=timeout_ms)
for timestamp, raw_packet in sniff:
packet = get_scapy_packet(raw_packet)
info = process_packet(info, timestamp, packet)