Using Scapy

Basics

BEFORE WE CAN SEND PACKETS, WE MUST FIX IPTABLES! SCAPY BYPASSES THE NORMAL KERNEL PROCEDURES!

Without this, we will NEVER see the responses from our packets we send!

iptables –A OUTPUT –p tcp –tcp-flags RST RST –j DROP

There are several basics we can use to create layers in a packet for whatever we would like!

Command

Description

ls()

list protocols or variable

lsc()

list supported commands

send()

send layer 3, match all responses

sendp()

send layer 2, no response

srp1()

send layer 2, match 1 response

srp()

send layer 2, match all responses

# send and receive [packet], define the return as ans and unans with “_”, print the summary
sr([packet]);
ans, unans = _
ans.summary()

# send a TCP snipe to end the connection, must hit the correct seq from the most recent ack in order to be accepted
send(IP(dst=”192.168.1.200”)/TCP(sport=45089, dport=999, flags=”RA”, seq=3689929657))

i = sniff(filter=”host 192.168.1.100 and icmp”, count=2)
i.summary()

Last updated