URN Logo
UNIX Resources » Linux » China Linux Forum » Python 编 程 » 6 » 请教问题一个
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
请教问题一个
请教问题一个 - 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)]
 
Subject: 请教问题一个
Author: panhudie    Posted: 2005-09-18 08:38    Length: 492 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]
Subject: Re: 请教问题一个
Author: passworld    Posted: 2005-09-18 12:34    Length: 1,503 byte(s)
[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]
Subject: Re: 请教问题一个
Author: panhudie    Posted: 2005-09-18 17:27    Length: 138 byte(s)
[Original] [Print] [Top]
感谢 passworld

decompyle几乎100%的还原了pyc

(还有个问题,可以直接disassemble内存中的函数吗)
[Original] [Print] [Top]
Subject: Re: 请教问题一个
Author: passworld    Posted: 2005-09-18 20:02    Length: 69 byte(s)
[Original] [Print] [Top]
你不会是想查 /proc/kcore 吧?那你就要自己努力了。

----
[Original] [Print] [Top]
Subject: Re: 请教问题一个
Author: passworld    Posted: 2005-09-18 20:09    Length: 154 byte(s)
[Original] [Print] [Top]
不过好象记得有人写过一个 gdb 的 .gdbinit 文件,可以用 gdb 来 debug python,这样有可能 attach 到一个 python pid 然后用 gdb 看文件内容。

----
[Original] [Print] [Top]
Subject: Re: 请教问题一个
Author: panhudie    Posted: 2005-09-19 01:35    Length: 582 byte(s)
[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]
Subject: Re: 请教问题一个
Author: limodou    Posted: 2005-09-19 11:23    Length: 288 byte(s)
[Original] [Print] [Top]
pickle只是对数据的,看一下它的源程序就知道了。有一个叫marshal的应该可以做这件事,但需要在程序中主动去调,而不是象debug程序一样给个内存区就可以自动干了,或给个进程号就行了。那样是不行的。也许有别的办法。这实际上是逆向工程。你确信要这样吗?python的绝大多数软件都是开源的,根本不需要这样啊。
----
[Original] [Print] [Top]
« Previous thread
根文件系统挂不上,romfs
Python 编 程
6
Next thread »
[精华] 如何用python实现网页登陆和其他一些网页上的常见操作
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 04:11:03, cost 0.073290109634399 ms.