Python

批量反编译PyCodeObject

字号+ 作者:secoff 来源:转载 2017-03-15 09:28 我要评论( )

#!/usr/bin/env python # -*- coding:utf-8 -*- # mail: cn.b4dboy@gmail.com import sys import imp import glob import marshal import uncompyle2 files = glob......

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# mail: cn.b4dboy@gmail.com

import sys
import imp
import glob
import marshal
import uncompyle2

files = glob.glob(r'./code/*.txt')
for plug in files:
    txt = ''
    with open(plug, 'r') as f:
        txt = f.read()

    try:
        arr = eval(txt)
        #decode some file
        if imp.get_magic() == arr[1][:4]:
            code = marshal.dumps(arr[1])
            bin = marshal.loads(code[13:])
            with open(bin.co_filename, 'w') as f:
                uncompyle2.uncompyle('2.7.3', bin, f);

    except:
        print 'str 2 code err in file: %s' % plug

本文来自: 蜗蜗侠's Blog-关注网络安全 http://blog.icxun.cn/Python/612.html

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
网友点评
暂时未开启评论功能~