>
>
ctfshow 内部赛 reverse_3 来一个派森
summerN
auther:summerN
BLOG:www.summern.club
题目给的是一个exe文件,通过提示,猜测为python打包形成的exe文件
那么。我们需要将其进行反编译
工具:1.archive_viewer.py
2.uncompyle6
步骤:
1.使用命令
python pyinstxtractor.py checkme.exe
得到一个含有checkme文件的文件夹,
我们将checkme 与strust文件用010edit打开,对比,发现pyc文件缺少前12个字节,补充上另存为checkme.pyc
2.使用命令
uncompyle6 checkme.pyc > checkme.py
我们就获得了源码
# uncompyle6 version 3.5.0
# Python bytecode 3.6 (3379)
# Decompiled from: Python 2.7.16 (v2.7.16:413a49145e, Mar 4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)]
# Embedded file name: checkme.py
# Compiled at: 1995-09-28 00:18:56
# Size of source mod 2**32: 272 bytes
def b58encode(tmp):
tmp = list(map(ord, tmp))
temp = tmp[0]
base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
for i in range(len(tmp) - 1):
temp = temp * 256 + tmp[(i + 1)]
tmp = []
while 1:
tmp.insert(0, temp % 58)
temp = temp // 58 # //表示整数除法
if temp == 0:
break
temp = ''
for i in tmp:
temp += base58[i]
tmp = []
for i in range(len(temp)):
tmp.append(chr(ord(temp[i]) ^ i))
check = [
'A', '5', 'q', 'O', 'g', 'q', 'd', '\x7f', '[', '\x7f', 's', '{', 'G', 'A', 'x', '`', 'D', '@', 'K', 'c', '-', 'c', ' ', 'G', '+', '+', '|', 'x', '}', 'J', 'h', '\\', 'l']
if tmp == check:
return 1
else:
return 0
flag = input(u'flag:')
if b58encode(flag):
print('you win')
else:
print('try again')
# okay decompiling checkme.pyc
3.
通过encode函数写出解密脚本
for i in check:
list1.append(ord(i))
print list1
print len(list1)
list2 = []
for i in range(len(list1)):
list2.append(chr(list1[i] ^ i))
print list2
index1 = []
base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
for i in list2:
index1.append(base58.index(i))#index查找位置
print index1
'''
tmp = 'ctf'
tmp = list(map(ord, tmp))
temp = tmp[0]
print temp
for i in range(len(tmp) - 1):
temp = temp * 256 + tmp[(i + 1)]
print temp
'''
str3 = 0
for i in index1:
print '[+]' + '('+str(str3) +' * 58)' + '+' + str(i)
num1 = (str3 * 58) + i
str3 = num1
print num1
temp = num1
tmp = []
#下面这一步就是取余还原,倒序加入数组 方法同加密脚本,改一下数就可
while 1:
tmp.insert(0, temp % 256)
temp = temp // 256 # //表示整数除法
if temp == 0:
break
print tmp
flag = []
for i in tmp:
flag.append(chr(i))
print ''.join(flag)
'''
while 1:
temp = temp % 256
temp = temp //256
'''
reverse3-python.md3kB
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论