我正在尝试找到一种方法来从单词词典中破解类似 XKCD 的密码短语(正确的密码)。基本上连接字典文件中的 X 个单词。现在,老实说,似乎没有一个简单的方法。
在 XKCD 漫画之后有很多这样的工具,我总是可以自己启动并创建一个字典文件,但我觉得应该有更好的方法。我的具体用途是 MD5 哈希上的 John the Ripper。
看起来没有办法在 JtR 中连接整个单词,只能修改现有单词。在底部参考这里
在 JtR 的未来版本中可能会添加多词“密码”破解模式,或对 wordlist 模式的增强。
那是 2008 年,但我仍然没有看到任何关于这种变化的参考。我可以使用该文档中描述的技术,但如果你需要做超过 2 个单词的短语或者你的字典很长,它会变得非常难看。
我的第二个想法是使用 Crunch 来管道输入单词,例如......crunch 0 0 -p word1 word2 | john --pipe mypasswd*我可以稍微修改一下并使用 -q wordlist.txt 和 crunch 将使用该文本文件中的单词。这里的问题是没有办法(我发现)限制用于密码短语的单词数量。例如,如果您的字典包含 1,000 个单词,则每个密码短语将是所有 1,000 个单词的串联。同样,如果您的字典长度很大,它会变得非常难看。
编辑:请注意此处建议更改上述紧缩命令以指定最小长度和最大长度的人。这不适用于 -p 或 -q 选项,但是,仍然必须指定数字(因此 0 占位符)。-p 标志下的引用
它忽略了最小和最大长度,但是您仍然必须指定两个数字。
由于文件的大小,我的要求是写入标准输出,而不是文件,并允许您指定要加入的单词数(2 个单词短语、3 个单词等)。如果允许使用其他字符甚至空格,最好这样的工具还允许您指定分隔字符 (correct.horse.battery.staple correct|horse|battery|staple)。
希望这是正确的堆栈交换,如果我应该尝试另一个,请告诉我。
编辑
对于在那里寻找同样东西的其他人,这里有一个 python 代码片段,它或多或少地做了我想要的。
# iterable=['test','correct','horse','battery','staple']
## Change the file specified here to your dictionary file
iterable = [i.strip().split() for i in open("wordList.txt").readlines()]
def permutations(iterable, r=None, s=''):
pool = tuple(iterable)
n = len(pool)
r = n if r is None else r
if r > n:
#return
r = n # Lets assume users want all permutations
indices = range(n)
cycles = range(n, n-r, -1)
temp = tuple(pool[i] for i in indices[:r])
for item in temp: # iterate through the current tuple and turn it into a string, to get rid of brackets and such
print s.join([str(i[0]) for i in temp])
while n:
for i in reversed(range(r)):
cycles[i] -= 1
if cycles[i] == 0:
indices[i:] = indices[i+1:] + indices[i:i+1]
cycles[i] = n - i
else:
j = cycles[i]
indices[i], indices[-j] = indices[-j], indices[i]
temp = tuple(pool[i] for i in indices[:r])
for item in temp:
print s.join([str(i[0]) for i in temp])
break
else:
return
# The first value relates to our variable (dictionary file) at the top
# The second value is the number of words we want to combine, a 2 would indicate 2
## word combinations, such as correct.horse, 3 would be correct.horse.staple
# The third value is the seperater, such as . in the example above, to create words
## that run together enter nothing, or ''
permutations(iterable, 2, '.')
要将其与 JtR 一起使用,您将使用 python xkcd.py | john --pipe mypasswd*
代码取自python 的 itertools所以它应该返回......
r 长度元组,所有可能的排序,没有重复的元素
我想要所有这些,而且它不会将数组存储在内存中(如果列表很长,它会很快耗尽)并且不会写入磁盘(尽管您可以根据需要重定向输出)。
现在,我遇到了长时间运行和 JtR 的错误(IOError: [Errno 32] Broken pipe)。代码很草率,等等。所以不,这不是一个完美的现实世界解决方案。然而,正如已经指出的那样,由于可能性的数量,即使没有错误,这在现实世界中也可能不切实际。有时我只是想知道是否有可能!
如果有人在看这个知道 C 并且想直接将这样的东西添加到 JtR 或 Crunch 中,那将是惊人的,我有一种感觉,如果它被写入为此设计的程序,将会加快速度并使其更加可靠种任务。