如何反编译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. Sqli-LABS通关笔录-9[延时注入]

    通过这个关卡 1.更快的掌握到了如何判断是否是延时注入 无论咋输入,都不行.当payload为: http://127.0.0.1/sql/Less-9/index.php?id=1' and sle ...

  2. 2016年11月2日--Window.document对象

    一.找到元素: docunment.getElementById("id"):                      根据id找,最多找一个: var a =docunment ...

  3. EOS单向N对1关联

    1. N端实体中用于关联的属性可以是主键也可以是非主键,1端的关联字段必须是主键(可以是单主键也可以是复合主键). 如下图关联字段:orgid 2.当在N端选择了用于关联的属性,那么这些属性在N端实体 ...

  4. 【架构】Google的大规模集群管理工具Borg

    参考资料: http://www.cnblogs.com/YaoDD/p/5374393.html http://www.cnblogs.com/YaoDD/p/5351589.html

  5. ios cordite 读取错误CoreData could not fulfill a fault for '0x15b4a870

    解释在这里 http://stackoverflow.com/questions/14296892/nsobjectinaccessibleexception-reason-coredata-coul ...

  6. 安装m2crypto报错swig error : Unrecognized option -builtin

    M2Crypto 是最完整的为 Python 包装 OpenSSL 的 RSA,DSA,DH,EC,HMACs,消息摘要,对称密码算法(包括AES)的一个库工具.而自从 M2Crypto 升级到版本 ...

  7. 小项目特供 简易迷宫(基于Java)

    明天返校,于是昨天和今天简单熟系了一下JAVA的GUI,做了一个简易的迷宫小游戏(暂时没有时间实现随机迷宫及多关卡,仅供学习) 源码及运行文件(提供JRE8):链接:简易迷宫 密码:hy8v

  8. 6.nodejs权威指南--进程

    1. 进程 var net = require('net'); var cluster = require('cluster'); cluster.setupMaster({ exec:'child. ...

  9. K3已被禁用的基础资料如何显示出来

    [基础资料]——[公共资料]——[物料.职员.客户==]——[查看]——[选项]——显示禁用基础资料——确定,就可以看见你所禁用过的基础资料,显示为红色字体! 同类问题example: 金蝶K3 禁用 ...

  10. diff & pattch 命令

    基础知识 该命令的功能为逐行比较两个文本文件,列出其不同之处.它比comm命令完成更复杂的检查.它对给出的文件进行系统的检查,并显示出两个文件中所有不同的行,不要求事先对文件进行排序. 语法:diff ...