diff options
| author | serpilliere <devnull@localhost> | 2011-08-11 10:28:35 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2011-08-11 10:28:35 +0200 |
| commit | 7542338f5d8335bf0c2ef0a6c91c7b926f1d899c (patch) | |
| tree | a132c0fa9c02950e05c49dcad1c8c9565b388be2 /example | |
| parent | a22b38d595fb85a8657f6da5f5d40bc10e36ebb2 (diff) | |
| download | miasm-7542338f5d8335bf0c2ef0a6c91c7b926f1d899c.tar.gz miasm-7542338f5d8335bf0c2ef0a6c91c7b926f1d899c.zip | |
add example ressource extractor
Diffstat (limited to 'example')
| -rw-r--r-- | example/extract_pe_ressources.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/example/extract_pe_ressources.py b/example/extract_pe_ressources.py new file mode 100644 index 00000000..d8fe11c1 --- /dev/null +++ b/example/extract_pe_ressources.py @@ -0,0 +1,38 @@ +import sys +import struct +from elfesteem import * +import os +import sys + +# example for extracting all pe ressources + +def extract_res(res, num = 0, lvl=-1): + lvl +=1 + if not res: + return num + for x in res.resentries: + print "\t"*lvl, repr(x) + num += 1 + if x.data: + print "\t"*lvl, 'data', len(x.data.s) + open('out/%.3d.bin'%(num), 'w').write(str(x.data.s)) + else: + print "\t"*lvl, None + if x.offsettosubdir: + num = extract_res(x.subdir, num, lvl+1) + return num + + + +try: + os.stat('out') +except: + os.mkdir('out') + +fname = sys.argv[1] +e = pe_init.PE(open(fname, 'rb').read()) +res = e.DirRes.resdesc + + + +extract_res(res) |