0

I tried sending a TCP SYN packet from a remote IP address to my local IP address using the following code.

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) 

But the code is giving the following error.

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.

If I change the srp() to sr1() to send/receive packet, it is giving the below error.

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 Answers1

0

DNS RR prematured was a DNS bug Scapy had.

It was fixed ages ago, but because you are using kamene instead of Scapy, you still encounter it.

Switch to Scapy. See https://stackoverflow.com/a/54578802/5459467

Cukic0d
  • 5,111
  • 2
  • 19
  • 48