Windows使用uncompyle6

安装:
pip install uncompyle6

cmd下查看使用方法:
uncompyle6 --help

Usage:
  uncompile [OPTIONS]... [ FILE | DIR]...
  uncompile [--help | -h | --V | --version]
Examples:
  uncompile      foo.pyc bar.pyc       # decompile foo.pyc, bar.pyc to stdout
  uncompile -o . foo.pyc bar.pyc       # decompile to ./foo.pyc_dis and ./bar.pyc_dis
  uncompile -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>
                  uncompyle6 -o /tmp bla/fasel.pyc bla/foo.pyc
                    -> /tmp/fasel.pyc_dis, /tmp/foo.pyc_dis
                  uncompyle6 -o /tmp bla/fasel.pyc bar/foo.pyc
                    -> /tmp/bla/fasel.pyc_dis, /tmp/bar/foo.pyc_dis
                  uncompyle6 -o /tmp /usr/lib/python1.5
                    -> /tmp/smtplib.pyc_dis ... /tmp/lib-tk/FixTk.pyc_dis
  -c <file>     attempts a disassembly after compiling <file>
  -d            print timestamps
  -p <integer>  use <integer> number of processes
  -r            recurse directories looking for .pyc and .pyo files
  --verify      compare generated source with input byte-code
  --linemaps    generated line number correspondencies between byte-code
                and generated source output
  --help        show this message
Debugging Options:
  --asm     -a  include byte-code         (disables --verify)
  --grammar -g  show matching grammar
  --tree    -t  include syntax tree       (disables --verify)
Extensions of generated files:
  '.pyc_dis' '.pyo_dis'   successfully decompiled (and verified if --verify)
    + '_unverified'       successfully decompile but --verify failed
    + '_failed'           decompile failed (contact author for enhancement)

反编译:
uncompyle6   -o   .   pyc文件名

说明:
-o后面可以加上文件路径,代表反编译文件输出的位置,“.”表示输出到当前文件夹
反编译成功后会返回“ # Successfully decompiled file

简单的批量反编译脚本:

# encoding=utf8
import os
import uncompyle6
from uncompyle6 import decompile_file
def main():
    path = 'C:\filename'.decode('utf8')        # Windows下
    for root, dirs, files in os.walk(path):
        if root != path:
            break
        for filename in files:
            if filename.endswith('pyc'):
                print filename
                os.system('uncompyle6 -o . %s'%filename)
    
if __name__ == '__main__':
    main()
  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值