0

我尝试使用以下代码将 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
4

1 回答 1

0

DNS RR prematured是 Scapy 的一个 DNS 错误。

很久以前就修复了,但是因为您使用的是kamene代替Scapy,所以您仍然会遇到它。

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

于 2019-11-28T11:34:08.750 回答