def full_report(options): global headers try: workspace = utils.get_workspace(options=options) url = options['REMOTE_API'] + "/api/{0}/activities".format(workspace) r = sender(url, headers=headers, data={}, method='GET') if r: raw_reports = r.json() except Exception: log_path = Path(options.get('WORKSPACE')).joinpath('log.json') raw_reports = utils.reading_json(log_path) if not raw_reports: utils.print_bad("Can't get log file for {0} workspace".format( options.get('TARGET'))) return None modules = list(raw_reports.keys()) for module in modules: if check_module(options, module): reports = raw_reports.get(module) utils.print_banner(module) for report in reports: cmd = report.get('cmd') utils.print_info("Command Executed: {0}\n".format(cmd)) output_path = report.get('output_path') std_path = report.get('std_path') if 'raw' in options.get('REPORT').lower(): read_report(std_path) elif 'full' in options.get('REPORT').lower(): read_report(output_path) utils.print_line()
def summary_report(options): global headers workspace = utils.get_workspace(options=options) try: url = options['REMOTE_API'] + "/api/workspace/{0}".format(workspace) r = sender(url, headers=headers, data={}, method='GET') if r: main_json = r.json() except Exception: main_json_path = Path(options.get('WORKSPACE')).joinpath( '{0}.json'.format(workspace)) main_json = utils.reading_json(main_json_path) if not main_json: utils.print_bad("Can't get log file for {0} workspace".format( options.get('TARGET'))) return None subdomains = main_json.get('Subdomains') head = ['Domain', 'IP', 'Technologies', 'Ports'] contents = [] for element in subdomains: item = [ element.get('Domain'), element.get('IP'), "\n".join(element.get('Technology')), ",".join(element.get('Ports')), ] contents.append(item) print(tabulate(contents, head, tablefmt="grid"))
def short_report(options): global headers workspace = utils.get_workspace(options=options) try: url = options['REMOTE_API'] + "/api/module/{0}".format(workspace) r = sender(url, headers=headers, data={}, method='GET') if r: raw_reports = r.json().get('reports', None) except Exception: raw_reports = None if not raw_reports: raw_reports = local_get_report(options).get('reports') if not raw_reports: utils.print_bad("Can't get log file for {0} workspace".format( options.get('TARGET'))) return None # only print out the path if options.get('REPORT') == 'path': path_report(options, raw_reports) return None for item in raw_reports: for report in item.get('reports'): report_path = os.path.join(options.get('WORKSPACES'), report.get('path')) utils.print_info(item.get('module') + ": " + report_path) # checking if get specific module or not if check_module(options, item.get('module')): read_report(report_path) elif options.get('MODULE') == "None": read_report(report_path) utils.print_line()