[GWCTF 2019]pyre
步骤:
1.附件是pyc文件,用python打不开,百度后得知用python反编译工具打开,分享一个python反编译在线网站
反编译后是这段代码
#!/usr/bin/env python
# visit http://tool.lu/pyc/ for more information
print 'Welcome to Re World!'
print 'Your input1 is your flag~'
l = len(input1) #输入字符串的长度
for i in range(l):
num = ((input1[i] + i) % 128 + 128) % 128 #对字符串的每一位进行加密,确保在128的范围内
code += num
for i in range(l - 1):
code[i] = code[i] ^ code[i + 1] #字符串的前一位与后一为进行异或运算后赋值给前一位
print code
code = [
'x1f',
'x12',
'x1d',
'(',
'0',
'4',
'x01',
'x06',
'x14',
'4',
',',
'x1b',
'U',
'?',
'o',
'6',
'*',
':',
'x01',
'D',
';',
'%',
'x13']
程序很简单,将code字符串逆向一下上方的两个算法即可
exp
code = ['x1f','x12','x1d','(','0','4','x01','x06','x14','4',
',','x1b','U','?','o','6','*',':','x01','D',';','%','x13']
for i in range(len(code)-2,-1,-1):
code[i]=chr(ord(code[i])^ord(code[i+1]))
for i in range(len(code)):
print(chr((ord(code[i])-i)%128),end="")