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ただし、ループは1回のwhile反復ですべての組み合わせを通過するように設定されています。名前が特定の値に設定されている場合、ループは魔法のwhileように壊れることはありません。Passwordテストに基づいてwhileループを中断する決定は、各反復が完了したとき(またはcontinued from)に行われます。

于 2012-11-25T20:20:14.710 に答える