免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7073 | 回复: 0
打印 上一主题 下一主题

pyc(pyo)文件反编译:depython [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-27 00:25 |只看该作者 |倒序浏览

DePython
DePython是什么?
DePython是用来反编译经过python编译的后缀名为pyc或pyo的字节码文件的.
如果你找不到你写的python源代码,Depython可以帮助你通过pyc/pyo文件来找回这些源代码。 经DePython反编译得出的python源代码,和你原来的代码文件几乎完全一样。
DePython支持那些版本的Python?
Depython支持很多Pythond的版本,甚至是最新的Python2.5。

发送天气邮件 试了下,得到的结果还是非常相似的(除了将汉字用utf8编码)
有空去研究下这个怎么实现的,太强了也~~
Thu Mar 26 09:18:15 2009
decompile /tmp/upload/20090326091815_427.pyc...
#! /usr/bin/env python
# emacs-mode: -*- python-*-
# -*- coding: utf-8 -*-
import os
import sys
import os.path
import datetime
import urllib
import smtplib
import email
import hashlib
urlbase = 'http://www.weather.com.cn/html/weather/'
cities = {'\xe8\x8b\x8f\xe5\xb7\x9e': '101190401',
'\xe5\xbe\x90\xe5\xb7\x9e': '101190801',
'\xe5\x8d\x97\xe4\xba\xac': '101190101'}
def rm_pages(city):
    localfile = (city + '.shtml')
    if os.path.isfile(localfile):
        cmd = ('rm -f ./%s' % localfile)
        os.popen(cmd)
def get_message(city):
    url = ((urlbase + cities[city]) + '.shtml')
    localfile = (city + '.shtml')
    try:
        urllib.urlretrieve(url, localfile)
    except IOError:
        urllib.urlretrieve(url, localfile)
    cmd = ("sed -i -e '1,/c_1_1/d; /c_1_2/,/dd_0/d; /surf/,$d; /\xe7\xb4\xab\xe5\xa4\x96\xe7\xba\xbf/,/\xe8\x88\x92\xe9\x80\x82\xe6\x8c\x87\xe6\x95\xb0/d' %s" % localfile)
    os.popen(cmd)
    cmd = ("sed -i -e 's/]*>//g;/ &nbsp/d' %s" % localfile)
    os.popen(cmd)
    cmd = ("sed -i -e 's/^\\s*//g;/^$/d' %s" % localfile)
    os.popen(cmd)
    cmd = ("sed -i -e 's/\\/ / -/g;s/\xe6\x98\x9f\xe6\x9c\x9f.*//g;s/\xe9\xab\x98\xe6\xb8\xa9\xef\xbc\x9a//g;s/\xe4\xbd\x8e\xe6\xb8\xa9\xef\xbc\x9a//g' %s" % localfile)
    os.popen(cmd)
    message = (city + '\xe6\x9c\xaa\xe6\x9d\xa5\xe4\xb8\x89\xe5\xa4\xa9\xe7\x9a\x84\xe5\xa4\xa9\xe6\xb0\x94:\n')
    tomorrow = ('%s\xe6\x97\xa5:  ' % (int(datetime.date.today().day) + 1))
    f = open(localfile)
    message += (((tomorrow + f.readline().replace('\r\n', ',')) + f.readline().replace('\r\n', ' ,')) + f.readline())
    message += (f.readline().replace('\n', ':  ') + f.readline().replace('\r\n', ','))
    htemp = f.readline().replace('\r\n', ' ,')
    ltemp = f.readline().replace('\r\n', '')
    message += ((ltemp + ' -') + htemp)
    message += f.readline()
    message += (f.readline().replace('\n', ':  ') + f.readline().replace('\r\n', ','))
    htemp = f.readline().replace('\r\n', ' ,')
    ltemp = f.readline().replace('\r\n', '')
    message += ((ltemp + ' -') + htemp)
    message += f.readline()
    f.close()
    print message
    return message
def send_mail(send_from, send_to, subject, text, auth = (), send_server = 'localhost'):
    msg = email.MIMEMultipart.MIMEMultipart()
    msg['From'] = send_from
    msg['To'] = email.Utils.COMMASPACE.join(send_to)
    msg['Date'] = email.Utils.formatdate(localtime=True)
    msg['Subject'] = email.Header.Header(subject, 'utf-8')
    msg.attach(email.MIMEText.MIMEText(text, _subtype='plain', _charset='utf-8'))
    smtp = smtplib.SMTP(send_server)
    smtp.docmd('EHLO server')
    smtp.starttls()
    smtp.login(*auth)
    smtp.sendmail(send_from, send_to, msg.as_string())
    smtp.close()
if (__name__ == '__main__'):
    weather_msg = ''
    for city in cities.keys():
        weather_msg += get_message(city)
    send_mail('gx2008758@gmail.com', ['bestfriends@gmail.com',
     'sisters@sina.com',
     'gx2008758@gmail.com'], '^_^\xe5\xa4\xa9\xe6\xb0\x94\xe9\xa2\x84\xe6\x8a\xa5^_^', weather_msg, ('gx2008758@gmail.com', 'uguessit'), 'smtp.gmail.com')
    print 'Done.'
# local variables:
# tab-width: 4
depythoned 1 files: 1 okay, 0 failed
Thu Mar 26 09:18:16 2009


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/65354/showart_1881086.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP