SCAPY(1)
π¦ SCAPY(1) β the girlies' guide to packet manipulation π¦
okay bestie, welcome to scapy(1) from the General Commands Manual β this is the page for the Scapy tool and it is lowkey iconic, highkey powerful, and fr fr one of my faves. sit down, grab a strawberry, we're doing packets today. πβ¨
β¨ NAME β¨
scapy β interactive packet manipulation tool π
πΈ SYNOPSIS πΈ
scapy [options]
that's it. that's the whole vibe. π
π DESCRIPTION π
This manual page documents briefly the Scapy tool. (briefly!! because there's so much more, iykyk.)
Scapy is a powerful interactive packet manipulation tool, packet generator, network scanner, network discovery, packet sniffer, etc. And the way that it can, for the moment, replace hping, parts of nmap, arpspoof, arp-sk, arping, tcpdump, tshark, p0f, ... β like, the whole roster. not me casually replacing your entire toolbelt. π
Scapy uses the Python interpreter as a command board. Which means you can use the Python language directly β assign variables, use loops, define functions, etc. you're literally in Python, bestie. it's giving "I have a REPL and I'm not afraid to use it". π₯
The idea is simple. Those kinds of tools do two things: sending packets and receiving answers. That's what Scapy does: you define a set of packets, it sends them, receives answers, matches requests with answers, and returns a list of packet couples (request, answer) and a list of unmatched packets. This has the big advantage over tools like nmap or hping that an answer is not reduced to (open/closed/filtered) β it's the whole packet. PERIODT. π
On top of this can be used to build more high-level functions, for example:
- one that does traceroutes and gives as a result only the start TTL of the request and the source IP of the answer
- one that pings a whole network and gives the list of machines answering
- one that does a portscan and returns a LaTeX report πβ¨
like ma'am?? a LaTeX report?? obsessed.
β¨ OPTIONS β¨
Options for Scapy are:
-hβ display usage π«Ά-Hβ header-less mode, also reduces verbosity. (quiet mode, she's shy)-dβ increase log verbosity. Can be used many times. (stack it like your iced coffees β)-pPRESTART_FILE β use PRESTART_FILE instead of$HOME/.config/scapy/prestart.pyas pre-startup file-Pβ do not run prestart file π«-cSTARTUP_FILE β use STARTUP_FILE instead of$HOME/.config/scapy/startup.pyas startup file-Cβ do not run startup file π«
π COMMANDS π
Only the vital commands to begin are listed here for the moment. (for the moment!! there's more coming, girlies, stay tuned.)
ls()β lists supported protocol layers. If a protocol layer is given as parameter, lists its fields and types of fields. If a string is given as parameter, it is used to filter the layers. πlsc()β lists scapy's main user commands. πconfβ this object contains the configuration. βοΈ
π§ FILES π§
$HOME/.config/scapy/prestart.pyβ This file is run before Scapy core is loaded. Only theconfobject is available. This file can be used to configure the CLI, configure parameters such as theconf.load_layerslist to choose which layers will be loaded, or change the logging level (for instance):
conf.interactive_shell = "bpython"
log_loading.setLevel(logging.WARNING)
conf.load_layers.remove("bluetooth")
conf.load_layers.append("new_layer")
$HOME/.config/scapy/startup.pyβ This file is run after Scapy is loaded. It can be used to configure more of Scapy behaviors, like un-registering layers:
conf.prog.pdfreader = "xpdf"
split_layers(UDP,DNS)
π EXAMPLES π
More verbose examples are available in the documentation at https://scapy.readthedocs.io/. Just run scapy and try the following commands in the interpreter. π«Ά
Test the robustness of a network stack with invalid packets:
sr(IP(dst="172.16.1.1", ihl=2, options=["verb$2"], version=3)/ICMP(), timeout=2)
Packet sniffing and dissection (with a bpf filter or tshark-like output):
a=sniff(filter="tcp port 110")
a=sniff(prn = lambda x: x.show)
Sniffed packet re-emission:
a=sniff(filter="tcp port 110")
sendp(a)
Pcap file packet re-emission:
sendp(rdpcap("file.cap"))
Manual TCP traceroute:
sr(IP(dst="www.google.com", ttl=(1,30))/TCP(seq=RandInt(), sport=RandShort(), dport=dport)
Protocol scan:
sr(IP(dst="172.16.1.28", proto=(1,254)))
ARP ping:
srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="172.16.1.1/24"))
ACK scan:
sr(IP(dst="172.16.1.28")/TCP(dport=(1,1024), flags="A"))
Passive OS fingerprinting:
sniff(prn=prnp0f)
Active OS fingerprinting:
nmap_fp("172.16.1.232")
ARP cache poisoning:
sendp(Ether(dst=tmac)/ARP(op="who-has", psrc=victim, pdst=target))
Reporting:
report_ports("192.168.2.34", (20,30))
π SEE ALSO π
- The official website:
https://scapy.net/ - The GitHub Development repository:
https://github.com/secdev/scapy/ - The official documentation:
https://scapy.readthedocs.io/en/latest/
π BUGS π
ngl bestie, she's not perfect and we're gonna be honest about it:
- Does not give the right source IP for routes that use interface aliases. π
- May miss packets under heavy load. This is a restriction from python itself. π
- Session saving is limited by Python ability to marshal objects. As a consequence,
lambdafunctions and generators can't be saved, which seriously reduce the usefulness of this feature. π - BPF filters don't work on Point-to-point interfaces. π«
π AUTHOR π
Philippe Biondi and the Scapy community. π«Ά
and that's the whole page, bestie!! this manual page is from March 24, 2024, SCAPY(1), and it's the one and only scapy(1) β slay, go send some packets, and remember: every answer is the whole packet, not just open/closed/filtered. main character energy only. π
β¨π
π¦ where this page comes from
- ubuntu resolute: python3-scapy 2.7.0+dfsg1-1 Β· GPL-2.0-only
- ubuntu stonking: python3-scapy 2.7.0+dfsg1-1 Β· GPL-2.0-only
- π the page's license: GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms