有一个百度网盘下载的 zip文件(加密了),想不花钱就知道密码。
编写 zip_mima.py 如下
# -*- coding: utf-8 -*-
import os
import sys
import zipfile
from datetime import datetime
def try_password(filename, password):
""" 尝试Zip文件密码 """
try:
with zipfile.ZipFile(filename) as zf:
zf.setpassword(password.encode('utf-8'))
zf.extractall()
print(f"Password found: {password}")
return True
except Exception as e:
#print(f"Incorrect password: {password}")
return False
filename = "程序员数学_.zip"
if not os.path.exists(filename):
print(f"Error: {filename} not found.")
sys.exit(1)
print(filename)
time0 = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f"time0: {time0}")
# 尝试常见密码
with open('password.lst','r') as fp:
for passwd in fp:
if try_password(filename, passwd.rstrip()):
break
time1 = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f"time1: {time1}")
# 密码可以是一个单词列表,或者使用更复杂的字典攻击
passwords = []
fp = open('dictionary.txt','r')
for line in fp:
passwords.append(line.rstrip())
fp.close()
n = 0
# 尝试字典密码
for passwd in passwords:
n +=1
if n %10000 ==0:
time1 = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f"{n}: {time1}")
if try_password(filename, passwd):
break
print(n)
time2 = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(f"time2: {time2}")
运行 python zip_mima.py 字典文件用了 \hashcat-6.2.6\example.dict
D:\test> python zip_mima.py
程序员数学_.zip
time0: 2024-10-07 09:38:29
time1: 2024-10-07 09:38:53
10000: 2024-10-07 09:39:53
20000: 2024-10-07 09:40:48
30000: 2024-10-07 09:41:58
40000: 2024-10-07 09:42:48
50000: 2024-10-07 09:43:44
60000: 2024-10-07 09:44:36
70000: 2024-10-07 09:45:31
80000: 2024-10-07 09:46:27
90000: 2024-10-07 09:47:11
100000: 2024-10-07 09:48:05
110000: 2024-10-07 09:49:02
120000: 2024-10-07 09:50:05
128416
time2: 2024-10-07 09:50:46
如果安装了【压缩包密码解除软件】,那么在C:\Users\用户名\AppData\Local\压缩包密码解除软件\dictionary\ 可以找到 dictionary.txt 大约120万多行。
在C:\Users\用户名\AppData\Local\压缩包密码解除软件\crack\ 有常见密码 password.lst
如果有网友尝试出该zip文件密码,请在评论区回复。
源代码文件下载:程序员数学:用Python学透线性代数和微积分
本站下载:hashcat + john-1.9.0-jumbo-1-win64
在 \john-1.9.0-jumbo-1-win64\run\ 有常见密码 password.lst
cd \john-1.9.0-jumbo-1-win64\run
zip2john.exe \test\程序员数学_.zip > /test/hash1.txt
zip2john.exe \test\程序员数学_.zip > \test\hash1.txt
ver 2.0 程序员数学_.zip/程序员数学:用Python学透线性代数和微积分_.pdf PKZIP Encr: cmplen=0, decmplen=55486480, crc=DB317376
cd \hashcat\hashcat-6.2.6
wc -l example.dict
128416 example.dict
hashcat.exe -a 3 -m 17225 $pkzip2$1*1*2*0*0*34ea810*db317376*0*5c*8*0*db31*a058**$/pkzip2$
hashcat (v6.2.6) starting
clCreateCommandQueue(): CL_OUT_OF_HOST_MEMORY
ADL2_Overdrive_Caps(): -8
ADL2_Overdrive_Caps(): -8
ADL2_Overdrive_Caps(): -8
ADL2_Overdrive_Caps(): -8
ADL_Overdrive5_FanSpeed_Get(): -100
ADL_Overdrive5_Temperature_Get(): -100
OpenCL API (OpenCL 2.1 AMD-APP (2639.5)) - Platform #1 [Advanced Micro Devices, Inc.]
=====================================================================================
* Device #1: AMD Radeon(TM) Vega 8 Mobile Graphics, 1696/3483 MB (1045 MB allocatable), 8MCU
* Device #2: AMD Radeon(TM) Vega 8 Mobile Graphics, skipped
* Device #3: , skipped
Minimum password length supported by kernel: 0
Maximum password length supported by kernel: 256
Hashes: 1 digests; 1 unique digests, 1 unique salts
Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
Optimizers applied:
* Not-Iterated
* Single-Hash
* Single-Salt
* Brute-Force
Watchdog: Temperature abort trigger set to 90c
Initializing backend runtime for device #1. Please be patient...
如果有网友 运行完上一命令,请在评论区回复运行结果。
对于破解过的hash值,用 hashcat.exe hash --show 查看结果
所有的hash破解结果都在 hashcat.potfile 文件中