-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraffic.py
More file actions
37 lines (30 loc) · 895 Bytes
/
traffic.py
File metadata and controls
37 lines (30 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import scapy.all as scapy
import requests
import threading
# Function to capture packets
def packet_sniffer():
def packet_callback(packet):
print(packet.summary())
scapy.sniff(prn=packet_callback, store=False)
# Function to fetch the URL
def fetch_url(url):
response = requests.get(url)
print(f"\nResponse from {url}:")
print(response.text[:200]) # Print the first 200 characters of the response
# Main function
def main():
url = input("Enter the website URL: ")
# Start the packet sniffer in a separate thread
sniffer_thread = threading.Thread(target=packet_sniffer)
sniffer_thread.daemon = True
sniffer_thread.start()
# Fetch the URL
fetch_url(url)
# Keep the script running
try:
while True:
pass
except KeyboardInterrupt:
print("\nExiting program.")
if __name__ == "__main__":
main()