This tutorial shows how to create a TCP header with scapy and how to associate a destination port with it. The destination port number of 80 is used which signifies the port number used by http.
1. The command sudo scapy starts scapy on the Ubuntu system.
2. The command ls(TCP) shows the list of commands which are available with the TCP header. These are the fields which are available in a typical TCP header.
3. The command tcp=TCP() creates a TCP Object.
4. The command tcp.dport==80 associates the TCP destination port as 80. Note that the sport command is not used. In this case, the operating system would select randomnly a source port for the TCP header.
Check out our course Python Scapy Network Programming and Automation Course on Udemy
The course will teach you how to use Python with scapy to create custom network tools and scripts for various purposes like network testing, protocol testing, automation and more. The course explains with source code and examples of different types of network scripts and tools.
The course is available on udemy platform. The details of the course can be checked out here – Python Scapy Network Programming and Automation Course
Check out our tutorial on How to build ARP packet with Scapy.