0
import itertools   

def bruteForce3 (PasswordIn):  
    Password =''  
    while(Password != PasswordIn):

        bruteForceLen1(PasswordIn)
        bruteForceLen2(PasswordIn)
        bruteForceLen3(PasswordIn)
        bruteForceLen4(PasswordIn)
        bruteForceLen5(PasswordIn)
        bruteForceLen6(PasswordIn)
        bruteForceLen7(PasswordIn)
        bruteForceLen8(PasswordIn)
        bruteForceLen9(PasswordIn)
        bruteForceLen10(PasswordIn)

    print('DONE ',Password, " = ",PasswordIn)

def bruteForceLen1(PasswordIn):  
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',1)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen2(PasswordIn):        
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',2)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen3(PasswordIn):  
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',3)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen4(PasswordIn):  
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',4)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen5(PasswordIn):  
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',5)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen6(PasswordIn):
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',6)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen7(PasswordIn):  
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',7)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen8(PasswordIn):  
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',8)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen9(PasswordIn):  
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',9)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)

def bruteForceLen10(PasswordIn):  
    gen = itertools.combinations_with_replacement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',10)
    for Password in gen:
        Password = ''.join(Password)
        print(PasswordIn, Password)
4

1 回答 1

2

Password''在函数中设置为bruteForce3并且永远不会在该范围内再次设置。函数中的Password变量是这些xLenN函数的局部变量,对Password != PasswordIn决定while循环是否继续的测试 ( ) 没有影响。但是,while循环设置为在一次迭代中遍历所有组合。当名称设置为某个值while时,循环不会神奇地中断。Password当每次迭代完成时(或continue从 d 开始),根据测试中断 while 循环的决定就完成了。

于 2012-11-25T20:20:14.710 回答