1. Capturing Packets with Scapy: -------------------------------- from scapy.all import sniff def packet_callback(packet): print(packet.summary()) sniff(prn=packet_callback, count=10) 2. Extracting HTTP Requests: ---------------------------- import dpkt import socket def analyze_pcap(filename): with open(filename, 'rb') as f: pcap = dpkt.pcap.Reader(f) for timestamp, buf in pcap: eth = dpkt.ethernet.Ethernet(buf) if isinstance(eth.data, dpkt.ip.IP): ip = eth.data if isinstance(ip.data, dpkt.tcp.TCP): tcp = ip.data if tcp.dport == 80 and tcp.data: print("HTTP Request:", tcp.data) analyze_pcap("capture.pcap") (Capture using tcpdump / Wireshark) 3. Challenge Task: ------------------ * Write a Python script to detect SYN scans by analyzing a pcap file. * Identify IPs sending multiple SYN packets without completing handshakes.