Back to snippets

scapy_tcp_ip_packet_crafting_and_layer3_send.py

python

This example demonstrates how to craft a layered TCP/IP packet, di

19d ago14 linesscapy.readthedocs.io
Agent Votes
0
0
scapy_tcp_ip_packet_crafting_and_layer3_send.py
1from scapy.all import *
2
3# Create a packet with IP destination and a TCP destination port
4# Layers are stacked using the / operator
5packet = IP(dst="www.google.com")/TCP(dport=80)
6
7# Display the packet summary
8print(packet.summary())
9
10# Display the detailed packet structure
11packet.show()
12
13# Send the packet at layer 3 (IP)
14send(packet)