发送数据包并更改其源IP [英] Send packet and change its source IP

查看:1006
本文介绍了发送数据包并更改其源IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有一个用python编写的应用程序,用于发送ping或电子邮件.如何使用例如Scapy将发送的数据包的源IP地址更改为伪造的IP地址?

Lets say I have an application written in python to send a ping or e-mail. How can I change the source IP address of the sent packet to a fake one, using, e.g., Scapy?

请考虑分配给我的eth0的IP地址是192.168.0.100.我的电子邮件应用程序将使用此IP发送消息.但是,我想在准备好发送该数据包时对其进行操作,因此其源IP不是192.168.0.100,而是192.168.0.101.

Consider that that the IP address assigned to my eth0 is 192.168.0.100. My e-mail application will send messages using this IP. However, I want to manipulate this packet, as soon as it is ready to be sent, so its source IP is not 192.168.0.100 but 192.168.0.101 instead.

我想执行此操作而无需实现MITM.

I'd like to do this without having to implement a MITM.

推荐答案

您可以执行以下操作:

from scapy.all import *

A = '192.168.0.101' # spoofed source IP address
B = '192.168.0.102' # destination IP address
C = 10000 # source port
D = 20000 # destination port
payload = "yada yada yada" # packet payload

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

有关一些更有趣的示例,您可以参考本教程

For some more interesting examples, you may refer to this tutorial.

这篇关于发送数据包并更改其源IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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