我在业余时间学习Python已经有一段时间了,我给自己设置了一个挑战,为一个非常具体的任务构建一个密码破解器,它是为了测试我的ADSL路由器的安全性(不是很有效)-使用Wireshark我可以很清楚地看到它是如何通过http散列密码的,我开发了一些代码执行单词表攻击。(如果你认为我的代码写得不好,我很抱歉-你可能是正确的!)。在
#!/usr/bin/env python
import hashlib, os, time, math
from hashlib import md5
def screen_clear():
if os.name == 'nt':
return os.system('cls')
else:
return os.system('clear')
screen_clear()
print ""
print "Welcome to the Technicolor md5 cracker"
print ""
user = raw_input("Username: ")
print ""
nonce = raw_input("Nonce: ")
print ""
hash = raw_input("Hash: ")
print ""
file = raw_input("Wordlist: ")
print ""
realm = "Technicolor Gateway"
qop = "auth"
uri = "/login.lp"
HA2 = md5("GET" + ":" + uri).hexdigest()
wordlist = open(file, 'r')
time1 = time.time()
for word in wordlist:
pwd = word.replace("\n","")
HA1 = md5(user + ":" + realm + ":" + pwd).hexdigest()
hidepw = md5(HA1 + ":" + nonce +":" + "00000001" + ":" + "xyz" + ":" + qop + ":" + HA2).hexdigest()
if hidepw == hash:
screen_clear()
time2 = time.time()
timetotal = math.ceil(time2 - time1)
print pwd + " = " + hidepw + " (in " + str(timetotal) + " seconds)"
print ""
end = raw_input("hit enter to exit")
exit()
wordlist.close()
screen_clear()
time2 = time.time()
totaltime = math.ceil(time2 - time1)
print "Sorry, out of " + str(tested) + " passwords tested, your password was not found (in " + str(totaltime) + " seconds)"
print ""
end = raw_input("hit enter to exit")
screen_clear()
exit()
这很好的工作,但我想要更多,所以我想我可以添加一些多处理能力,以加快事情-使用各种不同的指令和指南,我没有得到一个成功的结果!(虽然感觉我很亲近)
请有人告诉我“多核python密码破解的白痴指南”,或者帮助我修改我的代码。在
另外,我最初的计划是使用opencl或cuda…但我很快就知道我是多么的无能为力!在
我已经为您做了一个例子,应该相对容易添加到您的代码中。它的工作原理如下:首先,我们需要将
wordlist
压缩成可管理的块,然后将其放入多处理器模块。我用字典列一个表,上面有“开始”和“停止”点。接下来,我将这些参数传递到apply_async
中,它将依次运行pwd_find
函数。这是您想要添加for word in wordlist:
循环的函数,但是有一个起始点和停止点(请参阅下面的代码)。在如果您的代码找到匹配项,请添加
p.terminate
,然后加p.join
来终止处理器。在如果您想了解更多关于多处理器模块的知识,go here了解更多。在
我希望这能帮助你,或者至少能让你对多处理有一个更好的了解!在
相关问题 更多 >
编程相关推荐