Domain model refactored

This commit is contained in:
Yogesh Ojha
2021-06-06 21:59:24 +05:30
parent 6a7e5f65c7
commit e7e407f6ca
22 changed files with 167 additions and 121 deletions
+7 -7
View File
@@ -72,7 +72,7 @@ Dashboard
</div>
<br>
<p class="w-title"><b>{{critical_count}}</b> Critical, <b>{{high_count}}</b> High</p>
<a href="{% url 'all_vulns' %}">View all subdomains</a>
<a href="{% url 'all_vulns' %}">View all Vulnerabilities</a>
</div>
</div>
</div>
@@ -106,8 +106,8 @@ Dashboard
</thead>
<tbody>
{% for item in most_vulnerable_target %}
<tr class="bs-tooltip" title="{{item.num_vul}} Vulnerabilities" onclick="window.location='start_scan/detail/vuln?query={{item.domain_name}}';" style="cursor: pointer;">
<td>{{item.domain_name}}</td>
<tr class="bs-tooltip" title="{{item.num_vul}} Vulnerabilities" onclick="window.location='start_scan/detail/vuln?query={{item.domain.name}}';" style="cursor: pointer;">
<td>{{item.name}}</td>
<td class="text-center">
<div class="progress br-30">
<div class="progress-bar br-30 bg-danger" role="progressbar" style="width: {% with percent=item.num_vul|div:total_vul_count %}{{percent|mul:100}}{% endwith %}%" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
@@ -185,7 +185,7 @@ Dashboard
">
<div class="t-dot" data-original-title="" title=""></div>
<div class="t-text">
<p><b>{{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 %}</b>for {{item.scan_of.domain_name.domain_name}}</p>
<p><b>{{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 %}</b>for {{item.scan_of.domain.name}}</p>
<p class="t-time">{{item.time|naturaltime}}</p>
</div>
</div>
@@ -283,7 +283,7 @@ Dashboard
</div>
<div class="w-summary-details">
<div class="w-summary-info">
<h6>{{item.domain_name}}<br><small>{{item.start_scan_date|naturaltime}}</small></h6>
<h6>{{item.domain.name}}<br><small>{{item.start_scan_date|naturaltime}}</small></h6>
<p class="summary-average">
{% if item.scan_status == -1 %}
<span class="badge badge-warning">{% include 'base/_items/progress_spin.html' %}Pending</span>
@@ -330,7 +330,7 @@ Dashboard
</div>
<div class="w-summary-details">
<div class="w-summary-info">
<h6>{{item.domain_name}}<br><small>{{item.start_scan_date|naturaltime}}</small></h6>
<h6>{{item.domain.name}}<br><small>{{item.start_scan_date|naturaltime}}</small></h6>
<p class="summary-average">
<span class="badge badge-info">{% include 'base/_items/progress_spin.html' %}Scanning</span>
</p>
@@ -370,7 +370,7 @@ Dashboard
</div>
<div class="w-summary-details">
<div class="w-summary-info">
<h6>{{item.domain_name}}<br><small>{{item.start_scan_date|naturaltime}}</small></h6>
<h6>{{item.domain.name}}<br><small>{{item.start_scan_date|naturaltime}}</small></h6>
<p class="summary-average">
{% if item.scan_status == -1 %}
<span class="badge badge-warning">{% include 'base/_items/progress_spin.html' %}Pending</span>
+19 -20
View File
@@ -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,
+9 -9
View File
@@ -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)
@@ -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',
),
]
+2 -2
View File
@@ -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()
@@ -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 %}
+13 -7
View File
@@ -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 %}
<!-- Activity Feed -->
@@ -169,10 +169,10 @@ Detailed Scan Results for {{history.domain_name}}
<div class="widget-heading">
<a href="javascript:void(0)" class="task-info">
<div class="usr-avatar">
<span>{{history.domain_name.domain_name|slice:"0:2"|upper}}</span>
<span>{{history.domain.name|slice:"0:2"|upper}}</span>
</div>
<div class="w-title">
<h6>Scan Information for <span class="badge badge-info">{{history.domain_name.domain_name}}</span></h6>
<h6>Scan Information for <span class="badge badge-info">{{history.domain.name}}</span></h6>
</div>
</a>
</div>
@@ -246,7 +246,7 @@ Detailed Scan Results for {{history.domain_name}}
<div class="col-xl-4 col-lg-3 col-md-12 col-sm-12 col-12 layout-spacing">
<div class="widget widget-ip">
<div class="widget-heading">
<h6 class="">{{ip_addresses|length}} Discovered IP Addresses</h6>
<h6 class=""><span class='badge outline-badge-dark'>{{ip_addresses|length}}</span> Discovered IP Addresses</h6>
<small class="text-warning">*IP Addresses highlighted with yellow are CDN IP</small>
</div>
<div class="widget-content">
@@ -265,7 +265,7 @@ Detailed Scan Results for {{history.domain_name}}
<div class="col-xl-4 col-lg-3 col-md-12 col-sm-12 col-12 layout-spacing">
<div class="widget widget-ip">
<div class="widget-heading">
<h6 class="">{{ports.count}} Unique Discovered Ports</small></h6>
<h6 class=""><span class='badge outline-badge-dark'>{{ports.count}}</span> Unique Discovered Ports</small></h6>
<small class="text-danger">*Ports highlighted with red are uncommon Ports.</small>
</div>
<div class="widget-content">
@@ -303,7 +303,10 @@ Detailed Scan Results for {{history.domain_name}}
<div class="widget widget-table-two">
<div class="widget-heading">
<h6 class=""><div class="spinner-border text-danger align-self-center loader-sm" id="subdomain-changes-loader">Loading...</div><span class="badge badge-danger" id="subdomain_change_count"></span>&nbsp;&nbsp;Subdomain Changes</h6>
<h6 class="">
<div class="spinner-border text-danger align-self-center loader-sm" id="subdomain-changes-loader">Loading...</div>
<span class="badge outline-badge-danger" id="subdomain_change_count"></span>&nbsp;&nbsp;Subdomain Changes
</h6>
<p class='text-muted'>Comparing against the scan performed on <a href="{{last_scan.id}}" class="badge badge-pills badge-info bs-tooltip" title="{{last_scan.get_subdomain_count}} subdomains were discovered during the last scan, while this scan discovered {{history.get_subdomain_count}} Subdomains"><small>{{last_scan.start_scan_date}}</small></a></p>
<p class='text-muted'>During this scan
<span class="badge badge-success badge-pills m-1" id="subdomain-added-count"></span>
@@ -331,7 +334,10 @@ Detailed Scan Results for {{history.domain_name}}
<div class="widget widget-table-two">
<div class="widget-heading">
<h6 class=""><div class="spinner-border text-danger align-self-center loader-sm" id="endpoint-changes-loader">Loading...</div><span class="badge badge-danger" id="endpoint_change_count"></span>&nbsp;&nbsp;Endpoint Changes</h6>
<h6 class="">
<div class="spinner-border text-danger align-self-center loader-sm" id="endpoint-changes-loader">Loading...</div>
<span class="badge outline-badge-danger" id="endpoint_change_count"></span>&nbsp;&nbsp;Endpoint Changes
</h6>
<p class='text-muted'>Comparing against the scan performed on <a href="{{last_scan.id}}" class="badge badge-pills badge-info bs-tooltip" title="{{last_scan.get_endpoint_count}} endpoints were discovered during the last scan, while this scan discovered {{history.get_endpoint_count}} Endpoints."><small>{{last_scan.start_scan_date}}</small></a></p>
<p class='text-muted'>During this scan
<span class="badge badge-success badge-pills m-1" id="endpoint-added-count"></span>
@@ -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 %}
+3 -3
View File
@@ -50,14 +50,14 @@ Scan History
{% for scan_history in scan_history.all %}
<tr>
<td class="checkbox-column"> {{ scan_history.id }} </td>
<td class="">{{ scan_history.domain_name }}</td>
<td class="">{{ scan_history.domain.name }}</td>
<td class="text-center">
<span class="badge badge-pills badge-info bs-tooltip" title="Subdomains">{{scan_history.get_subdomain_count}}</span>
<span class="badge badge-pills badge-warning bs-tooltip" title="Endpoints">{{scan_history.get_endpoint_count}}</span>
<span class="badge badge-pills badge-danger bs-tooltip" title="{{scan_history.get_critical_vulnerability_count}} Critical, {{scan_history.get_high_vulnerability_count}} High, {{scan_history.get_medium_vulnerability_count}} Medium Vulnerabilities">{{scan_history.get_vulnerability_count}}</span>
</td>
<td class="text-center">{{ scan_history.scan_type }}</td>
<td class="text-center">{{ scan_history.last_scan_date }}</td>
<td class="text-center">{{ scan_history.start_scan_date }}</td>
<td class="text-center">
{% if scan_history.scan_status == -1 %}
<span class="shadow-none badge tbadge-warning bs-tooltip" data-placement="top" title="Waiting for other scans to complete">{% include 'base/_items/progress_spin.html' %}Pending</span>
@@ -115,7 +115,7 @@ Scan History
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather table-delete feather-alert-octagon"><polygon points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"></polygon><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
</a>
{% endif %}
<a onclick="delete_scan({{ scan_history.id }})" href="#" class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete Scan {{ scan_history.domain_name }}">
<a onclick="delete_scan({{ scan_history.id }})" href="#" class="bs-tooltip" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete Scan {{ scan_history.domain.name }}">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather table-delete feather-x-circle">
<circle cx="12" cy="12" r="10"></circle>
<line x1="15" y1="9" x2="9" y2="15"></line>
@@ -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}}
<div class="widget-header">
<div class="row">
<div class="col-12">
<h4>Schedule scan for <b>{{domain.domain_name}}</b></h4>
<h4>Schedule scan for <b>{{domain.domain.name}}</b></h4>
</div>
</div>
</div>
@@ -107,9 +107,9 @@ Schedule Scan for {{domain.domain_name}}
<h3>Import Subdomains</h3>
<div class="">
<div class="form-group mb-4">
<label for="importSubdomainFormControlTextarea"><b class="text-info">Import Subdomains(Optional)</b></br>You can import subdomains for <b>{{domain.domain_name}}</b> using your private recon tools.</label>
<label for="importSubdomainFormControlTextarea"><b class="text-info">Import Subdomains(Optional)</b></br>You can import subdomains for <b>{{domain.domain.name}}</b> using your private recon tools.</label>
</br>
<label for="importSubdomainFormControlTextarea">Seperate the subdomains using new line. If the subdomain does not belong to <b>{{domain.domain_name}}</b> it will be skipped.</label>
<label for="importSubdomainFormControlTextarea">Seperate the subdomains using new line. If the subdomain does not belong to <b>{{domain.domain.name}}</b> it will be skipped.</label>
<textarea class="form-control" id="importSubdomainFormControlTextarea" rows="7" spellcheck="false" name="importSubdomainTextArea"></textarea>
</div>
</div>
@@ -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}}
<div class="widget-header">
<div class="row">
<div class="col-12">
<h4>Initiating scan for <b>{{domain.domain_name}}</b></h4>
<h4>Initiating scan for <b>{{domain.domain.name}}</b></h4>
</div>
</div>
</div>
@@ -61,9 +61,9 @@ Start Scan for {{domain.domain_name}}
<h3>Import Subdomains</h3>
<div class="">
<div class="form-group mb-4">
<label for="importSubdomainFormControlTextarea"><b class="text-info">Import Subdomains(Optional)</b></br>You can import subdomains for <b>{{domain.domain_name}}</b> using your private recon tools.</label>
<label for="importSubdomainFormControlTextarea"><b class="text-info">Import Subdomains(Optional)</b></br>You can import subdomains for <b>{{domain.domain.name}}</b> using your private recon tools.</label>
</br>
<label for="importSubdomainFormControlTextarea">Seperate the subdomains using new line. If the subdomain does not belong to <b>{{domain.domain_name}}</b> it will be skipped.</label>
<label for="importSubdomainFormControlTextarea">Seperate the subdomains using new line. If the subdomain does not belong to <b>{{domain.domain.name}}</b> it will be skipped.</label>
<textarea class="form-control" id="importSubdomainFormControlTextarea" rows="7" spellcheck="false" name="importSubdomainTextArea"></textarea>
</div>
</div>
+11 -11
View File
@@ -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()
+2 -2
View File
@@ -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(`<span class="badge badge-danger">${data.length}</span>`);
$('#interesting_subdomain_count_badge').html(`<span class="badge outline-badge-danger">${data.length}</span>`);
});
$.getJSON(`../api/listInterestingEndpoints/?scan_id=${scan_id}&no_page`, function(data) {
$('#interesting_endpoint_count_badge').empty();
$('#interesting_endpoint_count_badge').html(`<span class="badge badge-danger">${data.length}</span>`);
$('#interesting_endpoint_count_badge').html(`<span class="badge outline-badge-danger">${data.length}</span>`);
});
}
+11 -11
View File
@@ -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
@@ -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',
),
]
+3 -3
View File
@@ -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
@@ -12,16 +12,16 @@
<div class="form-row">
<div class="col-md-6 mb-4">
<label for="domainName">Domain name</label>
{{ form.domain_name }}
{{ form.name }}
{% if form.errors %}
<div class="invalid-feedback" style="display: block;">
{{ form.errors.domain_name|striptags }}
{{ form.errors.name|striptags }}
</div>
{% endif %}
</div>
<div class="col-md-6 mb-4">
<label for="domainDescription">Description</label>
{{ form.domain_description }}
{{ form.description }}
</div>
</div>
<button class="btn btn-primary submit-fn mt-2 float-right" type="submit">{{button_title}}</button>
+6 -6
View File
@@ -24,22 +24,22 @@ Import Targets
</div>
</div>
<div class="widget-content widget-content-area animated-underline-content">
<ul class="nav nav-tabs mb-3" id="animateLine" role="tablist">
<ul class="nav nav-tabs mb-3" id="animateLine" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="animated-underline-home-tab" data-toggle="tab" href="#animated-underline-text" role="tab" aria-controls="animated-underline-home" aria-selected="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg> .txt import</a>
<a class="nav-link active" id="animated-underline-txt-tab" data-toggle="tab" href="#animated-underline-text" role="tab" aria-controls="animated-underline-text" aria-selected="true"> Import from Text File</a>
</li>
<li class="nav-item">
<a class="nav-link" id="animated-underline-profile-tab" data-toggle="tab" href="#animated-underline-csv" role="tab" aria-controls="animated-underline-profile" aria-selected="false"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-user"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg> .csv import</a>
<a class="nav-link" id="animated-underline-csv-tab" data-toggle="tab" href="#animated-underline-csv" role="tab" aria-controls="animated-underline-csv" aria-selected="false"> Import from CSV</a>
</li>
</ul>
<div class="tab-content" id="animateLineContent-4">
<div class="tab-pane fade show active" id="animated-underline-text" role="tabpanel" aria-labelledby="animated-underline-home-tab">
<div class="tab-pane fade show active" id="animated-underline-text" role="tabpanel" aria-labelledby="animated-underline-txt-tab">
<div class="mb-4">
<p class="text-warning">
*Your txt file must have list of domains seperated by new line.
<br><br>
By default all domains imported from txt will have no description. If you choose to import multiple domains with description, you should go for csv import.
By default all domains imported from txt will have no description. If you choose to import multiple domains with description, csv import is recommended.
</p>
<form method="post" enctype="multipart/form-data">
<div class="custom-file">
@@ -51,7 +51,7 @@ Import Targets
</form>
</div>
</div>
<div class="tab-pane fade" id="animated-underline-csv" role="tabpanel" aria-labelledby="animated-underline-profile-tab">
<div class="tab-pane fade" id="animated-underline-csv" role="tabpanel" aria-labelledby="animated-underline-csv-tab">
<div class="mb-4">
<p class="text-warning">
*Your csv file must be in the format of <strong>domain, description</strong> seperated by new line.
+3 -3
View File
@@ -54,8 +54,8 @@ List all Target for Recon
{% for domain in domains.all %}
<tr>
<td class="checkbox-column"> {{ domain.id }} </td>
<td>{{ domain.domain_name }}</td>
<td>{{ domain.domain_description }}</td>
<td>{{ domain.name }}</td>
<td>{{ domain.description }}</td>
<td>{{ domain.insert_date }}</td>
{% if domain.start_scan_date %}
<td class="text-center">{{domain.start_scan_date}}</td>
@@ -77,7 +77,7 @@ List all Target for Recon
<path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path>
</svg>
</a>
<a onclick="delete_target({{ domain.id }}, '{{ domain.domain_name }}')" class="bs-tooltip btnDelDomain" href="#" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete target">
<a onclick="delete_target({{ domain.id }}, '{{ domain.name }}')" class="bs-tooltip btnDelDomain" href="#" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete target">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather table-delete feather-x-circle">
<circle cx="12" cy="12" r="10"></circle>
<line x1="15" y1="9" x2="9" y2="15"></line>
+7 -7
View File
@@ -4,7 +4,7 @@
{% load custom_tags %}
{% load mathfilters %}
{% block title %}
Target Summary for {{target.domain_name}}
Target Summary for {{target.domain.name}}
{% endblock title %}
{% block custom_js_css_link %}
@@ -23,7 +23,7 @@ Target Summary for {{target.domain_name}}
{% endblock custom_js_css_link %}
{% block breadcrumb_title %}
Target Summary for {{target.domain_name}}
Target Summary for {{target.name}}
{% endblock breadcrumb_title %}
@@ -54,7 +54,7 @@ Target Summary for {{target.domain_name}}
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="scanHistoryModalLabel">Scans initiated for {{target.domain_name}}</h5>
<h5 class="modal-title" id="scanHistoryModalLabel">Scans initiated for {{target.name}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
@@ -142,7 +142,7 @@ Target Summary for {{target.domain_name}}
{% endif %}
</div>
<br>
<a href="javascript:window.location='../../start_scan/all/subdomains?query={{target.domain_name}}';" class="text-info">View all Subdomains</a>
<a href="javascript:window.location='../../start_scan/all/subdomains?query={{target.name}}';" class="text-info">View all Subdomains</a>
</div>
</div>
</div>
@@ -173,7 +173,7 @@ Target Summary for {{target.domain_name}}
&nbsp;
{% endif %}
</div>
<a href="javascript:window.location='../../start_scan/detail/endpoint?query={{target.domain_name}}';" class="text-info">View all Endpoints</a>
<a href="javascript:window.location='../../start_scan/detail/endpoint?query={{target.name}}';" class="text-info">View all Endpoints</a>
</div>
</div>
</div>
@@ -207,7 +207,7 @@ Target Summary for {{target.domain_name}}
<br>
{% endif %}
</div>
<a href="javascript:window.location='../../start_scan/detail/vuln?query={{target.domain_name}}';" class="text-info">View all Vulnerabilities</a>
<a href="javascript:window.location='../../start_scan/detail/vuln?query={{target.name}}';" class="text-info">View all Vulnerabilities</a>
</div>
</div>
</div>
@@ -407,7 +407,7 @@ Target Summary for {{target.domain_name}}
</div>
</div>
<div class="t-name">
<h4>{{item.domain_name}}</h4>
<h4>{{item.name}}</h4>
<p class="meta-date">{{item.start_scan_date|naturaltime}}</p>
</div>
+15 -15
View File
@@ -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)
+2 -2
View File
@@ -14,7 +14,7 @@
</polygon>
</svg>
</div>
<span id="interesting_subdomain_count_badge"><span class="spinner-border text-danger align-self-center loader-sm "></span></span> Interesting Subdomains
<span id="interesting_subdomain_count_badge"><span class="spinner-border text-danger align-self-center loader-sm"></span></span> Interesting Subdomains
<div class="icons text-info">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg>
</div>
@@ -41,7 +41,7 @@
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
</svg>
</div>
<span id="interesting_endpoint_count_badge"><span class="spinner-border text-danger align-self-center loader-sm "></span></span> Interesting Endpoints
<span id="interesting_endpoint_count_badge"><span class="spinner-border text-danger align-self-center loader-sm"></span></span> Interesting Endpoints
<div class="icons text-info">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg>
</div>