python拦截修改数据包_python-用scapy作为MITM即时更改数据包

假设我设法处于客户端和服务器之间的通信中间(假设我打开了一个热点,并使客户端仅通过我的计算机连接到服务器).

如何在不中断自己与其他服务的通信的情况下更改客户端发送和接收的数据包?必须有一种方法可以通过我的脚本路由客户端既发送又要接收的所有数据包(在转发给他之前).

我认为使用iptables是实现此目标的正确方向,但不确定究竟是什么参数才适合完成这项工作.我已经有以下简单的脚本:

hotspotd start #a script that runs dnsmasq as both a DNS and DHCP server, configures and starts a hotspot

iptables -P FORWARD ACCEPT

iptables --append FORWARD --in-interface wlan0 -j ACCEPT

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

#wlan0 is the interface on which the hotspot is.

#eth0 is the interface that is connected to the internet

现在,这对于被动的MITM来说非常完美-我可以看到客户端发送和接收的所有内容.但是现在我想加强它并重定向他通过我发送和接收的每条消息.

我最终的目的是要达到一个可以执行以下脚本的级别:

from scapy.all import *

from scapy_http.http import *

def callback(pkt):

#Process the packet here, see source and destination addresses, ports, data

s

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值