Added NS Records

This commit is contained in:
Yogesh Ojha
2022-04-24 22:57:31 +05:30
parent 6f9516cd86
commit 3910562ace
5 changed files with 152 additions and 4 deletions
+78 -2
View File
@@ -135,7 +135,7 @@ class Whois(APIView):
registrant.save()
whois_model = WhoisDetail()
whois_model.details = whois if whois else Noen
whois_model.details = whois if whois else None
whois_model.registrant = registrant
whois_model.save()
@@ -161,6 +161,81 @@ class Whois(APIView):
domain.domain_info = domain_info
domain.save()
ns_records = []
for i in range(4):
ns_records_xpath = tree.xpath("//*[@id='divDNSRecords']/table[{}]/tbody/tr".format(i))
for table_row in ns_records_xpath:
row = table_row.xpath('td/text()')
if row[0] == 'A':
# for getting address, use child lookup
address = table_row.xpath('td/a/text()')
address = address[0] if address else None
ns_records.append(
{
'type': row[0],
'hostname': row[1],
'address': address,
'ttl': row[2],
'class': row[3],
}
)
if save_db and Domain.objects.filter(name=ip_domain).exists():
ns = NSRecord()
ns.type = row[0]
ns.hostname = row[1]
ns.address = address
ns.ttl = row[2]
ns.ns_class = row[3]
ns.save()
domain_info.nameserver_record.add(ns)
elif row[0] == 'AAAA':
# for getting address, use child lookup
ns_records.append(
{
'type': row[0],
'hostname': row[1],
'address': row[2],
'ttl': row[3],
'class': row[4],
}
)
if save_db and Domain.objects.filter(name=ip_domain).exists():
ns = NSRecord()
ns.type = row[0]
ns.hostname = row[1]
ns.address = row[2]
ns.ttl = row[3]
ns.ns_class = row[4]
ns.save()
domain_info.nameserver_record.add(ns)
elif row[0] == 'MX':
ns_records.append(
{
'type': row[0],
'hostname': row[1],
'address': row[2],
'preference': row[3],
'ttl': row[4],
'class': row[5],
}
)
if save_db and Domain.objects.filter(name=ip_domain).exists():
ns = NSRecord()
ns.type = row[0]
ns.hostname = row[1]
ns.address = address
ns.preference = row[3]
ns.ttl = row[4]
ns.ns_class = row[5]
ns.save()
domain_info.nameserver_record.add(ns)
return Response({
'status': True,
@@ -173,7 +248,8 @@ class Whois(APIView):
'geolocation_iso': geolocation_iso,
},
'nameserver': {
'history': dns_history
'history': dns_history,
'records': ns_records
},
'registrant': {
'name': name,
@@ -179,8 +179,8 @@ function get_endpoints(scan_history_id, gf_tags){
}
});
$('#endpoint-search-button').click(function () {
endpoint_table.search($('#endpoints-search').val()).draw() ;
});
endpoint_table.search($('#endpoints-search').val()).draw() ;
});
}
function get_subdomain_changes(scan_history_id){
@@ -1361,3 +1361,25 @@ function download_endpoints(scan_id, domain_name, pattern){
$('#modal-loader').empty();
});
}
function fetch_whois(domain_name){
$('[data-toggle="tooltip"]').tooltip('hide');
Snackbar.show({
text: 'Fetching WHOIS...',
pos: 'top-right',
duration: 1500,
});
fetch(`/api/tools/whois/?format=json&ip_domain=${domain_name}&save_db`, {}).then(res => res.json())
.then(function (response) {
Snackbar.show({
text: 'Whois Fetched...(Click to reload)',
pos: 'top-right',
duration: 3000,
actionText: 'Reload',
onActionClick: function(element) {
location.reload();
}
});
});
}
@@ -311,6 +311,9 @@ Scan Findings
<div class="col-xl-7 col-lg-7 col-12">
<div class="card" style="height: 95%">
<div class="card-body">
<div class="card-widgets">
<a href="javascript: fetch_whois('{{history.domain}}');" data-toggle="tooltip" title="Reload Whois, Page needs to be refreshed!"><i class="mdi mdi-refresh"></i></a>
</div>
<h4 class="header-title mb-0"><i class="fe-activity"></i>&nbsp;Target Information</h4>
<div class="row mt-3">
<div class="col-sm-3">
@@ -400,6 +403,34 @@ Scan Findings
No DNS history records found.
{% endif %}
</div>
<div class="tab-pane fade" id="v-pills-nameserver" role="tabpanel" aria-labelledby="v-pills-nameserver-tab" data-simplebar style="max-height: 300px; min-height: 300px;">
{% if history.domain.domain_info.nameserver_record.all %}
<table class="table table-striped mb-0">
<thead class="table-dark">
<td>Type</td>
<td>Hostname</td>
<td>Address</td>
<td>TTL</td>
<td>Class</td>
<td>Preference</td>
</thead>
<tbody>
{% for nameserver in history.domain.domain_info.nameserver_record.all %}
<tr>
<td><span class="badge badge-soft-primary me-1 ms-1">{{ nameserver.type}}</span></td>
<td>{{nameserver.hostname}}</td>
<td>{{nameserver.address}}</td>
<td>{{nameserver.ttl}}</td>
<td>{{nameserver.ns_class}}</td>
<td>{% if nameserver.preference %}{{nameserver.preference}}{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
No DNS history records found.
{% endif %}
</div>
</div>
</div>
</div>
@@ -0,0 +1,18 @@
# Generated by Django 3.2.4 on 2021-10-30 16:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('targetApp', '0008_nsrecord'),
]
operations = [
migrations.AddField(
model_name='domaininfo',
name='nameserver_record',
field=models.ManyToManyField(to='targetApp.NSRecord'),
),
]
+1
View File
@@ -52,6 +52,7 @@ class DomainInfo(models.Model):
is_private = models.BooleanField(default=False)
whois = models.ForeignKey(WhoisDetail, on_delete=models.CASCADE, null=True, blank=True)
nameserver_history = models.ManyToManyField(NameServerHistory)
nameserver_record = models.ManyToManyField(NSRecord)
def __str__(self):
return self.whois.registrant.name