python多线程扫描_python实现多线程扫描网站目录
python实现网站目录扫描
st=>start: 程序开始
op=>operation: 打印banner信息
op2=>operation: 打印使用方法
op3=>operation: 接收传递过来的参数
cond=>condition: 判断参数是否接收完整(是或否?)
op6=>operation: 将传递过来的参数传递给指定变量
sub1=>subroutine: 没有接收完整
sub2=>subroutine: 打印错误信息
sub3=>subroutine: 直接退出程序
jieshu=>end: 直接退出程序
op4=>operation: 确定线程数,将字典按照线程数进行分组
op5=>operation: 执行扫描模块
io=>inputoutput: 输出扫描结果
e=>end: 程序执行完退出
st->op->op2->op3->cond
cond(yes)->op6->op4->op5->io->e
cond(no)->sub1(right)->sub2(right)-->sub3(right)
根据流程图确定使用getopt,sys模块来接受参数,并进行处理, threading模块来处理多线程, requests模块来执行扫描功能, math线程的向上取整.
打印工具的banner信息
def banner():
print ("*" * 57)
print ("*" * 3 + " " * 19 + "DirBrute v 1.0" + " " * 18 + "*" * 3)
print ("*" * 3 + " " * 12 + "This tool just develop fun!" + " " * 12 + "*" * 3)
print ("*" * 57)
声明使用方法
# python Dirbrute.py -u url -t thread -d dictionary
def usage():
print ("*" * 57)
print ("*" * 3 + " " * 13 + "This is the tool's usage" + " " * 14 + "*" * 3)
print ("*" * 3 + "python Dirbrute.py -u url -t threads -d dictionary!" + "*" * 3)
print ("*" * 57)
判断接收参数是否完整如果完整了传递给特定的变量
def start():
if len(sys.argv) == 7:
# This is true length
opts, args = getopt.getopt(sys.argv[1:], "u:t:d:")
for k, v in opts:
if k == "-u":
url =v
elif k == "-t":
threads = v
elif k == "-d":
dic = v
multi_scan(url, threads, dic)
else:
print ("Error Argument!")
sys.exit()
多线程的实现
第一步读字典文件
第二步 确定读取的行数 len(dic_list) / threads 向上去取整
第三步 确定每个线程读取的列表[[t1],[t2],[t3],...]
def multi_scan(url,threads,dic):
# 第一步读字典文件
# 第二步 确定读取的行数 len(dic_list) / threads 向上去取整
# 第三步 确定每个线程读取的列表[[t1],[t2],[t3],...]
result_list = []
threads_list = []
with open(dic, "r") as f:
dic_list = f.readlines()
if len(dic_list) % int(threads) == 0:
thread_read_line_num = len(dic_list) / int(threads)
else:
thread_read_line_num = math.ceil(len(dic_list) / int(threads))
i = 0
temp_list = []
for line in dic_list:
i += 1
if i % thread_read_line_num == 0:
temp_list.append(line.strip())
result_list.append(temp_list)
temp_list = []
else:
temp_list.append(line.strip())
for i in result_list:
# print (i)
threads_list.append(threading.Thread(target = scan, args = (url,i)))
for t in threads_list:
t.start()
扫描功能
def scan(url, dic):
# 实现扫描功能 requests
for line in dic:
r = requests.get(url = url + '/' + line)
if r.status_code == 200 or r.status_code == 302:
print (r.url + " : " + str(r.status_code))
调用程序
if __name__ == "__main__":
banner()
suage()
start()
程序结果:
pig@deep:~/Desktop$ python3 Dirbrute.py -u http://127.0.0.1/ -t 1 -d dic.txt
*********************************************************
*** DirBrute v 1.0 ***
*** This tool just develop fun! ***
*********************************************************
*********************************************************
*** This is the tool's usage ***
***python Dirbrute.py -u url -t threads -d dictionary!***
*********************************************************
http://127.0.0.1//readme.txt : 200
http://127.0.0.1//images/ : 200
http://127.0.0.1//index.html : 200
http://127.0.0.1/images/ : 200
pig@deep:~/Desktop$
python多线程扫描_python实现多线程扫描网站目录相关推荐
- python多线程没用_python的多线程到底有没有用?
在群里经常听到这样的争执,有人是虚心请教问题,有人就大放厥词因为这个说python辣鸡.而争论的核心无非就是,python的多线程在同一时刻只会有一条线程跑在CPU里面,其他线程都在睡觉.这是真的吗? ...
- python爬虫代理服务器_Python爬虫多线程抓取代理服务器
Python作为一门功能强大的脚本语言来说,经常被用来写爬虫程序,下面是Python爬虫多线程抓取代理服务器 首先通过谷歌把包含代理服务器地址的网页查出来,我选择从 http://www.88181. ...
- python不断刷新网页_python使用多线程不断刷新网页的方法
本文实例讲述了python使用多线程不断刷新网页的方法.分享给大家供大家参考.具体如下: 这段代码可以开通过个线程不断刷新指定的页面,可用于刷票,增加网页访问量等等,不用再去按F5了 import t ...
- python 多线程同步_Python利用多线程同步锁实现多窗口订票系统(推荐)
利用Python实现多窗口订票系统,利用 threading.Lock() 避免出现一票多卖,无票也卖的情况,并规范化输出情况. 代码: import threading import time ti ...
- python 主线程_Python threading多线程模块
Python是支持使用多线程的,程序代码可以在一个进程空间中操作管理多个执行的线程,python模块下载时要记得,这个库叫做 threading. 一.threading模块简介 在Python多线程 ...
- python多线程编程_python之多线程编程
python 之多线程编程 我们知道 python 中程序一般是从上往下依次执行的,那么即使没有什么联系的两件事也只 能是等一个执行完后再去执行另一个, 这样的就会很浪费时间, 那么有没有办法让两件事 ...
- python多线程没用_Python 的多线程原来不是真的多线程啊
55 2019-11-23 00:43:59 +08:00 1 所以这些 CS 导论就该明确方向的系列问题怎么还那么经-- 还是得从基础概念入手. https://stackoverflow.com/ ...
- python paramiko并发_python paramiko 多线程批量执行指令及批量上传文件和目录
源代码: 环境需求: 1.python3 2.paramiko pip install --upgrade pip apt-get install libssl-dev pip3 install pa ...
- python3多线程编程_Python 3多线程编程学习笔记-基础篇
本文是学习<Python核心编程>的学习笔记,介绍了Python中的全局解释器锁和常用的两个线程模块:thread, threading,并对比他们的优缺点和给出简单的列子. 全局解释器锁 ...
最新文章
- Windows进程与线程学习笔记(九)—— 线程优先级/进程挂靠/跨进程读写
- linux增加swap分区大小
- 英语笔记-20151209
- 使用meterpreter让没有安装python解释器的肉鸡设备执行任意python程序
- python多进程存储数据_python – 多进程还是多线程? – 并行化数百万次迭代的简单计算并将结果存储在单个数据结构中...
- 记住,TCP是一种流协议
- java正式测试数据隔离,开发环境要不要和测试环境隔离?
- 没想到裴勇俊留了一头长发。
- 获取Linux服务器信息脚本
- android 修改gps坐标,[原创] 改机 - 从源码着手任意修改GPS地理位置
- virtuoso配合calibre进行电路后仿真
- 51单片机SG90舵机控制原理
- 图片验证码的实现方法
- Python图片按比例缩放后的宽和高(PIL等比缩放)
- R语言如何做NMDS分析
- 【有问不答】空间随机四面体体积计算(MATLAB)
- tf.contrib.silm学习
- 商业银行的起源与经营模式-分业经营与混业经营
- 常用的机器学习算法(使用 Python 和 R 代码)
- (转载)互联网鄙视食物链大全
热门文章
- PHP与Java使用des加密通讯
- UICollectionView的无限滚动---妥协做法
- 正则表达式中模式修正符作用详解(i、g、m、s、x、e)
- [问题处理]redmine的gantt图导出出现‘星星星星星星星星’怎么解决
- 【转】HTML全解(1)
- redis、memcache、mongoDB有哪些区别?
- PaddleOCR加载chinese_ocr_db_crnn_modile模型进行中英文混合预测(Http服务)实践
- Fedora开启telnet服务
- CCPC 2018桂林站游记
- vue-video-player集成videojs-contrib-hls实现.m3u8文件播放