反编译Python 2.7 .pyc

发布于 2024-12-16 20:58:13 字数 1536 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

若能看破又如何 2024-12-23 20:58:13

如果有人仍在为此苦苦挣扎,就像我今天整个早上一样,我找到了一个适合我的解决方案:

Uncompyle

安装说明:

git clone https://github.com/gstarnberger/uncompyle.git
cd uncompyle/
sudo ./setup.py install

安装程序后(注意:它将安装到您的系统范围内可访问的 Python 包中,因此它应该位于您的 $PATH 中),您可以恢复您的 文件如下:

uncompyler.py thank_goodness_this_still_exists.pyc > recovered_file.py

Python 反编译器主要以注释的形式添加一些噪音,但是我发现它出奇地干净并且忠实于我的原始代码。您必须删除恢复文件末尾附近以 +++ 开头的一小行文本才能运行您的代码。

In case anyone is still struggling with this, as I was all morning today, I have found a solution that works for me:

Uncompyle

Installation instructions:

git clone https://github.com/gstarnberger/uncompyle.git
cd uncompyle/
sudo ./setup.py install

Once the program is installed (note: it will be installed to your system-wide-accessible Python packages, so it should be in your $PATH), you can recover your Python files like so:

uncompyler.py thank_goodness_this_still_exists.pyc > recovered_file.py

The decompiler adds some noise mostly in the form of comments, however I've found it to be surprisingly clean and faithful to my original code. You will have to remove a little line of text beginning with +++ near the end of the recovered file to be able to run your code.

寂寞陪衬 2024-12-23 20:58:13

Decompyle++ (pycdc) 似乎适用于一系列 python 版本:https://github.com/zrax/pycdc

例如:

git clone https://github.com/zrax/pycdc   
cd pycdc
make  
./bin/pycdc Example.pyc > Example.py

Decompyle++ (pycdc) appears to work for a range of python versions: https://github.com/zrax/pycdc

For example:

git clone https://github.com/zrax/pycdc   
cd pycdc
make  
./bin/pycdc Example.pyc > Example.py
别靠近我心 2024-12-23 20:58:13

更新(2019-04-22) - 听起来你现在想使用 uncompyle6 而不是我最初提到的答案。

这听起来好像有效:http://code.google.com/p/unpyc/

第 8 期表示支持 2.7:http://code.google.com/p/unpyc/更新/列表

更新(2013-09-03) - 正如评论和其他答案中所述,您应该查看 https://github .com/wibiti/uncompyle2https://github.com/gstarnberger/uncompyle 而不是 unpyc。

UPDATE (2019-04-22) - It sounds like you want to use uncompyle6 nowadays rather than the answers I had mentioned originally.

This sounds like it works: http://code.google.com/p/unpyc/

Issue 8 says it supports 2.7: http://code.google.com/p/unpyc/updates/list

UPDATE (2013-09-03) - As noted in the comments and in other answers, you should look at https://github.com/wibiti/uncompyle2 or https://github.com/gstarnberger/uncompyle instead of unpyc.

想你只要分分秒秒 2024-12-23 20:58:13

这是一个反编译pyc文件的好工具。

它是由我编写的,支持 python 1.0 - 3.3

它基于 uncompyle2 和 decompyle++

http://sourceforge.net/projects/easypythondecompiler/

Here is a great tool to decompile pyc files.

It was coded by me and supports python 1.0 - 3.3

Its based on uncompyle2 and decompyle++

http://sourceforge.net/projects/easypythondecompiler/

梦年海沫深 2024-12-23 20:58:13

Ned Batchelder 发布了一个简短脚本,它将解组 .pyc 文件并反汇编任何代码对象在其中,这样您就可以看到 Python 字节码。
看起来使用较新版本的 Python,您需要注释掉设置 modtime 的行并打印它(但不要注释设置 moddate 的行) 。

尽管理论上是可能的,但将其转回 Python 源代码会稍微困难一些。我假设所有适用于旧版本 Python 的程序都会这样做。

Ned Batchelder has posted a short script that will unmarshal a .pyc file and disassemble any code objects within, so you'll be able to see the Python bytecode.
It looks like with newer versions of Python, you'll need to comment out the lines that set modtime and print it (but don't comment the line that sets moddate).

Turning that back into Python source would be somewhat more difficult, although theoretically possible. I assume all these programs that work for older versions of Python do that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文