################### 目录 ###################
#PATH_home = '/storage/emulated/0' #以'/storage/emulated/0'为初始目录
PATH_home = '' #以__file__的上一级目录为初始目录
################### 目录 ###################
import os
os.system('pip list > pip_list.txt')
PIP = ['textual','pyzipper']
with open('pip_list.txt','r') as f :
pip_list = f.read().split()
for i in PIP :
if i not in pip_list :
os.system(f'pip install {i} -i https://pypi.tuna.tsinghua.edu.cn/simple')
import pyzipper
from sys import argv
from textual.app import App
from textual.screen import Screen
from textual.widgets import DirectoryTree,Header,Button
pwd_path = None
file_path = None
out_path = os.path.dirname(os.path.realpath(argv[0]))
if PATH_home[-1:] != '/' and len(PATH_home) > 1 :
PATH_home+='/'
if not os.path.exists(PATH_home) :
PATH_home = out_path
def pwd_list() :
if os.path.isfile(pwd_path) :
pwd_L = [pwd_path]
else :
pwd_L = os.listdir(pwd_path)
pwd_L = [str(pwd_path)+'/'+i for i in pwd_L]
for i in pwd_L :
print('\n当前字典 : ',i,end='\n')
with open(i,'r') as f:
for line in f:
yield line.strip()
def zip_pwd(a) :
_s = 0
zip_file = pyzipper.AESZipFile(file_path, 'r')
while True :
try :
passwd = next(a)
zip_file.extractall(path=out_path,pwd=passwd.encode())
zip_file.close()
print('\r',_s, end='\n')
print('密码是 : ',passwd)
return passwd
except RuntimeError :
print('\r',_s, end='')
except StopIteration :
print('\r',_s, end='\n')
print('未能匹配到密码')
return None
except Exception as e :
pass
#print('\n异常值 : "',passwd,'"\n',e,end='\n')
_s+=1
class zipp_1(Screen):
def compose(self) :
yield Header()
yield DirectoryTree(PATH_home)
self.notify('选择一个加密的ZIP文件',title='选择文件',timeout=10)
class zipp_2(Screen):
def compose(self) :
yield Header()
yield DirectoryTree(PATH_home)
yield Button('R U N',variant='success')
self.notify('''
选择一个字典文件,
或者含有多个字典
文件的文件夹,点
击RUN开始任务。
''',
title='选择字典',timeout=30)
class zipp(App):
CSS = '''
Header {height: 3 ;background: $error;text-style:bold}
Button {width: 50}
'''
TITLE = '选择需要破解的ZIP文件'
SCREENS = {
'zip': zipp_1(),
'dic': zipp_2()
}
def on_mount(self) :
self.push_screen('zip')
def on_tree_node_highlighted(self,event) :
global pwd_path,file_path
if not file_path :
return
pwd_path = event.node.data.path
def on_directory_tree_file_selected(self,event) :
global file_path
if file_path :
return
if str(event.path)[-4:].lower() == '.zip' :
file_path = event.path
self.title = '选择一个字典文件'
self.switch_screen('dic')
def on_button_pressed(self) :
self.exit()
if __name__ == '__main__' :
zipp().run()
PWD = pwd_list()
os.system('clear')
zip_pwd(PWD)
标签: