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.domain_name}} + + {{item.name}}
@@ -185,7 +185,7 @@ Dashboard ">
-

{{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}}

@@ -283,7 +283,7 @@ Dashboard
-
{{item.domain_name}}
{{item.start_scan_date|naturaltime}}
+
{{item.domain.name}}
{{item.start_scan_date|naturaltime}}

{% if item.scan_status == -1 %} {% include 'base/_items/progress_spin.html' %}Pending @@ -330,7 +330,7 @@ Dashboard

-
{{item.domain_name}}
{{item.start_scan_date|naturaltime}}
+
{{item.domain.name}}
{{item.start_scan_date|naturaltime}}

{% include 'base/_items/progress_spin.html' %}Scanning

@@ -370,7 +370,7 @@ Dashboard
-
{{item.domain_name}}
{{item.start_scan_date|naturaltime}}
+
{{item.domain.name}}
{{item.start_scan_date|naturaltime}}

{% 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}}
-
{{ip_addresses|length}} Discovered IP Addresses
+
{{ip_addresses|length}} Discovered IP Addresses
*IP Addresses highlighted with yellow are CDN IP
@@ -265,7 +265,7 @@ Detailed Scan Results for {{history.domain_name}}
-
{{ports.count}} Unique Discovered Ports
+
{{ports.count}} Unique Discovered Ports
*Ports highlighted with red are uncommon Ports.
@@ -303,7 +303,10 @@ Detailed Scan Results for {{history.domain_name}}
-
Loading...
  Subdomain Changes
+
+
Loading...
+   Subdomain Changes +

Comparing against the scan performed on {{last_scan.start_scan_date}}

During this scan @@ -331,7 +334,10 @@ Detailed Scan Results for {{history.domain_name}}

-
Loading...
  Endpoint Changes
+
+
Loading...
+   Endpoint Changes +

Comparing against the scan performed on {{last_scan.start_scan_date}}

During this scan diff --git a/startScan/templates/startScan/detail_vuln_scan.html b/startScan/templates/startScan/detail_vuln_scan.html index f3eadbbd..7e153537 100644 --- a/startScan/templates/startScan/detail_vuln_scan.html +++ b/startScan/templates/startScan/detail_vuln_scan.html @@ -21,7 +21,7 @@ Scan history - Vulnerabilities {% block breadcrumb_title %} {% if scan_history_id %} -Detailed Scan for {{history.domain_name}} - Vulnerabilities +Detailed Scan for {{history.domain.name}} - Vulnerabilities {% else %} All Vulnerabilities {% endif %} diff --git a/startScan/templates/startScan/history.html b/startScan/templates/startScan/history.html index a4e44f62..ac065f3a 100644 --- a/startScan/templates/startScan/history.html +++ b/startScan/templates/startScan/history.html @@ -50,14 +50,14 @@ Scan History {% for scan_history in scan_history.all %} {{ scan_history.id }} - {{ scan_history.domain_name }} + {{ scan_history.domain.name }} {{scan_history.get_subdomain_count}} {{scan_history.get_endpoint_count}} {{scan_history.get_vulnerability_count}} {{ scan_history.scan_type }} - {{ scan_history.last_scan_date }} + {{ scan_history.start_scan_date }} {% if scan_history.scan_status == -1 %} {% include 'base/_items/progress_spin.html' %}Pending @@ -115,7 +115,7 @@ Scan History {% endif %} - + diff --git a/startScan/templates/startScan/schedule_scan_ui.html b/startScan/templates/startScan/schedule_scan_ui.html index 1ab38acd..5d3cdfd2 100644 --- a/startScan/templates/startScan/schedule_scan_ui.html +++ b/startScan/templates/startScan/schedule_scan_ui.html @@ -19,7 +19,7 @@ Schedule Scan {% endblock custom_js_css_link %} {% block breadcrumb_title %} -Schedule Scan for {{domain.domain_name}} +Schedule Scan for {{domain.domain.name}} {% endblock breadcrumb_title %} {% block main_content %} @@ -27,7 +27,7 @@ Schedule Scan for {{domain.domain_name}}

@@ -107,9 +107,9 @@ Schedule Scan for {{domain.domain_name}}

Import Subdomains

- +
- +
diff --git a/startScan/templates/startScan/start_scan_ui.html b/startScan/templates/startScan/start_scan_ui.html index eb92f832..6b9e4f01 100644 --- a/startScan/templates/startScan/start_scan_ui.html +++ b/startScan/templates/startScan/start_scan_ui.html @@ -15,7 +15,7 @@ Start Scan {% endblock custom_js_css_link %} {% block breadcrumb_title %} -Start Scan for {{domain.domain_name}} +Start Scan for {{domain.domain.name}} {% endblock breadcrumb_title %} {% block main_content %} @@ -23,7 +23,7 @@ Start Scan for {{domain.domain_name}}
-

Initiating scan for {{domain.domain_name}}

+

Initiating scan for {{domain.domain.name}}

@@ -61,9 +61,9 @@ Start Scan for {{domain.domain_name}}

Import Subdomains

- +
- +
diff --git a/startScan/views.py b/startScan/views.py index e9cb9c11..ed366451 100644 --- a/startScan/views.py +++ b/startScan/views.py @@ -68,8 +68,8 @@ def detail_scan(request, id=None): domain_id = ScanHistory.objects.filter(id=id) if domain_id: - domain_id = domain_id[0].domain_name.id - scan_history = ScanHistory.objects.filter(domain_name=domain_id).filter(subdomain_discovery=True).filter(id__lte=id).filter(scan_status=2) + domain_id = domain_id[0].domain.id + scan_history = ScanHistory.objects.filter(domain=domain_id).filter(subdomain_discovery=True).filter(id__lte=id).filter(scan_status=2) if scan_history.count() > 1: last_scan = scan_history.order_by('-start_scan_date')[1] context['last_scan'] = last_scan @@ -130,7 +130,7 @@ def start_scan_ui(request, host_id): request, messages.INFO, 'Scan Started for ' + - domain.domain_name) + domain.name) return HttpResponseRedirect(reverse('scan_history')) engine = EngineType.objects.order_by('id') custom_engine_count = EngineType.objects.filter( @@ -173,7 +173,7 @@ def start_multiple_scan(request): for key, value in request.POST.items(): if key != "style-2_length" and key != "csrfmiddlewaretoken": domain = get_object_or_404(Domain, id=value) - list_of_domain_name.append(domain.domain_name) + list_of_domain_name.append(domain.name) list_of_domain_id.append(value) domain_text = ", ".join(list_of_domain_name) domain_ids = ",".join(list_of_domain_id) @@ -197,7 +197,7 @@ def export_subdomains(request, scan_id): response_body = response_body + name.name + "\n" response = HttpResponse(response_body, content_type='text/plain') response['Content-Disposition'] = 'attachment; filename="subdomains_' + \ - domain_results.domain_name.domain_name + '_' + \ + domain_results.domain.name + '_' + \ str(domain_results.start_scan_date.date()) + '.txt"' return response @@ -210,7 +210,7 @@ def export_endpoints(request, scan_id): response_body = response_body + endpoint.http_url + "\n" response = HttpResponse(response_body, content_type='text/plain') response['Content-Disposition'] = 'attachment; filename="endpoints_' + \ - domain_results.domain_name.domain_name + '_' + \ + domain_results.domain.name + '_' + \ str(domain_results.start_scan_date.date()) + '.txt"' return response @@ -224,7 +224,7 @@ def export_urls(request, scan_id): response_body = response_body + url.http_url + "\n" response = HttpResponse(response_body, content_type='text/plain') response['Content-Disposition'] = 'attachment; filename="urls_' + \ - domain_results.domain_name.domain_name + '_' + \ + domain_results.domain.name + '_' + \ str(domain_results.start_scan_date.date()) + '.txt"' return response @@ -232,7 +232,7 @@ def export_urls(request, scan_id): def delete_scan(request, id): obj = get_object_or_404(ScanHistory, id=id) if request.method == "POST": - delete_dir = obj.domain_name.domain_name + '_' + \ + delete_dir = obj.domain.name + '_' + \ str(datetime.datetime.strftime(obj.start_scan_date, '%Y_%m_%d_%H_%M_%S')) delete_path = settings.TOOL_LOCATION + 'scan_results/' + delete_dir os.system('rm -rf ' + delete_path) @@ -291,7 +291,7 @@ def schedule_scan(request, host_id): engine_type = int(request.POST['scan_mode']) engine_object = get_object_or_404(EngineType, id=engine_type) task_name = engine_object.engine_name + ' for ' + \ - domain.domain_name + \ + domain.name + \ ':' + \ str(datetime.datetime.strftime(timezone.now(), '%Y_%m_%d_%H_%M_%S')) if request.POST['scheduled_mode'] == 'periodic': @@ -334,7 +334,7 @@ def schedule_scan(request, host_id): request, messages.INFO, 'Scan Scheduled for ' + - domain.domain_name) + domain.name) return HttpResponseRedirect(reverse('scheduled_scan_view')) engine = EngineType.objects custom_engine_count = EngineType.objects.filter( @@ -410,7 +410,7 @@ def create_scan_object(host_id, engine_type): domain = Domain.objects.get(pk=host_id) task = ScanHistory() task.scan_status = -1 - task.domain_name = domain + task.domain = domain task.scan_type = engine_object task.start_scan_date = current_scan_time task.save() diff --git a/static/custom/custom.js b/static/custom/custom.js index 2b632da0..39b6d4d6 100644 --- a/static/custom/custom.js +++ b/static/custom/custom.js @@ -735,11 +735,11 @@ function get_endpoint_changes_values(scan_id){ function get_interesting_count(scan_id){ $.getJSON(`../api/listInterestingSubdomains/?scan_id=${scan_id}&no_page`, function(data) { $('#interesting_subdomain_count_badge').empty(); - $('#interesting_subdomain_count_badge').html(`${data.length}`); + $('#interesting_subdomain_count_badge').html(`${data.length}`); }); $.getJSON(`../api/listInterestingEndpoints/?scan_id=${scan_id}&no_page`, function(data) { $('#interesting_endpoint_count_badge').empty(); - $('#interesting_endpoint_count_badge').html(`${data.length}`); + $('#interesting_endpoint_count_badge').html(`${data.length}`); }); } diff --git a/targetApp/forms.py b/targetApp/forms.py index 7529f07c..6906c568 100644 --- a/targetApp/forms.py +++ b/targetApp/forms.py @@ -4,7 +4,7 @@ from reNgine.validators import validate_domain class AddTargetForm(forms.Form): - domain_name = forms.CharField( + name = forms.CharField( validators=[validate_domain], required=True, widget=forms.TextInput( @@ -14,7 +14,7 @@ class AddTargetForm(forms.Form): "placeholder": "example.com" } )) - domain_description = forms.CharField( + description = forms.CharField( required=False, widget=forms.TextInput( attrs={ @@ -23,9 +23,9 @@ class AddTargetForm(forms.Form): } )) - def clean_domain_name(self): - data = self.cleaned_data['domain_name'] - if Domain.objects.filter(domain_name=data).count() > 0: + def clean_name(self): + data = self.cleaned_data['name'] + if Domain.objects.filter(name=data).count() > 0: raise forms.ValidationError("{} target/domain already exists".format(data)) return data @@ -33,8 +33,8 @@ class AddTargetForm(forms.Form): class UpdateTargetForm(forms.ModelForm): class Meta: model = Domain - fields = ['domain_name', 'domain_description'] - domain_name = forms.CharField( + fields = ['name', 'description'] + name = forms.CharField( validators=[validate_domain], required=True, disabled=True, @@ -44,7 +44,7 @@ class UpdateTargetForm(forms.ModelForm): "id": "domainName", } )) - domain_description = forms.CharField( + description = forms.CharField( required=False, widget=forms.TextInput( attrs={ @@ -53,6 +53,6 @@ class UpdateTargetForm(forms.ModelForm): } )) - def set_value(self, domain_value, domain_description_value): - self.initial['domain_name'] = domain_value - self.initial['domain_description'] = domain_description_value + def set_value(self, domain_value, description_value): + self.initial['name'] = domain_value + self.initial['description'] = description_value diff --git a/targetApp/migrations/0003_auto_20210606_1608.py b/targetApp/migrations/0003_auto_20210606_1608.py new file mode 100644 index 00000000..c9a43d3e --- /dev/null +++ b/targetApp/migrations/0003_auto_20210606_1608.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.6 on 2021-06-06 16:08 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('targetApp', '0002_auto_20210502_0601'), + ] + + operations = [ + migrations.RenameField( + model_name='domain', + old_name='domain_description', + new_name='description', + ), + migrations.RenameField( + model_name='domain', + old_name='domain_name', + new_name='name', + ), + ] diff --git a/targetApp/models.py b/targetApp/models.py index a231e82c..f5f27916 100644 --- a/targetApp/models.py +++ b/targetApp/models.py @@ -3,10 +3,10 @@ from django.utils import timezone class Domain(models.Model): - domain_name = models.CharField(max_length=300, blank=True, null=True, unique=True) - domain_description = models.TextField() + name = models.CharField(max_length=300, blank=True, null=True, unique=True) + description = models.TextField() insert_date = models.DateTimeField() start_scan_date = models.DateTimeField(null=True) def __str__(self): - return self.domain_name + return self.name diff --git a/targetApp/templates/target/_items/domain_form.html b/targetApp/templates/target/_items/domain_form.html index ebb23c98..6d55b432 100644 --- a/targetApp/templates/target/_items/domain_form.html +++ b/targetApp/templates/target/_items/domain_form.html @@ -12,16 +12,16 @@
- {{ form.domain_name }} + {{ form.name }} {% if form.errors %}
- {{ form.errors.domain_name|striptags }} + {{ form.errors.name|striptags }}
{% endif %}
- {{ form.domain_description }} + {{ form.description }}
diff --git a/targetApp/templates/target/import.html b/targetApp/templates/target/import.html index 9c29774a..475991ba 100644 --- a/targetApp/templates/target/import.html +++ b/targetApp/templates/target/import.html @@ -24,22 +24,22 @@ Import Targets
-
@@ -407,7 +407,7 @@ Target Summary for {{target.domain_name}}
-

{{item.domain_name}}

+

{{item.name}}

{{item.start_scan_date|naturaltime}}

diff --git a/targetApp/views.py b/targetApp/views.py index 1f69d810..5de1ada8 100644 --- a/targetApp/views.py +++ b/targetApp/views.py @@ -37,7 +37,7 @@ def add_target_form(request): request, messages.INFO, 'Target domain ' + - form.cleaned_data['domain_name'] + + form.cleaned_data['name'] + ' added successfully') return http.HttpResponseRedirect(reverse('list_target')) context = { @@ -59,9 +59,9 @@ def import_targets(request): txt_content = txt_file.read().decode('UTF-8') io_string = io.StringIO(txt_content) for target in io_string: - if validators.domain(target): + if not Domain.objects.filter(name=_subdomain).exists() and validators.domain(target): Domain.objects.create( - domain_name=target.rstrip("\n"), + name=target.rstrip("\n"), insert_date=timezone.now()) target_count += 1 if target_count: @@ -85,8 +85,8 @@ def import_targets(request): for column in csv.reader(io_string, delimiter=','): if validators.domain(column[0]): Domain.objects.create( - domain_name=column[0], - domain_description=column[1], + name=column[0], + description=column[1], insert_date=timezone.now()) target_count += 1 if target_count: @@ -120,7 +120,7 @@ def delete_target(request, id): 'rm -rf ' + settings.TOOL_LOCATION + 'scan_results/' + - obj.domain_name + '*') + obj.name + '*') obj.delete() responseData = {'status': 'true'} messages.add_message( @@ -163,7 +163,7 @@ def update_target_form(request, id): 'Domain edited successfully') return http.HttpResponseRedirect(reverse('list_target')) else: - form.set_value(domain.domain_name, domain.domain_description) + form.set_value(domain.name, domain.description) context = { 'list_target_li': 'active', 'target_data_active': 'true', @@ -177,10 +177,10 @@ def target_summary(request, id): target = get_object_or_404(Domain, id=id) context['target'] = target context['scan_count'] = ScanHistory.objects.filter( - domain_name_id=id).count() + domai_id=id).count() last_week = timezone.now() - timedelta(days=7) context['this_week_scan_count'] = ScanHistory.objects.filter( - domain_name_id=id, start_scan_date__gte=last_week).count() + domain_id=id, start_scan_date__gte=last_week).count() subdomain_count = Subdomain.objects.filter( target_domain__id=id).values('name').distinct().count() endpoint_count = EndPoint.objects.filter( @@ -190,10 +190,10 @@ def target_summary(request, id): context['subdomain_count'] = subdomain_count context['endpoint_count'] = endpoint_count context['vulnerability_count'] = vulnerability_count - if ScanHistory.objects.filter(domain_name=id).filter( + if ScanHistory.objects.filter(domain=id).filter( scan_type__subdomain_discovery=True).filter(scan_status=2).count() > 1: print('ok') - last_scan = ScanHistory.objects.filter(domain_name=id).filter( + last_scan = ScanHistory.objects.filter(domain=id).filter( scan_type__subdomain_discovery=True).filter(scan_status=2).order_by('-start_scan_date') scanned_host_q1 = Subdomain.objects.filter( @@ -206,10 +206,10 @@ def target_summary(request, id): context['removed_subdomains'] = scanned_host_q1.difference(scanned_host_q2) if ScanHistory.objects.filter( - domain_name=id).filter( + domain=id).filter( scan_type__fetch_url=True).filter(scan_status=2).count() > 1: - last_scan = ScanHistory.objects.filter(domain_name=id).filter( + last_scan = ScanHistory.objects.filter(domain=id).filter( scan_type__fetch_url=True).filter(scan_status=2).order_by('-start_scan_date') endpoint_q1 = EndPoint.objects.filter( @@ -222,7 +222,7 @@ def target_summary(request, id): context['removed_urls'] = endpoint_q1.difference(endpoint_q2) context['recent_scans'] = ScanHistory.objects.filter( - domain_name=id).order_by('-start_scan_date')[:3] + domain=id).order_by('-start_scan_date')[:3] context['info_count'] = Vulnerability.objects.filter( target_domain=id).filter(severity=0).count() context['low_count'] = Vulnerability.objects.filter( @@ -238,5 +238,5 @@ def target_summary(request, id): context['interesting_subdomain'] = get_interesting_subdomains(target=id) context['interesting_endpoint'] = get_interesting_endpoint(target=id) context['scan_history'] = ScanHistory.objects.filter( - domain_name=id).order_by('-start_scan_date') + domain=id).order_by('-start_scan_date') return render(request, 'target/summary.html', context) diff --git a/templates/base/_items/interesting_recon.html b/templates/base/_items/interesting_recon.html index 4e5cad0e..4b309e22 100644 --- a/templates/base/_items/interesting_recon.html +++ b/templates/base/_items/interesting_recon.html @@ -14,7 +14,7 @@
- Interesting Subdomains + Interesting Subdomains
@@ -41,7 +41,7 @@
- Interesting Endpoints + Interesting Endpoints