diff --git a/files/scan.py b/files/scan.py index 859ca062525fee679499fca2eb8d195110ba48dc..36394a59da99d9bbb3888d7a429dab212a4cc52b 100644 --- a/files/scan.py +++ b/files/scan.py @@ -9,7 +9,7 @@ import utilities import argparse ### GVM Options ### -wait_timeout = 3600 #1h +WAIT_TIMEOUT = 3600 #1h parser = argparse.ArgumentParser( description='Scan endpoints and machines') @@ -87,7 +87,7 @@ for host,ports in endpoints.items(): if task['status'] == 'New': task = gvm_library.start_task(task) - if gvm_library.wait_for_task_ending(task,wait_timeout): + if gvm_library.wait_for_task_ending(task, WAIT_TIMEOUT): gvm_library.save_report(task,gvm_library.report_formats.txt, report_filename) reports[host] = gvm_library.get_report_info(task) else: diff --git a/files/script.py b/files/script.py index c61e6d4213090705f1baf3fcd40568d7a1dbfef3..bc94f06f5d209580dd82f1b8e99b6432f6a1d4f6 100644 --- a/files/script.py +++ b/files/script.py @@ -9,7 +9,6 @@ import logging import json import base64 from sys import argv, exit -import socket import os def get_version_old(): @@ -425,7 +424,6 @@ def import_dep_info(file_path, endpoints_to_scan): return endpoints ################ MAIN ####################################### -import argparse logging.basicConfig( filename='scans.log', @@ -457,9 +455,6 @@ scanner = {'id': "08b69003-5fc2-4037-a479-93b440211c73"} ovs_ssh_credential = {'id': "b9af5845-8b87-4378-bca4-cee39a894c17"} wait_timeout = 3600 #1h - - - if len(argv) != 4: print("Please pass three parameters:") print("- endpoints to scans [endpoints1,endpoint2,endpoint3,...]") diff --git a/files/utilities.py b/files/utilities.py index abbb337c6ed4d7370e7079c8a34f25485f9266a1..ed3270b268d8200732cafc319b9a232549057874 100644 --- a/files/utilities.py +++ b/files/utilities.py @@ -1,6 +1,10 @@ import json import logging +SSH_PORT = '22' +HTTP_PORT = '80' +HTTPS_PORT = '443' + def pretty_json(j): return json.dumps(j,sort_keys=True,indent=4) @@ -13,7 +17,8 @@ def import_dep_info(file_path, endpoint_keys): for key,value in data['output'].items(): if "_ip" in key: if isinstance(value, str): - endpoints[value] = {22} + logging.info(f"Endpoint: {value}:{SSH_PORT}") + endpoints[value] = {SSH_PORT} if endpoint_keys != "None": list_endpoints = endpoint_keys.split(',') @@ -26,9 +31,9 @@ def import_dep_info(file_path, endpoint_keys): else: host = url if prefix == "https": - port = '443' + port = HTTPS_PORT elif prefix == 'http': - port = '80' + port = HTTP_PORT else: raise Exception(f"Impossible to parse the endpoint port. Endpoint: {endpoint}") logging.info(f"Endpoint: {host}:{port}")