Skip to content

Instantly share code, notes, and snippets.

@sjorge

sjorge/1_setup Secret

Last active May 24, 2018 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjorge/ededf9c6ef583a6a6fe528a14f6ed945 to your computer and use it in GitHub Desktop.
Save sjorge/ededf9c6ef583a6a6fe528a14f6ed945 to your computer and use it in GitHub Desktop.
Using scapy to send an IP packet to 10.23.40.210 (computenode) from 10.23.40.42 (raspberry pi) both on the same subnet with just a switch in between.
10.23.40.42[ue0] --> switch --> [ixgbe0]10.23.40.210
# Send an IPv4 packet with version set to 6 to TCP port 80
>>> IP(dst='10.23.40.210', version=6)
<IP version=6 dst=10.23.40.210 |>
>>> TCP(dport=80, flags="S")
<TCP dport=http flags=S |>
>>> send(IP(dst='10.23.40.210', version=6)/TCP(dport=80, flags="S"))
WARNING: Mac address to reach destination not found. Using broadcast.
.
Sent 1 packets.
[root@carbon ~]# netstat -s | grep Hdr
ipInReceives = 246 ipInHdrErrors = 1
ipv6InReceives = 13451 ipv6InHdrErrors = 0
... sending packet ...
[root@carbon ~]# snoop -d ixgbe0 'host 10.23.40.210'
Using device ixgbe0 (promiscuous mode)
VLAN#40: 4006:f5a5:a17:282a:a17:28d2:14:50 -> ::5002:2000:2a55:0 IPv6 S=4006:f5a5:a17:282a:a17:28d2:14:50 D=::5002:2000:2a55:0 LEN=1 HOPS=0 CLASS=0x0 FLOW=0x28
[root@carbon ~]# netstat -s | grep Hdr
ipInReceives = 247 ipInHdrErrors = 2
ipv6InReceives = 13506 ipv6InHdrErrors = 0
# scapy
>>> e=Ether(type=0x86dd, dst="0:25:90:f1:55:6")
>>> i=IP(dst='10.23.40.210')
>>> t=TCP(dport=80, flags="S")
>>> e,i,t
(<Ether dst=0:25:90:f1:55:6 type=0x86dd |>, <IP dst=10.23.40.210 |>, <TCP dport=http flags=S |>)
>>> sendp(e/i/t)
.
Sent 1 packets.
# snoop on computenode
nothing arrives
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment