python的EXE逆向
潜心修炼,从基础开始
这是一道python的逆向题
题目内容比较简单,但过程值得记录
解题流程
1.惯例查壳
64位程序,无壳
2.运行程序
让输入用户名密码
3.IDA反汇编
查看字符串,发现大量py开头的字符串,确定是python封装的exe
4.python 解封装
利用pyinstxtractor.py脚本对文件进行解封装
5.还原PYC
利用16进制编辑器,和struct文件,为AnhengRe文件还原
使用插入时粘贴,将struct比AnhengRE多的文件头,粘贴过来
6.反编译pyc
保存文件,并将其添加扩展名,pyc
然后利用python的类uncompyle6 库将pyc反编译为py
7.看代码
# uncompyle6 version 3.7.4
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: AnhengRe.py
# Compiled at: 2017-06-17 19:57:18
# Size of source mod 2**32: 272 bytes
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)
# okay decompiling AnhengRE.pyc
8.获得答案
两种解法
- 第一种:运行程序按规定输入
st3 = '51e'
st2 = '9f1ff1e8b5b91110'
st1 = 'c4e21c11a2412'
print('flag{' + st3[:1] + st1 + st2 + st3[-2:] + '}')