2019安恒杯1月月赛

python_crackme

(拿安恒杯1月月赛的题目she来讲)首先,你会拿到一个由python编译的exe文件,使用pyinstxtractor.py脚本(下载地址)反编译exe文件

image.png

得到一个文件夹里面有一大堆东西

image.png

用010editor打开与exe文件同名的二进制文件

image.png

添加上python3.6的.pyc文件的文件头(即前12字节)然后再加上后缀名.pyc

image.png

再在线反编译一下(反编译地址)即可得到python源码:

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# encoding: utf-8
# 如果觉得不错,可以推荐给你的朋友!http://tool.lu/pyc
import os
n1 = input('Tell me your name?')
n2 = input('Tell me your pasw')
n11 = chr(ord(n1[0]) + 12)
s = ''
st3 = '51e'
st2 = '9f1ff1e8b5b91110'
st1 = 'c4e21c11a2412'
st0 = 'wrong'
if n11 + 'AnHeng' == n2:
for i in range(0, 4):
s += st1[3 - i]

print('Congratulations')
ts = st2[0] + st3 + st2[1] + s
print('flag{' + st3[:1] + st1 + st2 + st3[-2:] + '}')
os.system('pause')
else:
print('no,' + st0)
import os
n1 = input('Tell me your name?')
n2 = input('Tell me your pasw')
n11 = chr(ord(n1[0]) + 12)
s = ''
st3 = '51e'
st2 = '9f1ff1e8b5b91110'
st1 = 'c4e21c11a2412'
st0 = 'wrong'
if n11 + 'AnHeng' == n2:
for i in range(0, 4):
s += st1[3 - i]

print('Congratulations')
ts = st2[0] + st3 + st2[1] + s
print('flag{' + st3[:1] + st1 + st2 + st3[-2:] + '}')
os.system('pause')
else:
print('no,' + st0)

old-diver

32位pe文件,无壳

image.png

IDA分析:将v9的类型修改为char[]型,同时可以看到这里到401000处理的代码进行了加密异或,先解密一波:

1
2
3
4
5
6
s = get_bytes(0x401000,0x260)
buf = ''
for i in s:
buf += chr(ord(i)^0xbb)
from idaapi import *
patch_bytes(0x401000,buf)

重新构造解密部分函数,先undefine the current function(快捷键u)再 creat a function(快捷键p),重新F5,可以看到两个函数已经恢复正常

image.png

可以开始分析程序了
第一步验证前5位:”flag{“然后进入sub_4010b0函数
第二步异或image.png

第三步:base64加密,”c19zbWNf”解码
第四步:走迷宫

1
2
3
4
5
6
7
8
9
--------  上下左右
g + + 2 a q w
+ + ++ +
+ + #+ +
+ ++++ +
+ ++++ +
+ +
--------
waaaaawwwww22222qqqaaw

最终得到flag:flag{this_is_smc_waaaaawwwww22222qqqaaw}

0%