-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeguide.py
43 lines (35 loc) · 1.08 KB
/
peguide.py
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
import argparse
from src.PEGCore import Core
def main():
parser = argparse.ArgumentParser(
description="Show the structure of portable executable (PE) files under\
the Windows family of operating systems. ",
usage="peguide.py <command> [part] file",
)
parser.add_argument("file")
parser.add_argument(
"--sections", nargs="?", const=True, default=False,
)
parser.add_argument(
"--headers", nargs="?", const=True, default=False,
)
parser.add_argument(
"--tables", nargs="?", const=True, default=False,
)
args = parser.parse_args()
core = Core(args.file)
core.read_headers()
core.read_sections()
core.read_directories()
if args.headers:
core.write_headers()
if args.sections:
core.write_sections()
if args.tables:
core.write_tables()
if not (args.headers or args.sections or args.tables):
core.write_headers()
core.write_sections()
core.write_tables()
if __name__ == "__main__":
main()