diff --git a/dashboard/templates/dashboard/index.html b/dashboard/templates/dashboard/index.html
index 82466f0d..c58181bc 100644
--- a/dashboard/templates/dashboard/index.html
+++ b/dashboard/templates/dashboard/index.html
@@ -72,7 +72,7 @@ Dashboard
{{critical_count}} Critical, {{high_count}} High
- View all subdomains + View all Vulnerabilities @@ -106,8 +106,8 @@ Dashboard {% for item in most_vulnerable_target %} -{{item.title}} {% if item.status == 2 %} {% if item.title != 'Scan Completed' %} completed {% endif %}{% elif item.status == 1 %} initiated {% elif item.status == 0 %} {% if item.title != 'Scan aborted' %} aborted {% endif %} {% endif %}for {{item.scan_of.domain_name.domain_name}}
+{{item.title}} {% if item.status == 2 %} {% if item.title != 'Scan Completed' %} completed {% endif %}{% elif item.status == 1 %} initiated {% elif item.status == 0 %} {% if item.title != 'Scan aborted' %} aborted {% endif %} {% endif %}for {{item.scan_of.domain.name}}
{{item.time|naturaltime}}
{% if item.scan_status == -1 %} {% include 'base/_items/progress_spin.html' %}Pending @@ -330,7 +330,7 @@ Dashboard
{% include 'base/_items/progress_spin.html' %}Scanning
@@ -370,7 +370,7 @@ Dashboard{% if item.scan_status == -1 %} {% include 'base/_items/progress_spin.html' %}Pending diff --git a/reNgine/tasks.py b/reNgine/tasks.py index 3fdd65bc..9f60f695 100644 --- a/reNgine/tasks.py +++ b/reNgine/tasks.py @@ -65,7 +65,7 @@ def initiate_scan( # once the celery task starts, change the task status to Started task.scan_type = engine_object task.celery_id = initiate_scan.request.id - task.domain_name = domain + task.domain = domain task.scan_status = 1 task.start_scan_date = timezone.now() task.subdomain_discovery = True if engine_object.subdomain_discovery else False @@ -80,7 +80,7 @@ def initiate_scan( os.chdir(results_dir) try: - current_scan_dir = domain.domain_name + '_' + \ + current_scan_dir = domain.name + '_' + \ str(datetime.datetime.strftime(timezone.now(), '%Y_%m_%d_%H_%M_%S')) os.mkdir(current_scan_dir) except Exception as exception: @@ -122,7 +122,7 @@ def initiate_scan( initial_subdomain_file = '/target_domain.txt' if task.subdomain_discovery else '/sorted_subdomain_collection.txt' subdomain_file = open(results_dir + initial_subdomain_file, "w") - subdomain_file.write(domain.domain_name + "\n") + subdomain_file.write(domain.name + "\n") subdomain_file.close() if(task.subdomain_discovery): @@ -138,12 +138,10 @@ def initiate_scan( update_last_activity(activity_id, 2) activity_id = create_scan_activity(task, "HTTP Crawler", 1) - alive_file_location = results_dir + '/alive.txt' http_crawler( task, domain, results_dir, - alive_file_location, activity_id) update_last_activity(activity_id, 2) @@ -210,16 +208,16 @@ def skip_subdomain_scan(task, domain, results_dir): ''' if not Subdomain.objects.filter( scan_history=task, - name=domain.domain_name).exists(): + name=domain.name).exists(): scanned = Subdomain() - scanned.name = domain.domain_name + scanned.name = domain.name scanned.scan_history = task scanned.target_domain = domain scanned.save() # Save target into target_domain.txt with open('{}/target_domain.txt'.format(results_dir), 'w+') as file: - file.write(domain.domain_name + '\n') + file.write(domain.name + '\n') file.close() @@ -250,7 +248,7 @@ def skip_subdomain_scan(task, domain, results_dir): def extract_imported_subdomain(imported_subdomains, task, domain, results_dir): valid_imported_subdomains = [subdomain for subdomain in imported_subdomains if validators.domain( - subdomain) and domain.domain_name == get_domain_from_subdomain(subdomain)] + subdomain) and domain.name == get_domain_from_subdomain(subdomain)] # remove any duplicate valid_imported_subdomains = list(set(valid_imported_subdomains)) @@ -320,7 +318,7 @@ def subdomain_scan(task, domain, yaml_configuration, results_dir, activity_id): if 'amass-passive' in tools: amass_command = AMASS_COMMAND + \ ' -passive -d {} -o {}/from_amass.txt'.format( - domain.domain_name, results_dir) + domain.name, results_dir) if amass_config_path: amass_command = amass_command + \ ' -config {}'.format(settings.TOOL_LOCATION + @@ -333,7 +331,7 @@ def subdomain_scan(task, domain, yaml_configuration, results_dir, activity_id): if 'amass-active' in tools: amass_command = AMASS_COMMAND + \ ' -active -d {} -o {}/from_amass_active.txt'.format( - domain.domain_name, results_dir) + domain.name, results_dir) if AMASS_WORDLIST in yaml_configuration[SUBDOMAIN_DISCOVERY]: wordlist = yaml_configuration[SUBDOMAIN_DISCOVERY][AMASS_WORDLIST] @@ -356,7 +354,7 @@ def subdomain_scan(task, domain, yaml_configuration, results_dir, activity_id): if 'assetfinder' in tools: assetfinder_command = 'assetfinder --subs-only {} > {}/from_assetfinder.txt'.format( - domain.domain_name, results_dir) + domain.name, results_dir) # Run Assetfinder logging.info(assetfinder_command) @@ -364,7 +362,7 @@ def subdomain_scan(task, domain, yaml_configuration, results_dir, activity_id): if 'sublist3r' in tools: sublist3r_command = 'python3 /app/tools/Sublist3r/sublist3r.py -d {} -t {} -o {}/from_sublister.txt'.format( - domain.domain_name, threads, results_dir) + domain.name, threads, results_dir) # Run sublist3r logging.info(sublist3r_command) @@ -372,7 +370,7 @@ def subdomain_scan(task, domain, yaml_configuration, results_dir, activity_id): if 'subfinder' in tools: subfinder_command = 'subfinder -d {} -t {} -o {}/from_subfinder.txt'.format( - domain.domain_name, threads, results_dir) + domain.name, threads, results_dir) # Check for Subfinder config files if SUBFINDER_CONFIG in yaml_configuration[SUBDOMAIN_DISCOVERY]: @@ -398,20 +396,20 @@ def subdomain_scan(task, domain, yaml_configuration, results_dir, activity_id): if 'oneforall' in tools: oneforall_command = 'python3 /app/tools/OneForAll/oneforall.py --target {} run'.format( - domain.domain_name, results_dir) + domain.name, results_dir) # Run OneForAll logging.info(oneforall_command) os.system(oneforall_command) extract_subdomain = "cut -d',' -f6 /app/tools/OneForAll/results/{}.csv >> {}/from_oneforall.txt".format( - domain.domain_name, results_dir) + domain.name, results_dir) os.system(extract_subdomain) # remove the results from oneforall directory os.system( - 'rm -rf /app/tools/OneForAll/results/{}.*'.format(domain.domain_name)) + 'rm -rf /app/tools/OneForAll/results/{}.*'.format(domain.name)) ''' All tools have gathered the list of subdomains with filename @@ -458,12 +456,13 @@ def subdomain_scan(task, domain, yaml_configuration, results_dir, activity_id): subdomain.save() -def http_crawler(task, domain, results_dir, alive_file_location, activity_id): +def http_crawler(task, domain, results_dir, activity_id): ''' This function is runs right after subdomain gathering, and gathers important like page title, http status, etc HTTP Crawler runs by default ''' + alive_file_location = results_dir + '/alive.txt' httpx_results_file = results_dir + '/httpx.json' subdomain_scan_results_file = results_dir + '/sorted_subdomain_collection.txt' @@ -810,7 +809,7 @@ def fetch_endpoints( else: scan_type = 'normal' - domain_regex = "\'https?://([a-z0-9]+[.])*{}.*\'".format(domain.domain_name) + domain_regex = "\'https?://([a-z0-9]+[.])*{}.*\'".format(domain.name) if 'deep' in scan_type: # performs deep url gathering for all the subdomains present - @@ -822,7 +821,7 @@ def fetch_endpoints( os.system( settings.TOOL_LOCATION + 'get_urls.sh %s %s %s %s %s' % - (domain.domain_name, + (domain.name, results_dir, scan_type, domain_regex, diff --git a/startScan/api/views.py b/startScan/api/views.py index 5c97fb28..bd514380 100644 --- a/startScan/api/views.py +++ b/startScan/api/views.py @@ -46,8 +46,8 @@ class SubdomainChangesViewSet(viewsets.ModelViewSet): req = self.request scan_id = req.query_params.get('scan_id') changes = req.query_params.get('changes') - domain_id = ScanHistory.objects.filter(id=scan_id)[0].domain_name.id - scan_history = ScanHistory.objects.filter(domain_name=domain_id).filter(subdomain_discovery=True).filter(id__lte=scan_id).filter(scan_status=2) + domain_id = ScanHistory.objects.filter(id=scan_id)[0].domain.id + scan_history = ScanHistory.objects.filter(domain=domain_id).filter(subdomain_discovery=True).filter(id__lte=scan_id).filter(scan_status=2) if scan_history.count() > 1: last_scan = scan_history.order_by('-start_scan_date')[1] scanned_host_q1 = Subdomain.objects.filter(scan_history__id=scan_id).values('name') @@ -83,8 +83,8 @@ class EndPointChangesViewSet(viewsets.ModelViewSet): scan_id = req.query_params.get('scan_id') changes = req.query_params.get('changes') - domain_id = ScanHistory.objects.filter(id=scan_id)[0].domain_name.id - scan_history = ScanHistory.objects.filter(domain_name=domain_id).filter(fetch_url=True).filter(id__lte=scan_id).filter(scan_status=2) + domain_id = ScanHistory.objects.filter(id=scan_id)[0].domain.id + scan_history = ScanHistory.objects.filter(domain=domain_id).filter(fetch_url=True).filter(id__lte=scan_id).filter(scan_status=2) if scan_history.count() > 1: last_scan = scan_history.order_by('-start_scan_date')[1] scanned_host_q1 = EndPoint.objects.filter(scan_history__id=scan_id).values('http_url') @@ -165,7 +165,7 @@ class SubdomainViewset(viewsets.ModelViewSet): url_query = req.query_params.get('query_param') if url_query: self.queryset = Subdomain.objects.filter( - Q(target_domain__domain_name=url_query)) + Q(target_domain__name=url_query)) elif scan_id: self.queryset = Subdomain.objects.filter( scan_history__id=scan_id) @@ -352,12 +352,12 @@ class EndPointViewSet(viewsets.ModelViewSet): if url_query.isnumeric(): self.queryset = EndPoint.objects.filter( Q( - scan_history__domain_name__domain_name=url_query) | Q( + scan_history__domain__name=url_query) | Q( http_url=url_query) | Q( id=url_query)) else: self.queryset = EndPoint.objects.filter( - Q(scan_history__domain_name__domain_name=url_query) | Q(http_url=url_query)) + Q(scan_history__domain__name=url_query) | Q(http_url=url_query)) elif scan_history: self.queryset = EndPoint.objects.filter(scan_history__id=scan_history) @@ -516,12 +516,12 @@ class VulnerabilityViewSet(viewsets.ModelViewSet): if url_query.isnumeric(): self.queryset = Vulnerability.objects.filter( Q( - scan_history__domain_name__domain_name=url_query) | Q( + scan_history__domain__name=url_query) | Q( name=url_query) | Q( id=url_query)) else: self.queryset = Vulnerability.objects.filter( - Q(scan_history__domain_name__domain_name=url_query) | Q(name=url_query)) + Q(scan_history__domain__name=url_query) | Q(name=url_query)) elif vulnerability_of: self.queryset = Vulnerability.objects.filter( scan_history__id=vulnerability_of) diff --git a/startScan/migrations/0040_auto_20210606_1604.py b/startScan/migrations/0040_auto_20210606_1604.py new file mode 100644 index 00000000..de1f8853 --- /dev/null +++ b/startScan/migrations/0040_auto_20210606_1604.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.6 on 2021-06-06 16:04 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('startScan', '0039_subdomain_is_imported_subdomain'), + ] + + operations = [ + migrations.RenameField( + model_name='scanhistory', + old_name='domain_name', + new_name='domain', + ), + ] diff --git a/startScan/models.py b/startScan/models.py index ba173197..da8fb319 100644 --- a/startScan/models.py +++ b/startScan/models.py @@ -13,7 +13,7 @@ from django.http import JsonResponse class ScanHistory(models.Model): start_scan_date = models.DateTimeField() scan_status = models.IntegerField() - domain_name = models.ForeignKey(Domain, on_delete=models.CASCADE) + domain = models.ForeignKey(Domain, on_delete=models.CASCADE) scan_type = models.ForeignKey(EngineType, on_delete=models.CASCADE) celery_id = models.CharField(max_length=100, blank=True) subdomain_discovery = models.BooleanField(null=True, default=False) @@ -26,7 +26,7 @@ class ScanHistory(models.Model): def __str__(self): # debug purpose remove scan type and id in prod - return self.domain_name.domain_name + return self.domain.name def get_subdomain_count(self): return Subdomain.objects.filter(scan_history__id=self.id).count() diff --git a/startScan/templates/startScan/detail_endpoint_scan.html b/startScan/templates/startScan/detail_endpoint_scan.html index 571df410..124d431e 100644 --- a/startScan/templates/startScan/detail_endpoint_scan.html +++ b/startScan/templates/startScan/detail_endpoint_scan.html @@ -16,7 +16,7 @@ Scan history - Endpoints {% block breadcrumb_title %} {% if scan_history_id %} -Detailed Scan for {{history.domain_name}} - Endpoints +Detailed Scan for {{history.domain.name}} - Endpoints {% else %} All Endpoints {% endif %} diff --git a/startScan/templates/startScan/detail_scan.html b/startScan/templates/startScan/detail_scan.html index bc9972f5..7531c790 100644 --- a/startScan/templates/startScan/detail_scan.html +++ b/startScan/templates/startScan/detail_scan.html @@ -30,7 +30,7 @@ Detailed Scan {% endblock custom_js_css_link %} {% block breadcrumb_title %} -Detailed Scan Results for {{history.domain_name}} +Detailed Scan Results for {{history.domain.name}} {% endblock breadcrumb_title %} {% block main_content %} @@ -169,10 +169,10 @@ Detailed Scan Results for {{history.domain_name}}
@@ -246,7 +246,7 @@ Detailed Scan Results for {{history.domain_name}}