老板发我一个加密压缩包,告诉我是6位数的数字密码,让我将压缩包解压!
for i in range(1000000):
pwd = str(("%06d"%i))
cmd = f'7z t -p{pwd} ./test.zip'
status = subprocess.call(cmd)
cmd = f'7z x -p{pwd} ./test.zip -y -aos -o"./all/"'
subprocess.call(cmd)
#!/usr/bin/env python
"""
@Author :Rattenking
@Date :2021/06/02 15:42
@CSDN :https://blog.csdn.net/m0_38082783
"""
import time
import subprocess
def get_current_time_stamp():
times = time.time()
time_stamp = int(round(times * 1000))
return time_stamp
def verify_password(pwd):
cmd = f'7z t -p{pwd} ./test.zip'
status = subprocess.call(cmd)
return status
def unzip_file_other_folder(pwd):
print(f'正确的密码是:{pwd}')
cmd = f'7z x -p{pwd} ./test.zip -y -aos -o"./all/"'
subprocess.call(cmd)
def get_all_possible_password():
for i in range(1000000):
pwd = str(("%06d"%i))
status = verify_password(pwd)
if status == 0:
unzip_file_other_folder(pwd)
break
if __name__ == "__main__":
start = get_current_time_stamp()
get_all_possible_password()
end = get_current_time_stamp()
print(f"解压压缩包用时:{end - start}ms")