mirror of
https://github.com/vivisect/vivisect
synced 2026-06-08 18:04:23 +00:00
80de840881
A lot of cleanup things in prep for a python 3 transition. Getting rid of the old exception syntax, converting prints over to logging, cutting random scraps of code to be proper unit tests, cut away some older bits of code, etc. This still works in python2. It's just a lot of tidying up. There are no major functionality changes.
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
'''
|
|
For now, all this does is rename files to their exportname and version info.
|
|
(more to come is likely)
|
|
'''
|
|
|
|
import sys
|
|
import code
|
|
import optparse
|
|
import binascii
|
|
|
|
import PE
|
|
|
|
def main():
|
|
|
|
parser = optparse.OptionParser()
|
|
parser.add_option('--version', dest='version', default=False, action='store_true')
|
|
parser.add_option('--resources', dest='resources', default=False, action='store_true')
|
|
|
|
opts, argv = parser.parse_args()
|
|
|
|
for fname in argv:
|
|
|
|
print('Parsing: %s' % fname)
|
|
|
|
vsver = None
|
|
expname = None
|
|
|
|
pe = PE.peFromFileName(fname)
|
|
|
|
if opts.resources:
|
|
print('Type Nameid - rva size sample')
|
|
for rtype, nameid, (rva, size, codepage) in pe.getResources():
|
|
hexstr = binascii.hexlify(pe.readAtRva(rva, max(size, 8)))
|
|
print('0x%.4x 0x%.4x - 0x%.8x 0x%.8x %s' % (rtype, nameid, rva, size, hexstr))
|
|
|
|
if opts.version:
|
|
vs = pe.getVS_VERSIONINFO()
|
|
if vs is None:
|
|
print('No VS_VERSIONINFO found!')
|
|
|
|
else:
|
|
keys = vs.getVersionKeys()
|
|
keys.sort()
|
|
for k in keys:
|
|
val = vs.getVersionValue(k)
|
|
print('%s: %r' % (k, val))
|
|
|
|
code.interact(local=locals())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|