日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python多线程扫描_python实现多线程扫描网站目录

發(fā)布時間:2025/5/22 python 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python多线程扫描_python实现多线程扫描网站目录 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

python實現(xiàn)網(wǎng)站目錄掃描

st=>start: 程序開始

op=>operation: 打印banner信息

op2=>operation: 打印使用方法

op3=>operation: 接收傳遞過來的參數(shù)

cond=>condition: 判斷參數(shù)是否接收完整(是或否?)

op6=>operation: 將傳遞過來的參數(shù)傳遞給指定變量

sub1=>subroutine: 沒有接收完整

sub2=>subroutine: 打印錯誤信息

sub3=>subroutine: 直接退出程序

jieshu=>end: 直接退出程序

op4=>operation: 確定線程數(shù),將字典按照線程數(shù)進(jìn)行分組

op5=>operation: 執(zhí)行掃描模塊

io=>inputoutput: 輸出掃描結(jié)果

e=>end: 程序執(zhí)行完退出

st->op->op2->op3->cond

cond(yes)->op6->op4->op5->io->e

cond(no)->sub1(right)->sub2(right)-->sub3(right)

根據(jù)流程圖確定使用getopt,sys模塊來接受參數(shù),并進(jìn)行處理, threading模塊來處理多線程, requests模塊來執(zhí)行掃描功能, 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)

判斷接收參數(shù)是否完整如果完整了傳遞給特定的變量

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()

多線程的實現(xiàn)

第一步讀字典文件

第二步 確定讀取的行數(shù) len(dic_list) / threads 向上去取整

第三步 確定每個線程讀取的列表[[t1],[t2],[t3],...]

def multi_scan(url,threads,dic):

# 第一步讀字典文件

# 第二步 確定讀取的行數(shù) 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):

# 實現(xiàn)掃描功能 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))

調(diào)用程序

if __name__ == "__main__":

banner()

suage()

start()

程序結(jié)果:

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$

《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的python多线程扫描_python实现多线程扫描网站目录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。