题目给出一个pyc后缀的文件,需要使用uncompyle6模块去还原成py文件
uncompyle6 是一个 Python 反编译器,它能够将 Python 字节码(.pyc 文件)转换回源代码(.py 文件)。
pip install uncompyle6
uncompyle6默认只支持3.8及以下版本
如何修改?(我这里是python3.11.3)
Python311\Lib\site-packages\uncompyle6\bin\uncompile.py
修改位置:Python311\Lib\site-packages\xdis\magics.py
生成的py文件内容如下:
# uncompyle6 version 3.7.4
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]
# Embedded file name: b'C:\\Users\\CD\\Desktop\\\xb7\xb4\xb1\xe0\xd2\xeb\\crypto11.py'
# Compiled at: 2019-11-24 10:36:35
import base64
def encode1(ans):
s = ''
for i in ans:
x = ord(i) ^ 18
x = x + 19
s += chr(x)
return s
def encode2(ans):
s = ''
for i in ans:
x = ord(i) + 66
x = x ^ 32
s += chr(x)
return s
def encode3(ans):
return base64.b16encode(ans)
flag = ' '
print 'Please Input your flag:'
flag = raw_input()
final = 'E9F3E8EA9EECE859E5555BA0A05F555A555CEBE955EC59E5EC5AECE858E9ECE555EB5FE6E8E4'
if encode3(encode2(encode1(flag))) == final:
print 'correct'
else:
print 'wrong'
逆运算脚本如下:
import base64
def decode2(ans):
s = ''
for i in ans:
j=ord(i)
x=j ^ 32
x-=66
s += chr(x)
return s
def decode1(ans):
s = ''
for i in ans:
j=ord(i)
x=j-19
x=x^18
s += chr(x)
return s
final = 'E9F3E8EA9EECE859E5555BA0A05F555A555CEBE955EC59E5EC5AECE858E9ECE555EB5FE6E8E4'
s = base64.b16decode(final)
s = decode1(decode2(s))
print s
链接:https://pan.baidu.com/s/13S5xdwEvsb1H0nLTlyzMAA
提取码:25fq