-
Notifications
You must be signed in to change notification settings - Fork 10
/
packer
executable file
·42 lines (37 loc) · 1.54 KB
/
packer
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
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
from pbox import *
from tinyscript import *
__script__ = "Packing tool"
__version__ = "1.2.0"
__doc__ = """
This tool simply packs (using Packer.pack) with the selected packer an input executable or folder of executables.
"""
__description__ = "Pack an input executable/folder with the selected packer"
__examples__ = [
"upx /tmp/cscript.exe",
"petite samples/",
"hxor-packer dataset-test-upx",
"nspack program.exe -a custom-alteration.yml -A rename_sections",
]
if __name__ == '__main__':
parser.add_argument("packer", type=Packer.get, help="selected packer")
parser.add_argument("executable", help="executable or folder containing executables")
add_argument(parser, "alterations-set", "alteration")
parser.add_argument("-p", "--prefix", help="string to be prepended to the filename")
initialize(noargs_action="usage", multi_level_debug=True)
configure_logging(args.verbose, ("INFO", "DEBUG", "DETAIL"))
p, rn = ts.Path(args.executable), lambda x: x.rename(x.dirname.joinpath(args.prefix + x.filename))
delattr(args, "executable")
set_yaml(args)
if p.is_file():
args.packer.pack(p.absolute(), **vars(args))
if args.prefix:
rn(p)
elif p.is_dir():
logger.debug("packing files from folder %s..." % p)
with progress_bar(transient=True) as pb:
for f in pb.track(p.listdir(is_exe)):
args.packer.pack(f.absolute(), **vars(args))
if args.prefix:
rn(f)