ctfshow 内部赛 reverse_3 来一个派森

admin 2022年1月5日23:12:56评论60 views字数 1893阅读6分18秒阅读模式

>

>

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


  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月5日23:12:56
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   ctfshow 内部赛 reverse_3 来一个派森https://cn-sec.com/archives/720101.html

发表评论

匿名网友 填写信息