From 0d5f4b0b51fffaaf6464c6fd4e4bf7a1f0a63abb Mon Sep 17 00:00:00 2001 From: Yogesh Ojha Date: Tue, 25 May 2021 09:12:16 +0530 Subject: [PATCH] Fixed aquatone screenshot json parsing issue --- reNgine/tasks.py | 26 ++++++++----------- .../templates/startScan/detail_scan.html | 14 +++------- startScan/views.py | 2 +- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/reNgine/tasks.py b/reNgine/tasks.py index a09ade9a..305162b4 100644 --- a/reNgine/tasks.py +++ b/reNgine/tasks.py @@ -524,27 +524,23 @@ def grab_screenshot(task, yaml_configuration, results_dir, activity_id): try: if os.path.isfile(aqua_json_path): + logger.info('Gathering aquatone results') with open(aqua_json_path, 'r') as json_file: data = json.load(json_file) for host in data['pages']: - sub_domain = Subdomain.objects.get( + try: + sub_domain = Subdomain.objects.get( scan_history__id=task.id, name=data['pages'][host]['hostname']) - # list_ip = data['pages'][host]['addrs'] - # ip_string = ','.join(list_ip) - # sub_domain.ip_address = ip_string - sub_domain.screenshot_path = results_dir + \ - '/aquascreenshots/' + data['pages'][host]['screenshotPath'] - sub_domain.http_header_path = results_dir + \ - '/aquascreenshots/' + data['pages'][host]['headersPath'] - tech_list = [] - if data['pages'][host]['tags'] is not None: - for tag in data['pages'][host]['tags']: - tech_list.append(tag['text']) - tech_string = ','.join(tech_list) - sub_domain.technology_stack = tech_string - sub_domain.save() + if data['pages'][host]['hasScreenshot']: + sub_domain.screenshot_path = results_dir + \ + '/aquascreenshots/' + data['pages'][host]['screenshotPath'] + sub_domain.http_header_path = results_dir + \ + '/aquascreenshots/' + data['pages'][host]['headersPath'] + sub_domain.save() + except Exception as e: + continue except Exception as exception: logging.error(exception) update_last_activity(activity_id, 0) diff --git a/startScan/templates/startScan/detail_scan.html b/startScan/templates/startScan/detail_scan.html index 6d552899..efbc25f0 100644 --- a/startScan/templates/startScan/detail_scan.html +++ b/startScan/templates/startScan/detail_scan.html @@ -423,10 +423,11 @@ Detailed Scan Results for {{history.domain_name}} Screenshot Response Time Technology + Checked HTTP URL IS CDN CNAME - Checked + is_interesting Info Low Medium @@ -445,7 +446,7 @@ Detailed Scan Results for {{history.domain_name}} {{subdomain.name}}
-

{{subdomain.name}}

+

{{subdomain.name}}{{subdomain.screenshot_path}}

@@ -551,13 +552,6 @@ Detailed Scan Results for {{history.domain_name}} // Collapse Sidebar collapse_sidebar(); -function fetch_http_headers(id, http_header_path, screenshot_path){ - $('#screenshot'+id).attr('src', '/media/'+screenshot_path); - fetch('/media/'+http_header_path) - .then(response => response.text()) - .then(text => $("#tabsModal"+id+" #txt-file-content").text(text)); -} - $("#pills-subdomain-tab").click(function() { $('#subdomain_scan_results').DataTable({ "destroy": true, @@ -775,7 +769,7 @@ $("#pills-subdomain-tab").click(function() { "render": function ( data, type, row ) { if (data){ //return lightbox with caption as http link - return ``; + return ``; } return ""; }, diff --git a/startScan/views.py b/startScan/views.py index 9a558df7..429be569 100644 --- a/startScan/views.py +++ b/startScan/views.py @@ -77,7 +77,7 @@ def detail_scan(request, id=None): context['ip_addresses'] = IPAddress.objects.filter(scan_history=id).values_list('address', 'is_cdn').distinct().order_by() context['ports'] = Port.objects.filter(scan_history=id).values_list('number', 'service_name', 'description', 'is_uncommon').distinct().order_by('number') - context['screenshot_subdomains'] = Subdomain.objects.filter(scan_history__id=id).exclude(screenshot_path__isnull=True,screenshot_path="") + context['screenshot_subdomains'] = Subdomain.objects.filter(scan_history__id=id).exclude(screenshot_path__isnull=True) # badge count for gfs if history.used_gf_patterns: