|
|
|
|
 请教问题一个 - panhudie [ 2005-09-18 08:38 | 492 byte(s)]
 Re: 请教问题一个 - passworld [ 2005-09-18 12:34 | 1,503 byte(s)]
 Re: 请教问题一个 - panhudie [ 2005-09-18 17:27 | 138 byte(s)]
 Re: 请教问题一个 - passworld [ 2005-09-18 20:02 | 69 byte(s)]
 Re: 请教问题一个 - passworld [ 2005-09-18 20:09 | 154 byte(s)]
 Re: 请教问题一个 - panhudie [ 2005-09-19 01:35 | 582 byte(s)]
 Re: 请教问题一个 - limodou [ 2005-09-19 11:23 | 288 byte(s)]
|
|
|
|
[Original]
[Print]
[Top]
|
可以直接把python的bytecode变成原来的code吗?
import dis
def myfunc(alist):
return len(alist)
>>> dis.dis(myfunc)
2 0 LOAD_GLOBAL 0 (len)
3 LOAD_FAST 0 (alist)
6 CALL_FUNCTION 1
9 RETURN_VALUE
请问有可以把上面的Python assembly code变成真的python code的module吗?
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
decompyle
Debian 下的描述:
================
Package: decompyle
Priority: optional
Section: python
Installed-Size: 412
Maintainer: Ben Burton <bab@debian.org>
Architecture: i386
Version: 2.3.2-2
Depends: libc6 (>= 2.3.2.ds1-4), python2.3
Suggests: decompyle2.2
Filename: pool/main/d/decompyle/decompyle_2.3.2-2_i386.deb
Size: 73524
MD5sum: f88e8eee3f58b10aea93101cec3a5ff3
Description: a Python byte-code decompiler
Decompyle converts Python byte-code back into equivalent Python source.
It accepts byte-code from any Python version between 1.5 and 2.3 inclusive.
.
The generated source is very readable: docstrings, lists, tuples and
hashes get pretty-printed.
.
Decompyle can also verify the equivalence of the generated source by
compiling it and comparing the new byte-code with the original byte-code.
.
Note that an older version of decompyle is available in the decompyle2.2
package. The older version cannot handle Python 2.3 byte-code, but it
might provide a greater success rate with byte-code from Python 2.2 and
below. Both the newer decompyle and the older decompyle2.2 may be
installed together without problems.
Tag: devel::debugger, langdevel::python
|
|
|
----
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
不过好象记得有人写过一个 gdb 的 .gdbinit 文件,可以用 gdb 来 debug python,这样有可能 attach 到一个 python pid 然后用 gdb 看文件内容。
|
|
|
----
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
(我菜鸟一个,gdb还没用过,debian只是在colinux里面的...)
只是想了解一下python语言到底有好强
decompyle好像只能disassemble编译的python文件, 不能disassemble内存中的,
pickle 好像不能pickle function的内容, dis模块也只能把内存中的func变成python assembly code
动态语言这点就是强, 把编译的文件还能100%还原,
只是非常好奇想知道一下有没有把内存里的function,class,module(就是没有本地文件连接的,比如说在python shell直接定义的)还原成原代码的办法
或者直接把这些(function,class,module)完全pickle到文件里或者数据库里面.
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
|
pickle只是对数据的,看一下它的源程序就知道了。有一个叫marshal的应该可以做这件事,但需要在程序中主动去调,而不是象debug程序一样给个内存区就可以自动干了,或给个进程号就行了。那样是不行的。也许有别的办法。这实际上是逆向工程。你确信要这样吗?python的绝大多数软件都是开源的,根本不需要这样啊。
|
|
|
----
|
|
[Original]
[Print]
[Top]
|
|
|