批量反编译PyCodeObject

只为看下bugscan的插件、haha

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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