密码学?爆破就行了

点击此处获得更好的阅读体验


WriteUp来源

https://xz.aliyun.com/t/8581

题目考点

  • 爆破

解题思路

这道签到题主要是想给大家推荐一个密码学常用的库,可以多线程的爆破

我用的默认线程解只需要不到7s(还可以更快的)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python2
from pwn import pwnlib
from pwnlib.util.iters import mbruteforce
import hashlib

flag = 'd0g3{71b2b5616ee2a4639a07d979ebde964c}'
msgbroken = 'd0g3{71b2b5616**2a4639**7d979**de964c}'
table = '0123456789abcdef'
assert len(table) == 16

m1 = 'd0g3{71b2b5616'
m2 = '2a4639'
m3 = '7d979'
m4 = 'de964c}'

def f(res):
ciphier = '0596d989a2938e16bcc5d6f89ce709ad9f64d36316ab80408cb6b89b3d7f064a'
msgbroken = m1 + res[0:2] + m2 + res[2:4] + m3 + res[4:6] + m4
tmp = hashlib.sha256(msgbroken).hexdigest()
if tmp == ciphier:
return True

res = mbruteforce(f,table,6,method='fixed')

print(m1 + res[0:2] + m2 + res[2:4] + m3 + res[4:6] + m4 )

Flag

1
d0g3{71b2b5616ee2a4639a07d979ebde964c}