探索和反编译python字节码 [英] Exploring and decompiling python bytecode

查看:128
本文介绍了探索和反编译python字节码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我说:

>>> def test(a):    
>>>    print a

现在,我想探索一下测试在编译后的样子。

Now, I want to explore see how test looks like in its compiled form.

>>> test.func_code.co_code
'|\x00\x00GHd\x00\x00S'

我可以使用 dis 模块获取反汇编的表单:

I can get the disassembled form using the dis module:

>>> import dis
>>> dis.dis(test)
  2           0 LOAD_FAST                0 (a)
              3 PRINT_ITEM
              4 PRINT_NEWLINE
              5 LOAD_CONST               0 (None)
              8 RETURN_VALUE

是否有开源和维护的反编译器,我可以用来将字节码转换回可读的python代码?

Is there an opensource and maintained decompiler I could use to turn the bytecode back into readable python code?

更新:感谢您建议反编译,但是它已经过时了(python2.3),并且没有人对其进行维护。 python2.5或更高版本有什么用吗?

推荐答案

UnPyc

http://sourceforge.net/projects/unpyc/

这是旧decompyle的维护分支,已更新为可用于2.5和2.6。

It is a maintained fork of the old decompyle updated to work with 2.5 and 2.6.

这篇关于探索和反编译python字节码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆