找一个pyc文件(不是源代码文件),然后搜索相关反编译工具把pyc反编译成Python源代码,最好能多找几种工具或者途径达到反编译的目的。
我找的是另一位同学的pyc文件
1、在线反编译
2、Easy Python Decompiler反编译工具
但是他的代码可能用的是最新的python环境,Easy Python Decompiler目前只支持带python3.4。但我反编译其他文件没有问题。
3、使用uncompyle6代码反编译
import os
import sys
def displayFile(file):
unPath = sys.executable
unPath = unPath[0: unPath.rfind(os.sep)]
newname = file[0:file.rfind('.')] + '.py'
command = "python -u " + unPath + "\scripts\uncompyle2 " + file + ">" + newname
try:
os.system(command)
except :
print
file
if __name__ == '__main__':
# print unPath
print("init")
displayFile('D:\\hh.pyc')
print("finished")
反编译出来的源代码为:
import string
base64_charset = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/'
a1 = 'A12345678'
a2 = ''
a3 = ''
n1 = len(a1) % 3
n2 = len(a1) // 3
for i in range(1, n1):
a1 += '\x00'
# WARNING: Decompyle incomplete
import string
base64_charset = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/'
a1 = 'A12345678'
a2 = ''
a3 = ''
n1 = len(a1) % 3
n2 = len(a1) // 3
for i in range(1, n1):
a1 += '\x00'