SlideShare a Scribd company logo
1 of 1
SCAPY                                                                                                    packetlife.net
               Basic Commands                                       Specifying Addresses and Values
ls()
                                                     # Explicit IP address (use quotation marks)
List all available protocols and protocol options
                                                     >>> IP(dst="192.0.2.1")
lsc()
List all available scapy command functions           # DNS name to be resolved at time of transmission
conf                                                 >>> IP(dst="example.com")
Show/set scapy configuration parameters
                                                     # IP network (results in a packet template)
            Constructing Packets                     >>> IP(dst="192.0.2.0/24")
# Setting protocol fields                            # Random addresses with RandIP() and RandMAC()
>>> ip=IP(src="10.0.0.1")                            >>> IP(dst=RandIP())
>>> ip.dst="10.0.0.2"                                >>> Ether(dst=RandMAC())
# Combining layers                                   # Set a range of numbers to be used (template)
>>> l3=IP()/TCP()                                    >>> IP(ttl=(1,30))
>>> l2=Ether()/l3
                                                     # Random numbers with RandInt() and RandLong()
# Splitting layers apart                             >>> IP(id=RandInt())
>>> l2.getlayer(1)
<IP frag=0 proto=tcp |<TCP              |>>
                                                                              Sending Packets
>>> l2.getlayer(2)
<TCP |>                                              send(pkt, inter=0, loop=0, count=1, iface=N)
                                                     Send one or more packets at layer three
              Displaying Packets                     sendp(pkt, inter=0, loop=0, count=1, iface=N)
                                                     Send one or more packets at layer two
# Show an entire packet
>>> (Ether()/IPv6()).show()                          sendpfast(pkt, pps=N, mbps=N, loop=0, iface=N)
                                                     Send packets much faster at layer two using tcpreplay
###[ Ethernet ]###
  dst= ff:ff:ff:ff:ff:ff                             >>> send(IP(dst="192.0.2.1")/UDP(dport=53))
  src= 00:00:00:00:00:00                             .
  type= 0x86dd                                       Sent 1 packets.
###[ IPv6 ]###                                       >>> sendp(Ether()/IP(dst="192.0.2.1")/UDP(dport=53))
     version= 6                                      .
     tc= 0                                           Sent 1 packets.
     fl= 0
     plen= None
                                                                     Sending and Receiving Packets
     nh= No Next Header
     hlim= 64                                        sr(pkt, filter=N, iface=N), srp(…)
     src= ::1                                        Send packets and receive replies
     dst= ::1                                        sr1(pkt, inter=0, loop=0, count=1, iface=N), srp1(…)
                                                     Send packets and return only the first reply
# Show field types with          default values
                                                     srloop(pkt, timeout=N, count=N), srploop(…)
>>> ls(UDP())                                        Send packets in a loop and print each reply
sport : ShortEnumField           =   1025   (53)
dport : ShortEnumField           =   53     (53)     >>> srloop(IP(dst="packetlife.net")/ICMP(), count=3)
len    : ShortField              =   None   (None)   RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140
chksum : XShortField             =   None   (None)   RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140
                                                     RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140
                     Fuzzing
                                                                              Sniffing Packets
# Randomize fields where applicable
>>> fuzz(ICMP()).show()                              sniff(count=0, store=1, timeout=N)
                                                     Record packets off the wire; returns a list of packets when stopped
###[ ICMP ]###
  type= <RandByte>                                   # Capture up to 100 packets (or stop with ctrl-c)
  code= 227                                          >>> pkts=sniff(count=100, iface="eth0")
  chksum= None                                       >>> pkts
  unused= <RandInt>                                  <Sniffed: TCP:92 UDP:7 ICMP:1 Other:0>

by Jeremy Stretch                                                                                                          v1.0

More Related Content

What's hot

[PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list [PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list nisivaasdfghj
 
Introduction to tcpdump
Introduction to tcpdumpIntroduction to tcpdump
Introduction to tcpdumpLev Walkin
 
Udp socket programming(Florian)
Udp socket programming(Florian)Udp socket programming(Florian)
Udp socket programming(Florian)Flor Ian
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90minsLarry Cai
 
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RIThe Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RIEleanor McHugh
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency designHyejong
 
Study of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramStudy of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramMeenakshi Devi
 
Go concurrency
Go concurrencyGo concurrency
Go concurrencysiuyin
 
Arp Dan Ipconfig Syntax
Arp Dan Ipconfig  SyntaxArp Dan Ipconfig  Syntax
Arp Dan Ipconfig Syntaxguestcc37e8c
 

What's hot (18)

Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
 
[PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list [PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list
 
Tcpdump
TcpdumpTcpdump
Tcpdump
 
tokyotalk
tokyotalktokyotalk
tokyotalk
 
Introduction to tcpdump
Introduction to tcpdumpIntroduction to tcpdump
Introduction to tcpdump
 
Udp socket programming(Florian)
Udp socket programming(Florian)Udp socket programming(Florian)
Udp socket programming(Florian)
 
Python in 90mins
Python in 90minsPython in 90mins
Python in 90mins
 
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RIThe Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
The Ruby Guide to *nix Plumbing: on the quest for efficiency with Ruby [M|K]RI
 
libpcap
libpcaplibpcap
libpcap
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency design
 
Sockets and Socket-Buffer
Sockets and Socket-BufferSockets and Socket-Buffer
Sockets and Socket-Buffer
 
Ip Access Lists
Ip Access ListsIp Access Lists
Ip Access Lists
 
Concurrency with Go
Concurrency with GoConcurrency with Go
Concurrency with Go
 
socket programming
socket programming socket programming
socket programming
 
Study of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramStudy of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proram
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
 
Go concurrency
Go concurrencyGo concurrency
Go concurrency
 
Arp Dan Ipconfig Syntax
Arp Dan Ipconfig  SyntaxArp Dan Ipconfig  Syntax
Arp Dan Ipconfig Syntax
 

Viewers also liked

Viewers also liked (13)

Cts assignment 3 brief
Cts assignment 3 briefCts assignment 3 brief
Cts assignment 3 brief
 
matric
matricmatric
matric
 
IDJ 1
IDJ 1IDJ 1
IDJ 1
 
PASAR SENI BOOKLET
PASAR SENI BOOKLETPASAR SENI BOOKLET
PASAR SENI BOOKLET
 
Plantas condimentares: cultivo e utilização
Plantas condimentares: cultivo e utilizaçãoPlantas condimentares: cultivo e utilização
Plantas condimentares: cultivo e utilização
 
Aula 02 propagação e implantação de plantas ornamentais
Aula 02   propagação e implantação de plantas ornamentaisAula 02   propagação e implantação de plantas ornamentais
Aula 02 propagação e implantação de plantas ornamentais
 
Performance Bottleneck Identification
Performance Bottleneck IdentificationPerformance Bottleneck Identification
Performance Bottleneck Identification
 
Citoplasma aulas 27 e 28 (1)
Citoplasma   aulas 27 e 28 (1)Citoplasma   aulas 27 e 28 (1)
Citoplasma aulas 27 e 28 (1)
 
Rajesh
RajeshRajesh
Rajesh
 
rajesh
rajeshrajesh
rajesh
 
Performance Testing
Performance TestingPerformance Testing
Performance Testing
 
2016 Dolsey Catalogue
2016 Dolsey Catalogue2016 Dolsey Catalogue
2016 Dolsey Catalogue
 
Family Health Care introduction
Family Health Care introductionFamily Health Care introduction
Family Health Care introduction
 

Similar to Scapy

Computer network (12)
Computer network (12)Computer network (12)
Computer network (12)NYversity
 
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Tom Paulus
 
Internet Technology Practical (Mumbai University) -2017
Internet Technology Practical  (Mumbai University) -2017Internet Technology Practical  (Mumbai University) -2017
Internet Technology Practical (Mumbai University) -2017Satyendra Singh
 
Tutorial of SF-TAP Flow Abstractor
Tutorial of SF-TAP Flow AbstractorTutorial of SF-TAP Flow Abstractor
Tutorial of SF-TAP Flow AbstractorYuuki Takano
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoScyllaDB
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking ExplainedThomas Graf
 
13048671.ppt
13048671.ppt13048671.ppt
13048671.pptLyVu51
 
Cs423 raw sockets_bw
Cs423 raw sockets_bwCs423 raw sockets_bw
Cs423 raw sockets_bwjktjpc
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commandsHanan Nmr
 
Make container without_docker_6-overlay-network_1
Make container without_docker_6-overlay-network_1 Make container without_docker_6-overlay-network_1
Make container without_docker_6-overlay-network_1 Sam Kim
 
TCP IP
TCP IPTCP IP
TCP IPhivasu
 
BSides London - Scapy Workshop
BSides London - Scapy WorkshopBSides London - Scapy Workshop
BSides London - Scapy WorkshopAdam Maxwell
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecturehugo lu
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Andriy Berestovskyy
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver艾鍗科技
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filterGiovanni Bechis
 

Similar to Scapy (20)

Computer network (12)
Computer network (12)Computer network (12)
Computer network (12)
 
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1
 
Internet Technology Practical (Mumbai University) -2017
Internet Technology Practical  (Mumbai University) -2017Internet Technology Practical  (Mumbai University) -2017
Internet Technology Practical (Mumbai University) -2017
 
Tutorial of SF-TAP Flow Abstractor
Tutorial of SF-TAP Flow AbstractorTutorial of SF-TAP Flow Abstractor
Tutorial of SF-TAP Flow Abstractor
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
 
GoでKVSを書けるのか
GoでKVSを書けるのかGoでKVSを書けるのか
GoでKVSを書けるのか
 
null Pune meet - Understanding TCP/IP and Network Intrusion
null Pune meet - Understanding TCP/IP and Network Intrusionnull Pune meet - Understanding TCP/IP and Network Intrusion
null Pune meet - Understanding TCP/IP and Network Intrusion
 
Ns2 introduction 2
Ns2 introduction 2Ns2 introduction 2
Ns2 introduction 2
 
13048671.ppt
13048671.ppt13048671.ppt
13048671.ppt
 
Cs423 raw sockets_bw
Cs423 raw sockets_bwCs423 raw sockets_bw
Cs423 raw sockets_bw
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commands
 
Make container without_docker_6-overlay-network_1
Make container without_docker_6-overlay-network_1 Make container without_docker_6-overlay-network_1
Make container without_docker_6-overlay-network_1
 
TCP IP
TCP IPTCP IP
TCP IP
 
BSides London - Scapy Workshop
BSides London - Scapy WorkshopBSides London - Scapy Workshop
BSides London - Scapy Workshop
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
 
Computer networkppt4577
Computer networkppt4577Computer networkppt4577
Computer networkppt4577
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filter
 

More from Mohamed Gamel (20)

Vyatta subnet range_cheat_sheet
Vyatta subnet range_cheat_sheetVyatta subnet range_cheat_sheet
Vyatta subnet range_cheat_sheet
 
Voip basics
Voip basicsVoip basics
Voip basics
 
Vla ns
Vla nsVla ns
Vla ns
 
Spanning tree
Spanning treeSpanning tree
Spanning tree
 
Rip
RipRip
Rip
 
Qo s
Qo sQo s
Qo s
 
Ppp
PppPpp
Ppp
 
Physical terminations
Physical terminationsPhysical terminations
Physical terminations
 
Ospf
OspfOspf
Ospf
 
Nat
NatNat
Nat
 
Media wiki
Media wikiMedia wiki
Media wiki
 
Markdown
MarkdownMarkdown
Markdown
 
Is is
Is isIs is
Is is
 
I pv6
I pv6I pv6
I pv6
 
I pv4 subnetting
I pv4 subnettingI pv4 subnetting
I pv4 subnetting
 
I pv4 multicast
I pv4 multicastI pv4 multicast
I pv4 multicast
 
I psec
I psecI psec
I psec
 
Ios zone based-firewall
Ios zone based-firewallIos zone based-firewall
Ios zone based-firewall
 
Ios i pv4_access_lists
Ios i pv4_access_listsIos i pv4_access_lists
Ios i pv4_access_lists
 
Ios interior routing_protocols
Ios interior routing_protocolsIos interior routing_protocols
Ios interior routing_protocols
 

Scapy

  • 1. SCAPY packetlife.net Basic Commands Specifying Addresses and Values ls() # Explicit IP address (use quotation marks) List all available protocols and protocol options >>> IP(dst="192.0.2.1") lsc() List all available scapy command functions # DNS name to be resolved at time of transmission conf >>> IP(dst="example.com") Show/set scapy configuration parameters # IP network (results in a packet template) Constructing Packets >>> IP(dst="192.0.2.0/24") # Setting protocol fields # Random addresses with RandIP() and RandMAC() >>> ip=IP(src="10.0.0.1") >>> IP(dst=RandIP()) >>> ip.dst="10.0.0.2" >>> Ether(dst=RandMAC()) # Combining layers # Set a range of numbers to be used (template) >>> l3=IP()/TCP() >>> IP(ttl=(1,30)) >>> l2=Ether()/l3 # Random numbers with RandInt() and RandLong() # Splitting layers apart >>> IP(id=RandInt()) >>> l2.getlayer(1) <IP frag=0 proto=tcp |<TCP |>> Sending Packets >>> l2.getlayer(2) <TCP |> send(pkt, inter=0, loop=0, count=1, iface=N) Send one or more packets at layer three Displaying Packets sendp(pkt, inter=0, loop=0, count=1, iface=N) Send one or more packets at layer two # Show an entire packet >>> (Ether()/IPv6()).show() sendpfast(pkt, pps=N, mbps=N, loop=0, iface=N) Send packets much faster at layer two using tcpreplay ###[ Ethernet ]### dst= ff:ff:ff:ff:ff:ff >>> send(IP(dst="192.0.2.1")/UDP(dport=53)) src= 00:00:00:00:00:00 . type= 0x86dd Sent 1 packets. ###[ IPv6 ]### >>> sendp(Ether()/IP(dst="192.0.2.1")/UDP(dport=53)) version= 6 . tc= 0 Sent 1 packets. fl= 0 plen= None Sending and Receiving Packets nh= No Next Header hlim= 64 sr(pkt, filter=N, iface=N), srp(…) src= ::1 Send packets and receive replies dst= ::1 sr1(pkt, inter=0, loop=0, count=1, iface=N), srp1(…) Send packets and return only the first reply # Show field types with default values srloop(pkt, timeout=N, count=N), srploop(…) >>> ls(UDP()) Send packets in a loop and print each reply sport : ShortEnumField = 1025 (53) dport : ShortEnumField = 53 (53) >>> srloop(IP(dst="packetlife.net")/ICMP(), count=3) len : ShortField = None (None) RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140 chksum : XShortField = None (None) RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140 RECV 1: IP / ICMP 174.143.213.184 > 192.168.1.140 Fuzzing Sniffing Packets # Randomize fields where applicable >>> fuzz(ICMP()).show() sniff(count=0, store=1, timeout=N) Record packets off the wire; returns a list of packets when stopped ###[ ICMP ]### type= <RandByte> # Capture up to 100 packets (or stop with ctrl-c) code= 227 >>> pkts=sniff(count=100, iface="eth0") chksum= None >>> pkts unused= <RandInt> <Sniffed: TCP:92 UDP:7 ICMP:1 Other:0> by Jeremy Stretch v1.0