Chapter 5: Analyzing Network Traffic

  1. What is the Scapy function that can capture packets in the same way that tools such as tcpdump and Wireshark do?

scapy> pkts = sniff (iface = "eth0", count = n), where n is the number of packets.

  1. What is the best way to send a packet with Scapy indefinitely every five seconds in the form of a loop?

scapy> sendp (packet, loop=1, inter=5)

  1. What is the method that must be invoked with Scapy to check whether a certain port (port) is open or closed on a certain machine (host), and also to show detailed information about how packets are being sent?

scapy> sr1(IP(dst=host)/TCP(dport=port), verbose=True)

  1. What functions are necessary for implementing the traceroute command in Scapy?

IP/UDP/sr1

Get Mastering Python for Networking and Security now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.