我正在寫有從網上下載了一堆文件,它甚至可以運行以前的程序,所以我創建了一個將下載的所有文件和「功能初始化」稱爲init_program
程序,它的工作原理是通過它一對夫婦dicts
有URL到GitHub上一個gistfiles運行。它拉動網址並使用urllib2
下載它們。我將不能夠添加的所有文件,但你可以通過克隆回購here嘗試一下。下面是從要旨創建文件的功能:加快文件下載的處理速度從網絡
def init_program():
""" Initialize the program and allow all the files to be downloaded
This will take awhile to process, but I'm working on the processing
speed """
downloaded_wordlists = [] # Used to count the amount of items downloaded
downloaded_rainbow_tables = []
print("\n")
banner("Initializing program and downloading files, this may take awhile..")
print("\n")
# INIT_FILE is a file that will contain "false" if the program is not initialized
# And "true" if the program is initialized
with open(INIT_FILE) as data:
if data.read() == "false":
for item in GIST_DICT_LINKS.keys():
sys.stdout.write("\rDownloading {} out of {} wordlists.. ".format(len(downloaded_wordlists) + 1,
len(GIST_DICT_LINKS.keys())))
sys.stdout.flush()
new_wordlist = open("dicts/included_dicts/wordlists/{}.txt".format(item), "a+")
# Download the wordlists and save them into a file
wordlist_data = urllib2.urlopen(GIST_DICT_LINKS[item])
new_wordlist.write(wordlist_data.read())
downloaded_wordlists.append(item + ".txt")
new_wordlist.close()
print("\n")
banner("Done with wordlists, moving to rainbow tables..")
print("\n")
for table in GIST_RAINBOW_LINKS.keys():
sys.stdout.write("\rDownloading {} out of {} rainbow tables".format(len(downloaded_rainbow_tables) + 1,
len(GIST_RAINBOW_LINKS.keys())))
new_rainbowtable = open("dicts/included_dicts/rainbow_tables/{}.rtc".format(table))
# Download the rainbow tables and save them into a file
rainbow_data = urllib2.urlopen(GIST_RAINBOW_LINKS[table])
new_rainbowtable.write(rainbow_data.read())
downloaded_rainbow_tables.append(table + ".rtc")
new_rainbowtable.close()
open(data, "w").write("true").close() # Will never be initialized again
else:
pass
return downloaded_wordlists, downloaded_rainbow_tables
這個工作,是的,但它是非常緩慢的,由於文件的大小,每個文件中有至少100,000行。我如何加快此功能,使其更快,更方便用戶使用?
嗯,這取決於你的無線網絡連接。幾乎沒有辦法可以加快這一點,除了提高你的無線網絡。對不起,說。 – Qwerty
@Qwerty即使有線程?我的意思是這是緩慢的,是的,它將在最後值得它,但它是一個慢初始化過程.. – papasmurf
嗯... http://stackoverflow.com/a/9010299/2308683 –