Skip to content

Commit 09630b4

Browse files
committed
Added packet sniffing for run
1 parent b98ab85 commit 09630b4

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

list_interfaces.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from scapy.all import get_if_list
2+
3+
# List all available network interfaces
4+
interfaces = get_if_list()
5+
print("Available network interfaces:")
6+
for iface in interfaces:
7+
print(iface)

packet_sniffer.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from scapy.all import sniff
2+
import logging
3+
4+
# Set up logging to log to both the terminal and a file
5+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', handlers=[
6+
logging.FileHandler("packet_sniffer.log"),
7+
logging.StreamHandler()
8+
])
9+
10+
def packet_callback(packet):
11+
# This function will be called for each packet captured
12+
packet_info = f"Packet: {packet.summary()}"
13+
logging.info(packet_info)
14+
15+
def main():
16+
# Start sniffing packets
17+
print("Starting packet sniffer...")
18+
sniff(prn=packet_callback, store=False)
19+
20+
if __name__ == "__main__":
21+
main()

0 commit comments

Comments
 (0)