Dictionary 如何在多用途键盘上实施字典攻击?

Dictionary 如何在多用途键盘上实施字典攻击?,dictionary,xor,pad,Dictionary,Xor,Pad,我在Coursera上斯坦福大学的密码学课(实际上落后了几周:/),第一个作业有点麻烦。下面的代码可能是,或者肯定是,过度使用了。。。当我遇到这个方法的问题时,我缩小了尺寸,尝试用两个密码文本中的一个异或结果拖动crib,然后手动检查结果列表 虽然我了解打破多用途垫的原理,也了解婴儿床拖动的工作原理,但我看不到评估婴儿床拖动结果的实用方法。。。我花了大约一到两个小时插入不同的单词,努力寻找结果中的部分英语单词,但没有多大成功。我觉得应该有一种方法可以使用一个简短的词典列表来搜索可能的词汇,并自动

我在Coursera上斯坦福大学的密码学课(实际上落后了几周:/),第一个作业有点麻烦。下面的代码可能是,或者肯定是,过度使用了。。。当我遇到这个方法的问题时,我缩小了尺寸,尝试用两个密码文本中的一个异或结果拖动crib,然后手动检查结果列表

虽然我了解打破多用途垫的原理,也了解婴儿床拖动的工作原理,但我看不到评估婴儿床拖动结果的实用方法。。。我花了大约一到两个小时插入不同的单词,努力寻找结果中的部分英语单词,但没有多大成功。我觉得应该有一种方法可以使用一个简短的词典列表来搜索可能的词汇,并自动检查结果。我怎么做

这是我最好的尝试:

# XOR two hex encoded strings
def XOR(a, b):            
    return " ".join("".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a ,b)]).split())

# Compares each of 10 ciphers with each other...results in 45 XORed results
def compareCiphers():     
    with open("ciphers.txt", "r") as f:
        ciphers = f.readlines()    

    with open("XORedCiphers.txt", "w") as f:
        n = 0
        for c in ciphers: 
            print "Cipher: " + c + "-----------------------------------------\n"
            for x in range(n, len(ciphers)):
                if ciphers[x] != c:        
                    print "\tXORed with cipher: " + ciphers[x]
                    result = XOR(ciphers[x], c)
                    print "\t\tResult:\t" + result + "\n\n"
                    f.write(result + "\n")     
            n += 1

# Drags each word of the dictionary across each XORed cipher text
def cribDrag():
    with open("XORedCiphers.txt", "r") as f:
        XORs = f.readlines()

    with open("/Users/aweeeezy/bin/dictionaries/dictionary.txt", "r") as d:
        for word in d:    
            for x in XORs:
                for index in range(0, len(x)):
                    test = XOR(x[index:], word)
                    if test.isalpha():
                        """ Something should go here to check if 'test' is an English
                        word...but I can't think of a practical way to do this """
                        print "\t" + test          

compareCiphers()
cribDrag()