How are port ranges specified in Scapy when crafting a packet?

Study for the SANS560 GIAC Penetration Tester (GPEN) Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

How are port ranges specified in Scapy when crafting a packet?

Explanation:
Port ranges in Scapy are expressed as a tuple in the destination port field. The (start, end) form signals Scapy to expand to every port in that inclusive range when crafting packets. This is shown by using parentheses to create the tuple, not square brackets or braces. For example, IP()/TCP(dport=(20, 80)) will generate packets for ports 20 through 80. If you specify a single port, you provide an integer like 80. If you need discrete ports, you could use a list of ports, but that’s not a range. The key point is that a port range uses a tuple inside the dport field.

Port ranges in Scapy are expressed as a tuple in the destination port field. The (start, end) form signals Scapy to expand to every port in that inclusive range when crafting packets. This is shown by using parentheses to create the tuple, not square brackets or braces. For example, IP()/TCP(dport=(20, 80)) will generate packets for ports 20 through 80. If you specify a single port, you provide an integer like 80. If you need discrete ports, you could use a list of ports, but that’s not a range. The key point is that a port range uses a tuple inside the dport field.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy