[*] Processing D:/PycharmProjects/gui_project/dist/auto_organize_gui.exe [*] Pyinstaller version: 2.1+ [*] Python version: 37 [*] Length of package: 9491710 bytes [*] Found 984 files in CArchive [*] Beginning extraction...please standby [*] Found 157 files in PYZ archive [*] Successfully extracted pyinstaller archive: D:/PycharmProjects/gui_project/dist/auto_organize_gui.exe
You can now use a Python decompiler on the pyc files within the extracted directory
预处理pyc文件修护校验头
deffind_main(pyc_dir): for pyc_file in os.listdir(pyc_dir): ifnot pyc_file.startswith("pyi-") and pyc_file.endswith("manifest"): main_file = pyc_file.replace(".exe.manifest", "") result = f"{pyc_dir}/{main_file}" if os.path.exists(result): return main_file
pyz_dir = f"{pyc_dir}/PYZ-00.pyz_extracted" for pyc_file in os.listdir(pyz_dir): if pyc_file.endswith(".pyc"): file = f"{pyz_dir}/{pyc_file}" break with open(file, "rb") as f: head = f.read(4) list(map(hex, head))
['0x42', '0xd', '0xd', '0xa']
校准入口类:
import shutil if os.path.exists("pycfile_tmp"): shutil.rmtree("pycfile_tmp") os.mkdir("pycfile_tmp") main_file_result = f"pycfile_tmp/{main_file}.pyc" with open(f"{pyc_dir}/{main_file}", "rb") as read, open(main_file_result, "wb") as write: write.write(head) write.write(b""*12) write.write(read.read())
校准子类:
pyz_dir = f"{pyc_dir}/PYZ-00.pyz_extracted" for pyc_file in os.listdir(pyz_dir): pyc_file_src = f"{pyz_dir}/{pyc_file}" pyc_file_dest = f"pycfile_tmp/{pyc_file}" print(pyc_file_src, pyc_file_dest) with open(pyc_file_src, "rb") as read, open(pyc_file_dest, "wb") as write: write.write(read.read(12)) write.write(b""*4) write.write(read.read())
开始反编译
from uncompyle6.bin import uncompile
ifnot os.path.exists("py_result"): os.mkdir("py_result") for pyc_file in os.listdir("pycfile_tmp"): sys.argv = ['uncompyle6', '-o', f'py_result/{pyc_file[:-1]}', f'pycfile_tmp/{pyc_file}'] uncompile.main_bin()
值得一提的是,Visual Studio Code 可通过用户和工作区设置(User and Workspace Settings)实现高度配置。
用户设置(User settings)在所有 Visual Studio Code 实例中都是全局性的,而工作区设置(Workspace Settings)是特定文件夹或项目工作区的本地设置。工作区设置为 VS Code 提供了极大的灵活性,工作区设置会在整篇文章中提到。工作区设置以.json 文件的形式存储在名为.vscode 的项目工作区本地文件夹中。启动新的 Python 程序
让我们以一个新的 Python 程序来探索 Visual Studio Code 中的 Python 开发。在 VS Code 中,键入 Ctrl + N 打开一个新文件。(你也可以从菜单中选择「文件」-「新建」。)
无论你如何操作,你都应该看到一个类似于以下内容的 VS Code 窗口:打开新文件后,你即可以输入代码。
输入 Python 代码
作为测试,我们可以快速编码埃拉托斯特尼筛法(Sieve of Eratosthenes,它可以找出小于已知数的所有质数)。在刚打开的新选项卡中键入以下代码:等等,这是怎么回事?为什么 Visual Studio Code 没有进行任何关键词高亮显示,也没有进行任何自动格式化或任何真正有用的操作呢?它提供了什么?
测试框架设置完成并显示测试后,你可以单击状态栏(Status Bar)上的 Run Tests 并从命令面板中选择一个 option 来运行所有测试:通过在 VS Code 中打开测试文件,单击状态栏上的 Run Tests,然后选择 Run Unit Test Method 以及其他要运行的特定测试,你还可以运行单个测试。这使得解决单个测试失败并重新运行失败的测试变得很简单,从而能够节省大量时间。测试结果显示在 Python Test Log 下的 Output 窗格中。调试支持
即使 VS Code 是代码编辑器,直接在 VS Code 中调试 Python 也是可以的。VS Code 提供的诸多功能可以媲美好的代码调试器,包括: