-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathpedump.py
More file actions
27 lines (23 loc) · 708 Bytes
/
Copy pathpedump.py
File metadata and controls
27 lines (23 loc) · 708 Bytes
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
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import pefile
import argparse
import struct
def main( f = None, o = None ):
try:
exe = pefile.PE( f );
raw = exe.sections[0].get_data();
end = raw.find(b'\xcc' * 4);
raw = raw[:end]
bin = open( o, 'wb+' );
bin.write( raw );
bin.close( );
except Exception as e:
print("[error]: {}".format(e));
raise SystemExit
if __name__ in '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-f', help='Path to EXE file.', required=True);
parser.add_argument('-o', help='Path to store code.', required=True);
args = parser.parse_args();
main(**vars(args));