如何反编译pyc

uncompyle2 是一个可以将pyc文件转换为py源码的工具

下载地址:https://github.com/wibiti/uncompyle2

安装: setup.py install

参数:

Usage: uncompyle2 [OPTIONS]... [ FILE | DIR]...

Examples:
uncompyle2 foo.pyc bar.pyc # decompile foo.pyc, bar.pyc to stdout
uncompyle2 -o . foo.pyc bar.pyc # decompile to ./foo.dis and ./bar.dis
uncompyle2 -o /tmp /usr/lib/python1.5 # decompile whole library

Options:
-o <path> output decompiled files to this path:
if multiple input files are decompiled, the common prefix
is stripped from these names and the remainder appended to
<path>
uncompyle -o /tmp bla/fasel.pyc bla/foo.pyc
-> /tmp/fasel.dis, /tmp/foo.dis
uncompyle -o /tmp bla/fasel.pyc bar/foo.pyc
-> /tmp/bla/fasel.dis, /tmp/bar/foo.dis
-s if multiple input files are decompiled, the common prefix
is stripped from these names and the remainder appended to
<path>
uncompyle -o /tmp /usr/lib/python1.5
-> /tmp/smtplib.dis ... /tmp/lib-tk/FixTk.dis
-c <file> attempts a disassembly after compiling <file>
-d do not print timestamps
-m use multiprocessing
--py use '.py' extension for generated files
--norecur don't recurse directories looking for .pyc and .pyo files
--verify compare generated source with input byte-code
(requires -o)
--help show this message

Debugging Options:
--showasm -a include byte-code (disables --verify)
--showast -t include AST (abstract syntax tree) (disables --verify)

Extensions of generated files:
'.pyc_dis' '.pyo_dis' successfully decompiled (and verified if --verify)
'.py' with --py option
+ '_unverified' successfully decompile but --verify failed
+ '_failed' uncompyle failed (contact author for enhancement)

参数其实就是C:\Python27\Scripts\uncompyle2   文件里面, uncompyle2也是一个py文件但没有py扩展

代码如下:

 #! /usr/bin/env python
import os
import sys def displayFile(file):
unPath= sys.executable
unPath=unPath[ 0 : unPath.rfind( os.sep ) ]
newname = file[0:file.rfind('.')] + '.py'
command = "python -u "+unPath+"\scripts\uncompyle2 " + file + ">" + newname
try:
os.system(command)
except e:
print file if __name__ == '__main__':
print 'init'
displayFile('C:\\pycc.pyc')
print 'finished'

经过测试 反编译后生成的py 执行报错:
SyntaxError: Non-ASCII character '\xd6' ***** but no encoding declared
一看就知道是编码问题, 说有在生成的py文件的头部加
# -*- coding: gbk -*-
很奇怪,# -*- coding: UTF8 -*- 也会报错

更多:http://www.iteye.com/topic/382423

Python 反编译工具uncompyle2的更多相关文章

  1. python反编译工具

    开发类在线工具:https://tool.lu/一个反编译网站:https://tool.lu/pyc/ 一看这个标题,就是搞坏事用的, 用 java 写程序多了,很习惯用反编译工具了,而且玩java ...

  2. python 反编译模块uncompyle2的使用--附破解wingide5 方法

    原来一直用pycharm,无奈它常常无法使用.来訪问一些模块的属性,朋友推荐了wingide,于是去官网下载了wingide5的最新版本号,仅仅有10天的试用期,就想能否用python的uncompy ...

  3. Java反编译工具CFR,Procyon简介

    Java反编译工具有很多,个人觉得使用最方便的是jd-gui,当然jad也不错,jd-gui主要提供了图形界面,操作起来很方便,但是jd-gui很久没有更新了,java 7出来很久了,jd-gui在反 ...

  4. 工欲善其事,必先利其器 软件工具开发关键词 protractor自动化测试工具 RegexBuddy正则 CodeSmith,LightSwitch:代码生成 CheatEngine:玩游戏修改内存值必备神器 ApkIDE:Android反编译工具 Reflector:反编译dll动态链接库

    工欲善其事,必先利其器 本文版权归翟士丹(Stan Zhai)和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利. 原文地址:http ...

  5. Java 反编译工具哪家强?对比分析瞧一瞧

    前言 Java 反编译,一听可能觉得高深莫测,其实反编译并不是什么特别高级的操作,Java 对于 Class 字节码文件的生成有着严格的要求,如果你非常熟悉 Java 虚拟机规范,了解 Class 字 ...

  6. apk反编译工具

    反编译工具: apktool:资源文件获取,可以提取出图片文件和布局文件进行使用查看 dex2jar:将apk反编译成Java源码(classes.dex转化成jar文件) jd-gui:查看APK中 ...

  7. eclipse安装反编译工具

    身为一名程序员来说,日常最常做的就是编写代码和查看别人写好的源代码了,有时候打开别人写的class文件发现根本不是自己想要的,所以给大家介绍一种eclipse中反编译class文件的工具. 第一步:下 ...

  8. .net混淆、反编译工具调查

    常用的工具列表[比较常见的] 混淆器.加密 Dotfuscator VS默认带的工具,不过是个社区版 强度不大 dotNET Reactor 使用了NativeCode 和混淆的形式 Xenocode ...

  9. Android反编译工具的使用-Android Killer

    今天百度搜索“Android反编译”搜索出来的结果大多数都是比较传统的教程.刚接触反编译的时候,我也是从这些教程慢慢学起的.在后来的学习过程中,我接触到比较方便操作的Android反编译.在这,我将使 ...

随机推荐

  1. 有关在线OJ网络AC爬虫

    搜索源码 爬取代码 自动登录 在线提交 判断AC

  2. thinkphp save()方法没有数据,保存失败解决办法

    thinkphp save()方法没有数据保存返回0,保存失败返回false   可以对返回值判断一下就好 $ret = $model->save($data); //var_dump($ret ...

  3. linux 终端全局代理设置

    http://www.webupd8.org/2010/10/how-to-set-proxy-for-terminal-quick.html 即 export http_proxy='http:// ...

  4. 应用HTK搭建语音拨号系统4: 识别器评估

    选自:http://maotong.blog.hexun.com/6261890_d.html 苏统华 哈尔滨工业大学人工智能研究室 2006年10月30日 声明:版权所有,转载请注明作者和来源 该系 ...

  5. espcms列表页ajax获取内容 - 并初始化swiper

    <link rel="stylesheet" href="swiper.min.css" type="text/css" media= ...

  6. Graph Valid Tree

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  7. ACM/ICPC 之 BFS(离线)+康拓展开(TSH OJ-玩具(Toy))

    祝大家新年快乐,相信在新的一年里一定有我们自己的梦! 这是一个简化的魔板问题,只需输出步骤即可. 玩具(Toy) 描述 ZC神最擅长逻辑推理,一日,他给大家讲述起自己儿时的数字玩具. 该玩具酷似魔方, ...

  8. cairo-1.14.6 static compiler msys mingw32

    gtk2.x 静态编译时 需要注意的是 cairo cairo 1.14.x 使用了 mutex , 用动态方式时 DllMain 中调用了 CAIRO_MUTEX_INITIALIZE () 在静态 ...

  9. GNOME启动时激活NumLock(小键盘数字锁定)

    首先下载numlockx官方源提供的安装包,解压后进入目录运行终端,切换到root账户执行以下命令: python ./setup.py 然后依次点击GNOME菜单项上的“系统->首选项-> ...

  10. linux 增加用户 useradd 用法小结及配置文件说明

    转自CSDN,http://blog.csdn.net/warden2010/article/details/5132290,谢谢作者 在Linux 系统中,所有的用户和组像一个国家.如果国家要繁荣昌 ...