Scapy Kamene发送SYN数据包

时间:2019-11-28 10:50:09

标签: tcp send scapy packet syn

我尝试使用以下代码将TCP SYN数据包从远程IP地址发送到本地IP地址。

from kamene.all import *
print("Send SYN from remote to local")
ip=IP(src=remote_ip,dst=local_ip,frag=0,tos=0x0)
tcp=TCP(sport=remote_port,dport=local_port, flags="S", seq=1111)
SYN_pkt = ip/tcp
SYNACK_pkt = srp(SYN_pkt,verbose=0)
ls(SYNACK_pkt) 

但是代码给出了以下错误。

Send SYN from remote to local
WARNING: DNS RR prematured end (ofs=16116, len=26)
WARNING:kamene.runtime:DNS RR prematured end (ofs=16116, len=26)
WARNING: wrong value: DNS.ancount=51411
WARNING:kamene.runtime:wrong value: DNS.ancount=51411
WARNING: wrong value: DNS.nscount=41893
WARNING:kamene.runtime:wrong value: DNS.nscount=41893
WARNING: more wrong value: DNS.arcount=778
WARNING:kamene.runtime:more wrong value: DNS.arcount=778
Not a packet class. Type 'ls()' to list packet classes.

如果我将srp()更改为sr1()以发送/接收数据包,则会出现以下错误。

Send SYN from remote to local
WARNING: Mac address to reach destination not found. Using broadcast.
WARNING:kamene.runtime:Mac address to reach destination not found. Using broadcast.
WARNING: DNS RR prematured end (ofs=16116, len=26)
WARNING:kamene.runtime:DNS RR prematured end(ofs=16116, len=26)
WARNING: wrong value: DNS.ancount=51411
WARNING:kamene.runtime:wrong value: DNS.ancount=51411
WARNING: wrong value: DNS.nscount=41893
WARNING:kamene.runtime:wrong value: DNS.nscount=41893
WARNING: more wrong value: DNS.arcount=778
WARNING:kamene.runtime:more wrong value: DNS.arcount=778

1 个答案:

答案 0 :(得分:0)

DNS RR prematured是Scapy遇到的DNS错误。

was fixed ages ago,但是因为您使用的是kamene而不是Scapy,所以仍然会遇到它。

切换到Scapy。 参见https://stackoverflow.com/a/54578802/5459467