1. Building an SYN Scanner: --------------------------- from scapy.all import IP, TCP, sr1 def syn_scan(target, port): pkt = IP(dst=target) / TCP(dport=port, flags="S") response = sr1(pkt, timeout=1, verbose=0) if response and response.haslayer(TCP): if response.getlayer(TCP).flags == 0x12: # SYN-ACK print(f"Port {port} is open on {target}") elif response.getlayer(TCP).flags == 0x14: # RST-ACK print(f"Port {port} is closed on {target}") else: print(f"Port {port} is filtered on {target}") target_ip = "192.168.1.1" for port in range(20, 100): syn_scan(target_ip, port) 2. Running the SYN Scanner: --------------------------- * Run the script against a controlled system. * Use Wireshark to visualize the traffic. 3. Modifications & Enhancements: -------------------------------- * Add multiple targets. * Multi-threading for faster scanning. * Scan only common ports.