【发布时间】:2020-02-06 19:05:18
【问题描述】:
我正在尝试将多处理添加到现有的密码破解程序中,其来源位于此处:https://github.com/axcheron/pyvboxdie-cracker
脚本运行良好,但速度确实很慢,添加多处理肯定会加快速度。我已经在网上(和这里)查看了一些示例,但我已经遇到了信息过载的问题,我无法理解它。我在这里找到了用户 Camon 的一篇非常有用的帖子(在此处发布:Python Multiprocessing password cracker),但我看不出如何在脚本中实现它。
def crack_keystore(keystore, dict):
wordlist = open(dict, 'r')
hash = get_hash_algorithm(keystore)
count = 0
print("\n[*] Starting bruteforce...")
for line in wordlist.readlines():
kdf1 = PBKDF2HMAC(algorithm=hash, length=keystore['Key_Length'], salt=keystore['Salt1_PBKDF2'],
iterations=keystore['Iteration1_PBKDF2'], backend=backend)
aes_key = kdf1.derive(line.rstrip().encode())
cipher = Cipher(algorithms.AES(aes_key), modes.XTS(tweak), backend=backend)
decryptor = cipher.decryptor()
aes_decrypt = decryptor.update(keystore['Enc_Password'])
kdf2 = PBKDF2HMAC(algorithm=hash, length=keystore['KL2_PBKDF2'], salt=keystore['Salt2_PBKDF2'],
iterations=keystore['Iteration2_PBKDF2'], backend=backend)
final_hash = kdf2.derive(aes_decrypt)
if random.randint(1, 20) == 12:
print("\t%d password tested..." % count)
count += 1
if binascii.hexlify(final_hash).decode() == binascii.hexlify(keystore['Final_Hash'].rstrip(b'\x00')).decode():
print("\n[*] Password Found = %s" % line.rstrip())
exit(0)
print("\t[-] Password Not Found. You should try another dictionary.")
这是我需要编辑的脚本部分,Carmon 的示例具有将单词列表拆分为块的功能,并且每个进程都有自己的块。我实现它的问题是,wordlist 只填充在函数内部(在其他任务完成后,repo 上的完整源代码)。我将如何对本节实施多处理?感谢您的帮助。
【问题讨论】:
-
请发布minimal reproducible example 而不是整个回购。此外,这是一个非常开放的问题。你到底在问什么?了解 Python 中的多处理的资源?简单介绍?
标签: python multithreading multiprocessing cracking