This repository was archived by the owner on Apr 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.py
More file actions
48 lines (37 loc) · 1.37 KB
/
entrypoint.py
File metadata and controls
48 lines (37 loc) · 1.37 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
import argparse
import multiprocessing as mp
import os
import re
import subprocess
import tempfile
from functools import partial
import shutil
FILENAME_RE = re.compile(r'[^\w\d-]')
def main():
args = parseargs()
pool = mp.Pool(processes=args.processes)
scan_list = [line.strip() for line in open(args.inputfile)]
func = partial(process, args.output_directory)
pool.map(func, scan_list)
def process(output, host):
try:
tmp_file = tempfile.mktemp()
path = os.path.join(output, FILENAME_RE.sub("_", host))
command = ["testssl.sh"]
command_arguments = ['--jsonfile', tmp_file, host]
command.extend(command_arguments)
subprocess.call(command)
shutil.move(tmp_file, path)
except Exception as exception:
print(exception)
def parseargs():
parser = argparse.ArgumentParser(description='Start the testssl scan')
parser.add_argument('-o', '--output_directory', default='/output', type=str, required=False,
help='output directory for results')
parser.add_argument('-p', '--processes', default=5, type=int, required=False,
help='number of processes to run')
parser.add_argument('inputfile', type=str,
help='Fetch the domains from a particular file.')
return parser.parse_args()
if __name__ == "__main__":
main()