-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathanalysePE.py
More file actions
executable file
·72 lines (55 loc) · 1.63 KB
/
analysePE.py
File metadata and controls
executable file
·72 lines (55 loc) · 1.63 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python
# coding: utf-8
"""
analysePE.py - v0.1 - 2014.04.10
Author : Jan Goebel - goebel@pi-one.net
Licence : GPL v2
Example Usage:
# to extract PE header information
python analysePE.py file.exe
"""
############################################################################
# General Information
############################################################################
__author__ = "jan goebel (goebel@pi-one.net)"
__version__ = "0.1"
############################################################################
# Imports
############################################################################
import sys
import struct
import time
import os
import classPEfile
############################################################################
def showFile(fn):
t = classPEfile.pefile(fn)
if not t.isPEfile:
return
t.printMSDOSHeader()
t.printPEHeader()
t.printPEOptHeader()
t.printSectionHeader()
t.readExportSymbols()
t.readImportSymbols()
t.printImportedDLLs()
t.getImportedFunctions()
t.getExportedFunctions()
t.printResourceInformation()
return
############################################################################
if __name__ == '__main__':
try:
fn = sys.argv[1]
except:
print("missing file/directory to analyse")
sys.exit(255)
if os.path.isfile(fn):
print("reading from %s ..." % (fn))
showFile(fn)
else:
for root, dirs, files in os.walk(fn):
for fl in files:
fn = os.path.join(root, fl)
print("reading from %s ..." % (fn))
showFile(fn)