pyc是一种二进制文件,是由py文件经过编译后,生成的文件,是一种byte code,py文件变成pyc文件后,运行加载的速度会有所提高;另一反面,把py文件编译为pyc文件,从而可以实现部分的源码隐藏,保证了python做商业化软件时的安全性
用uncompyle6这个第三方python反编译器来进行反编译
uncompyle6是一个原生python的跨版本反编译器和fragment反编译器,是decompyle、uncompyle、uncompyle2等的接替者。
uncompyle6可将python字节码转换回等效的python源代码,它接受python 1.3版到3.8版的字节码,这其中跨越了24年的python版本,此外还包括Dropbox的Python 2.5字节码和一些PyPy字节码。
github项目:https://github.com/rocky/python-uncompyle6
pip install uncompyle6
uncompyle6 -o . mima.pyc
# uncompyle6 version 3.6.5
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: ans.py
# Compiled at: 2018-08-09 11:29:44
import base64
def encode1(ans):
s = ''
for i in ans:
x = ord(i) ^ 36
x = x + 25
s += chr(x)
return s
def decode1(ans):
s = ''
for i in ans:
x = ord(i) - 25
x = x ^ 36
s+=chr(x)
return s
def encode2(ans):
s = ''
for i in ans:
x = ord(i) + 36
x = x ^ 36
s += chr(x)
return s
def decode2(ans):
s = ''
for i in ans:
x=i^36
x=x-36
s+=chr(x)
return s
def encode3(ans):
return base64.b32encode(ans)
def decode3(ans):
return base64.b32decode(ans)
final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
print(decode1(decode2(decode3(final))))
'''
flag = ' '
print 'Please Input your flag:'
flag = raw_input()
final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
if encode3(encode2(encode1(flag))) == final:
print 'correct'
else:
print 'wrong'
import base64
def encode1(ans):
s = ''
for i in ans:
x = ord(i) ^ 36
x = x + 25
s += chr(x)
return s
def encode2(ans):
s = ''
for i in ans:
x = ord(i) + 36
x = x ^ 36
s += chr(x)
return s
def encode3(ans):
return base64.b32encode(ans)
flag = ' '
print 'Please Input your flag:'
flag = raw_input()
final = 'UC7KOWVXWVNKNIC2XCXKHKK2W5NLBKNOUOSK3LNNVWW3E==='
if encode3(encode2(encode1(flag))) == final:
print 'correct'
else:
print 'wrong'
'''
cyberpeace{interestinghhhhh}