-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrich_standalone.py
More file actions
49 lines (41 loc) · 1.23 KB
/
rich_standalone.py
File metadata and controls
49 lines (41 loc) · 1.23 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
#!/usr/bin/env python3
import sys
import traceback
# imports for rich
import richlibrary
def RichHeader(objpath):
return richlibrary.RichLibrary(objpath)
def main():
if len(sys.argv) < 2:
print("Usage: {} <pe-files>".format(sys.argv[0]))
sys.exit(-1)
for arg in sys.argv[1:]:
error = 0
rich_parser = RichHeader(arg)
try:
rich = rich_parser.parse()
except richlibrary.FileSizeError:
error = -2
except richlibrary.MZSignatureError:
error = -3
except richlibrary.MZPointerError:
error = -4
except richlibrary.PESignatureError:
error = -5
except richlibrary.RichSignatureError:
error = -6
except richlibrary.DanSSignatureError:
error = -7
except richlibrary.HeaderPaddingError:
error = -8
except richlibrary.RichLengthError:
error = -9
except Exception as e:
print(traceback.format_exc(e))
if error < 0:
print("\x1b[33m[-] " + richlibrary.err2str(error) + "\x1b[39m")
sys.exit(error)
else:
rich_parser.pprint_header(rich)
if __name__ == '__main__':
main()