https://scapy.net/
https://scapy.readthedocs.io/en/latest/
https://scapy.net/?try=1
https://github.com/secdev/scapy
The repo/docs has some jupyter notebooks also.
https://github.com/0xbharath/art-of-packet-crafting-with-scapy
https://scapy.disruptivelabs.in/scapy/index.html
$ sudo scapy
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# If run in script
# from scapy.all import * # type: ignore
ls()
explore()
lsc()
ls(DNS)
ls(TCP)
ls(UDP)
ls(IP)
ls(ICMP)
ls(ARP)
ls(Dot11)
conf
conf.route
conf.ifaces
pkt = IP(dst="mst.edu")
pkt.dst
pkt.scr
pkt.ttl
pkt.show()
pkt.show2()
pkt.summary()
[p for p in pkt]
# Ping packet to my local gateway
ping_pkt = IP(dst="10.138.27.13")/ICMP()
ping_pkt.show()
ping_pkt.show2()
ping_pkt.summary()
# Actually sending the packet!
ans, unans = sr(ping_pkt)
ans.show()
ans.summary()
# A packet to broadcast on lan, UDP junk
pkt2 = Ether(dst="ff:ff:ff:ff:ff:ff")/IP(dst="10.138.27.13")/UDP()
pkt3.show()
pkt3.show2()
pkt3.summary
# Web request
pkt3 = IP(dst="info.cern.ch")/TCP()/"GET / HTTP/1.0\r\nHost:Host: info.cern.ch\r\n\r\n"
pkt3.show()
pkt3.summary()