2014-11-03 93 views
0

證明我怎麼會爲了得到它放在一個鎖着的zip文件試密碼Zip文件餅乾蟒蛇3 - 概念

chars = "abcdefghijklmnopqrstuvwxyz" 
password = "hello" 

def brute_force(x, y):  
#Where x stands for chars(list to check in) and y stands for password variable to check against 
    for length in range(1, 100):  
     to_attempt = product(x, repeat=length) 
     for attempt in to_attempt: 
      i = i + 1 
      if ''.join(attempt) == y: 
       print('Password: ' + ''.join(attempt)) 
       return 
+0

是什麼產品功能在做? – Hackaholic 2014-11-03 18:57:06

+0

即時通訊它的itertools.product方法(發生器的大小repreatix集x的所有排列) – 2014-11-03 18:58:23

+1

您的問題不清楚 – Hackaholic 2014-11-03 19:00:08

回答

0

我不會完全重新寫你爲你的功能,但(在頂部import zipfile)來測試每個attempt你會怎麼做:

f = zipfile.ZipFile('path/to/file') 
for attempt in attempts: 
    try: 
     f.extractall(pwd=attempt) 
    except RuntimeError: 
     continue 
    else: 
     return attempt 
0
def brute_force(x, y): 
    #since you already have the password just return it 
    return y 

OK OK,可能wasnt的在我現有的功能擴展回答你正在尋找...

但實際上我知道的唯一方法(假設你不知道一個利用解碼任何加密,這可能是)被蠻力它...

粗很多

系統有vunerabilities,你可以利用獲得訪問而不必「猜測」密碼

如果你問你怎麼不能包括y,而是測試它對一個真實的文件嘗試zipfile module,其中包括大多數方法的密碼選項使用

0

zipfile模塊

import zipfile 
z = zipfile.Zipfile('your_zip_file') 
def searching(z,x): 
try: 
    z.extractall(pwd=x) 
    print "\n[+]Password found: " + x 
    exit 
except: 
    pass 

# loop over you combination call searching 
    searching(z,pwd) 

,這可能會幫助你。你可以使用線程的概念,使其更快