#!/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