简体   繁体   中英

Scapy sending proto as ipv6 for a ipv4 packet

Here is my code is SCAPY

#! /usr/bin/env python
from scapy.all import *

source_port = 25000
dest_port = 23
ip = IP(src="192.168.21.146",dst="192.168.21.168")
num_seq=10
SYN=TCP(sport=source_port,dport=dest_port,flags="S",seq=num_seq)
SYNACK=sr1(ip/SYN)
payload1="/etc/passwd"
num_ack=SYNACK.seq + 1
num_seq=num_seq=1
ACK=TCP(sport=source_port,dport=dest_port,flags="A",ack=num_ack,seq=num_seq)
send(ip/ACK)
PUSH = TCP(sport=source_port,dport=dest_port,flags="PA",ack=num_ack)
PUSH.seq=num_seq
first=fragment(ip/PUSH/payload1,fragsize=24)
send(first)

So as you see, I am trying to initiate 3 way handshake and then sending /etc/passwd(fragmented). However, upon checking wireshark, everything works fine until 3 way and when I am sending the payload /etc/passwd, the packets are displayed as follows

1 0.000000000 192.168.21.146 → 192.168.21.168 TCP 54 25000 → 23 [SYN] Seq=10 Win=8192 Len=0
2 0.000282483 192.168.21.168 → 192.168.21.146 TCP 60 23 → 25000 [SYN, ACK] Seq=2859111682 Ack=11 Win=29200 Len=0 MSS=1460
3 0.074613619 192.168.21.146 → 192.168.21.168 TCP 54 25000 → 23 [ACK] Seq=1 Ack=2859111683 Win=8192 Len=0
4 0.166245933 192.168.21.146 → 192.168.21.168 IPv4 58 Fragmented IP protocol (proto=IPv6 Hop-by-Hop Option 0, off=0, ID=0001)
5 0.167909879 192.168.21.146 → 192.168.21.168 IPv4 41 IPv6 Hop-by-Hop Option (0)

So if you see here at packet 4 and 5, I am not sure where hop-by-hop and proto ipv6 coming from. Proto should be TCP. Can anyone please help me here. Any help is greatly appreciated.

I don't know which version of Scapy you are using, but this looks a lot like bugs we have fixed several months ago. You should try with Scapy's current development version from Github .

Your code works fine for me!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM