【发布时间】:2021-10-08 18:30:56
【问题描述】:
对于 POC,我需要创建 MITM 设置,在该设置中我将监听接口上的 ICMP 流量,并且对于收到的所有 ping 命令,我会发送自己的回复。到目前为止,使用 python scapy,我已经能够拦截所有 ICMP 数据包。如何阻止实际的 ping 回复数据包并发送我自己的数据包作为回复?
我的代码是这样的
import scapy.all as scapy
import socket
from scapy.arch import get_if_hwaddr
from scapy.interfaces import get_if_list
from scapy.layers import http
from scapy.layers.inet import TCP, ICMP, IP
from scapy.layers.l2 import Ether
from uuid import getnode as get_mac
def sniffer(interface):
scapy.sniff(iface=interface, store=False, prn=process_packet)
def process_packet(packet):
if packet.haslayer(ICMP):
print("DUMP\n")
print(packet.show(dump=True))
print(packet[Ether].src)
print(Ether().src)
if packet[Ether].src == Ether().src:
print("OUTGOING PACKET")
else:
print("INCOMING PACKET")
interface = "Wi-Fi"
sniffer(interface)
【问题讨论】:
标签: networking scapy man-in-the-middle