Search

Search IconIcon to open search

python unrar库

Last updated Jun 16, 2023

https://rarfile.readthedocs.io/api.html#rarfile-class

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
from unrar import rarfile

rf = rarfile.RarFile('sgz14.rar')
for f in rf.infolist():
    print(f.filename, f.file_size)
pwd_list = []
with open('PwdDic.txt', encoding='utf-8') as pwd_file:
    print('load pwd list..')
    for ln in pwd_file:
        pwd_list.append(ln.strip())
    print('finished.')
ctr = 1
for pwd in pwd_list:
    print(str(ctr) + ' try decrpyting..' + pwd)
    try:
        rf.extractall(pwd=pwd)
        print('Found: ' + pwd)
        break
    except:
        ctr += 1
        pass
rf.close()