macleo's blog

孤独 和 赛跑

导航

bugku easy_hash

https://ctf.bugku.com/challenges/detail/id/2300.html

 

这个挺有意思的

通过比对 加密结果来实现md5 的解密 

以下是 dictionary.txt

a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Z
1
2
3
4
5
6
7
8
9
0
{
}
&
*
%
$
#
@
!
_
+
-
(
)
^
,
.
/
?
\
[
]

 

下面是拼凑的解密脚本:

import hashlib
def md5_encrypt(text):
    md5 = hashlib.md5()
    md5.update(text.encode('utf-8'))
    return md5.hexdigest()

def md5_decrypt(md5_hash, wordlist):
    with open(wordlist, 'r') as file:
        for line in file:
            word = line.strip()
            encrypted_word = md5_encrypt(word)
            if encrypted_word == md5_hash:
                return word
    return None

wordlist = 'dictionary.txt'
# md5_hash = 'e1671797c52e15f763380b45e841ec32'
target_string = ""
try:
    with open('output', 'r', encoding='gb2312', errors='ignore') as file:
        for line in file:
            md5_hash = line.strip()
            decrypted_text = md5_decrypt(md5_hash, wordlist)
            target_string +=decrypted_text
except Exception as e:
    print(e)
print(target_string)

# 输出:Hello World!

 

最终能实现的反向 md5 的结果

这个题有点意思,别说 md5 无法解密,这个有趣

posted on 2024-06-04 23:21  macleo  阅读(93)  评论(0)    收藏  举报