Fixed whois fetcher

This commit is contained in:
Yogesh Ojha
2022-04-24 22:57:31 +05:30
parent cc8eff3513
commit c91aae7cec
3 changed files with 45 additions and 22 deletions
@@ -1477,16 +1477,33 @@ function fetch_whois(domain_name){
pos: 'top-right',
duration: 1500,
});
$("#whois_not_fetched_alert").hide();
$("#whois_fetching_alert").show();
fetch(`/api/tools/whois/?format=json&ip_domain=${domain_name}&save_db`, {}).then(res => res.json())
.then(function (response) {
$("#whois_fetching_alert").hide();
document.getElementById('domain_age').innerHTML = response['domain']['domain_age'] + ' ' + response['domain']['date_created'];
document.getElementById('ip_address').innerHTML = response['domain']['ip_address'];
document.getElementById('ip_geolocation').innerHTML = response['domain']['geolocation'];
document.getElementById('registrant_name').innerHTML = response['registrant']['name'];
console.log(response['registrant']['organization'])
document.getElementById('registrant_organization').innerHTML = response['registrant']['organization'] ? response['registrant']['organization'] : ' ';
document.getElementById('registrant_address').innerHTML = response['registrant']['address'] + ' ' + response['registrant']['city'] + ' ' + response['registrant']['state'] + ' ' + response['registrant']['country'];
document.getElementById('registrant_phone_numbers').innerHTML = response['registrant']['tel'];
document.getElementById('registrant_fax').innerHTML = response['registrant']['fax'];
Snackbar.show({
text: 'Whois Fetched...(Click to reload)',
text: 'Whois Fetched...',
pos: 'top-right',
duration: 3000,
actionText: 'Reload',
onActionClick: function(element) {
location.reload();
}
duration: 3000
});
$("#whois_fetched_alert").show();
$("#whois_fetched_alert").fadeTo(2000, 500).slideUp(1500, function(){
$("#whois_fetched_alert").slideUp(500);
});
});
}
@@ -343,7 +343,7 @@ Detailed Scan
<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>
<a href="javascript: fetch_whois('{{history.domain}}');" data-toggle="tooltip" title="Reload Whois"><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">
@@ -358,6 +358,19 @@ Detailed Scan
<div class="col-sm-9">
<div class="tab-content pt-0">
<div class="tab-pane fade active show" id="v-pills-domain" role="tabpanel" aria-labelledby="v-pills-domain-tab" data-simplebar style="max-height: 300px; min-height: 300px;">
{% if not history.domain.domain_info %}
<div class="alert alert-danger alert-dismissible fade show" role="alert" id="whois_not_fetched_alert">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
WHOIS Record Has not been fetched, would you like to <a href="javascript: fetch_whois('{{history.domain}}');">fetch it now?</a>
</div>
{% endif %}
<div class="alert alert-info alert-dismissible fade show" role="alert" id="whois_fetching_alert" style="display: none">
Fetching WHOIS records, Please wait...
<div class="spinner-border spinner-border-sm float-end" role="status"></div>
</div>
<div class="alert alert-success alert-dismissible fade show" role="alert" id="whois_fetched_alert" style="display: none">
WHOIS Records have been fetched, please <a href="javascript:location.reload();">reload the page.</a>
</div>
<h4 class="header-title">Domain Information</h4>
<table class="domain_details_table table table-hover table-borderless">
<tr style="display: none">
@@ -370,15 +383,15 @@ Detailed Scan
</tr>
<tr>
<td>Domain age</td>
<td>{{history.domain.domain_info.domain_age}} {{history.domain.domain_info.date_created}}</td>
<td id="domain_age"></td>
</tr>
<tr>
<td>IP Address</td>
<td>{{history.domain.domain_info.ip_address}}</td>
<td id="ip_address">{{history.domain.domain_info.ip_address}}</td>
</tr>
<tr>
<td>IP Geolocation</td>
<td>{% if history.domain.domain_info.geolocation_iso %}<img src="https://domainbigdata.com/img/flags-iso/flat/24/{{history.domain.domain_info.geolocation_iso}}.png" alt="{{history.domain.domain_info.geolocation_iso}}">{% endif %} {{history.domain.domain_info.geolocation}}</td>
<td id="ip_geolocation">{% if history.domain.domain_info.geolocation_iso %}<img src="https://domainbigdata.com/img/flags-iso/flat/24/{{history.domain.domain_info.geolocation_iso}}.png" alt="{{history.domain.domain_info.geolocation_iso}}">{% endif %} {{history.domain.domain_info.geolocation}}</td>
</tr>
</table>
<h4 class="header-title mt-3">Registrant Information</h4>
@@ -389,23 +402,23 @@ Detailed Scan
</tr>
<tr>
<td>Name</td>
<td>{{history.domain.domain_info.whois.registrant.name}}</td>
<td id="registrant_name">{{history.domain.domain_info.whois.registrant.name}}</td>
</tr>
<tr>
<td>Organization</td>
<td>{{history.domain.domain_info.whois.registrant.organization}}</td>
<td id="registrant_organization">{{history.domain.domain_info.whois.registrant.organization}}</td>
</tr>
<tr>
<td>Address</td>
<td>{% if history.domain.domain_info.whois.registrant.country_iso %}<img src="https://domainbigdata.com/img/flags-iso/flat/24/{{history.domain.domain_info.whois.registrant.country_iso}}.png" alt="{{history.domain.domain_info.whois.registrant.country_iso}}">{% endif %} {{history.domain.domain_info.whois.registrant.address}} {{history.domain.domain_info.whois.registrant.City}} {{history.domain.domain_info.whois.registrant.state}} {{history.domain.domain_info.whois.registrant.country}}</td>
<td id="registrant_address">{% if history.domain.domain_info.whois.registrant.country_iso %}<img src="https://domainbigdata.com/img/flags-iso/flat/24/{{history.domain.domain_info.whois.registrant.country_iso}}.png" alt="{{history.domain.domain_info.whois.registrant.country_iso}}">{% endif %} {{history.domain.domain_info.whois.registrant.address}} {{history.domain.domain_info.whois.registrant.City}} {{history.domain.domain_info.whois.registrant.state}} {{history.domain.domain_info.whois.registrant.country}}</td>
</tr>
<tr>
<td>Phone Numbers</td>
<td>{{history.domain.domain_info.whois.registrant.phone_number}}</td>
<td id="registrant_phone_numbers">{{history.domain.domain_info.whois.registrant.phone_number}}</td>
</tr>
<tr>
<td>Fax</td>
<td>{{history.domain.domain_info.whois.registrant.fax}}</td>
<td id="registrant_fax">{{history.domain.domain_info.whois.registrant.fax}}</td>
</tr>
</table>
</div>
-7
View File
@@ -24,9 +24,6 @@ class WhoisDetail(models.Model):
details = models.TextField(blank=True, null=True)
registrant = models.ForeignKey(RegistrantInfo, on_delete=models.CASCADE, null=True, blank=True)
def __str__(self):
return self.registrant.name
class NameServerHistory(models.Model):
date = models.CharField(max_length=10, null=True, blank=True)
@@ -54,10 +51,6 @@ class DomainInfo(models.Model):
nameserver_history = models.ManyToManyField(NameServerHistory)
nameserver_record = models.ManyToManyField(NSRecord)
def __str__(self):
return self.whois.registrant.name
class Organization(models.Model):
id = models.AutoField(primary_key=True)