diff --git a/web/api/views.py b/web/api/views.py index b021c38f..81cc40b2 100644 --- a/web/api/views.py +++ b/web/api/views.py @@ -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, diff --git a/web/startScan/static/startScan/js/detail_scan.js b/web/startScan/static/startScan/js/detail_scan.js index aa4615e8..2291b893 100644 --- a/web/startScan/static/startScan/js/detail_scan.js +++ b/web/startScan/static/startScan/js/detail_scan.js @@ -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(); + } + }); + }); +} diff --git a/web/startScan/templates/startScan/detail_scan.html b/web/startScan/templates/startScan/detail_scan.html index 029cf819..c7659bc5 100644 --- a/web/startScan/templates/startScan/detail_scan.html +++ b/web/startScan/templates/startScan/detail_scan.html @@ -311,6 +311,9 @@ Scan Findings
| Type | +Hostname | +Address | +TTL | +Class | +Preference | + + + {% for nameserver in history.domain.domain_info.nameserver_record.all %} +
| {{ nameserver.type}} | +{{nameserver.hostname}} | +{{nameserver.address}} | +{{nameserver.ttl}} | +{{nameserver.ns_class}} | +{% if nameserver.preference %}{{nameserver.preference}}{% endif %} | +