Skip to content

[+]优化:1.Generator改用queue 2.兼容Py2 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions SvnExploit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
'user-agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Mobile Safari/537.36',
'referer':'http://baidu.com'}
table_dump = ''
if sys.version_info < (3, 0): # 兼容py2和py3
import Queue as queue
else:
import queue

download_queue = queue.Queue()

# 下载wc.db
def download_db(url):
Expand Down Expand Up @@ -68,23 +74,19 @@ def print_values(values):
table.reversesort = True
print(table)

# 生成器 存放values中的记录,供下载源码使用
def Gen_values(values):
# 用queue存放values中的记录,供下载源码使用
def gen_queue(values):
global download_queue
for v in values:
if v[0]:
yield v

download_queue.put(v)

def down_file(url,db_path,Gen_value):
def down_file(url,db_path):
# 获取下载后保存的本地地址
path = os.path.dirname(db_path) # dbs/127.0.0.1

# 取出生成器中的记录
while True:
try:
value = Gen_value.__next__()
except:
break
while not download_queue.empty(): # 如果queue不为空
value = download_queue.get()
#print(value)
#sys.exit()
if value[1]=="dir":
Expand Down Expand Up @@ -119,6 +121,7 @@ def down_file(url,db_path,Gen_value):
file.write(res.content)
#global table_dump
table_dump.add_row([value[0], file_uri, '下载成功'])
download_queue.task_done() # 通知队列已消费完该任务

def banner():
print(""" ____ _____ _ _ _
Expand All @@ -142,16 +145,18 @@ def svnMoreThan1_7(url,isdump):
print_values(values)
else:
global table_dump
global download_queue
table_dump = PrettyTable(['文件名','URL','下载状态'])
Gen_value = Gen_values(values)
print_values(values)
gen_queue(values)
threads = []
for i in range(options.thread_num):
thread = threading.Thread(target=down_file, args=(url, db_path, Gen_value))
thread = threading.Thread(target=down_file, args=(url, db_path,))
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
print(table_dump)

print("[+] 已经Dump完成!")

def SvnVersion(url):
Expand Down