2014-11-03 92 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) 

,这可能会帮助你。你可以使用线程的概念,使其更快