Skip to content

Commit

Permalink
finished the first version of the technical support helper
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Oct 30, 2020
1 parent d12880c commit c678383
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 41 deletions.
208 changes: 176 additions & 32 deletions helper/tools/templates/console_result.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@ <h1 class="display-4" style="text-transform: uppercase;">{{domain}}</h1>
<div class="grid">
<div class="row">
<div class="col">
<p class="lead" style="background-color: #5BFC2B; padding: 0.7rem 0.7rem; border: 1px solid black; border-radius: 6%;"><strong>Estado: </strong>Registrado</p>
</div>
<div class="col">
<p class="lead" style="padding: 0.7rem 0.7rem; border: 1px solid black; border-radius: 6%;"><strong>Fecha de vencimiento: </strong>{{domainInfo.events.expiration_date}}</p>
<p class="lead" style="background-color: #5BFC2B; padding: 0.7rem 0.7rem; border: 1px solid black; border-radius: 6%;"><strong>Registrado</strong></p>
</div>
</div>
</div>
{% else %}
<div class="grid">
<div class="row">
<div class="col">
<p class="lead" style="background-color: red; padding: 0.7rem 0.7rem; border: 1px solid black; border-radius: 6%;"><strong>Estado: </strong>Vencido</p>
</div>
<div class="col">
<p class="lead" style="padding: 0.7rem 0.7rem; border: 1px solid black; border-radius: 6%;"><strong>Fecha de vencimiento: </strong> - </p>
<p class="lead" style="background-color: red; padding: 0.7rem 0.7rem; border: 1px solid black; border-radius: 6%;"><strong>Vencido o Dudoso</strong></p>
</div>
</div>
</div>
Expand All @@ -41,42 +35,191 @@ <h1 class="display-4" style="text-transform: uppercase;">{{domain}}</h1>

{% block content %}
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="card-title">Ping</h5>
<p class="card-text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Id officia veritatis voluptates eveniet natus. Eius earum deleniti quis nobis tempore dolorum consequuntur aliquid eveniet perferendis maxime. Numquam delectus soluta iste.</p>
<div class="grid">
<div class="row">
<!--PING DOMINIO-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">PING DEL DOMINIO</h5>
<ul class="list-group">
{% for ping in domainInfo.domain_ping %}
<li class="list-group-item">{{ping}}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="card-title">DNS</h5>
<p class="card-text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Id officia veritatis voluptates eveniet natus. Eius earum deleniti quis nobis tempore dolorum consequuntur aliquid eveniet perferendis maxime. Numquam delectus soluta iste.</p>
<br>
{% if domainInfo.subdomain_ping %}
<div class="row">
<!--PING SUBDOMINIO-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">PING DEL SUBDOMINIO</h5>
<ul class="list-group">
{% for ping in domainInfo.subdomain_ping %}
<li class="list-group-item">{{ping}}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="card-title">Informacion acerca del dominio</h5>
<p class="card-text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Id officia veritatis voluptates eveniet natus. Eius earum deleniti quis nobis tempore dolorum consequuntur aliquid eveniet perferendis maxime. Numquam delectus soluta iste.</p>
<br>
{% endif %}
<div class="row">
<!--DNS-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">DNS</h5>
<ul class="list-group">
{% for dns in domainInfo.nameservers %}
<li class="list-group-item">{{dns}}</li>
{% endfor %}
</ul>
</div>
</div>
</div>

<!--EVENTOS-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">EVENTOS</h5>
<ul class="list-group">
<li class="list-group-item">Fecha de vencimiento: {{domainInfo.events.expiration_date}}</li>
<li class="list-group-item">Fecha de creacion: {{domainInfo.events.creation_date}} </li>
<li class="list-group-item">Fecha de actualizacion: {{domainInfo.events.last_date}} </li>
</ul>
</div>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="card-title">Eventos</h5>
<p class="card-text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Id officia veritatis voluptates eveniet natus. Eius earum deleniti quis nobis tempore dolorum consequuntur aliquid eveniet perferendis maxime. Numquam delectus soluta iste.</p>

<br>

<div class="row">

<!--SUBDOMINIO-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">SUBDOMINIO</h5>
<ul class="list-group">
{% if domainInfo.subdomain %}
<li class="list-group-item">{{domainInfo.subdomain}}</li>
{% else %}
<li class="list-group-item">Sin subdominio</li>
{% endif %}
</ul>
</div>
</div>
</div>

<!--DOMINIO-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">DOMINIO</h5>
<ul class="list-group">
{% if domainInfo.domain %}
<li class="list-group-item">{{domainInfo.domain}}</li>
{% else %}
<li class="list-group-item">Sin dominio</li>
{% endif %}
</ul>
</div>
</div>
</div>

<!--SUFIJO-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">SUFIJO</h5>
<ul class="list-group">
{% if domainInfo.suffix %}
<li class="list-group-item">{{domainInfo.suffix}}</li>
{% else %}
<li class="list-group-item">Sin sufijo</li>
{% endif %}
</ul>
</div>
</div>
</div>
</div>
<br>
<div class="row">

<!--DATOS DEL TITULAR-->
<div class="col">
<div class="card bg-secondary text-center">
<h5 class="card-title" style="color: white;">DATOS SOBRE EL TITULAR</h5>
<div class="card-body">
<ul class="list-group">
{% if domainInfo.status %}
<li class="list-group-item" style="color: green;"> <strong>Estado del dominio: </strong>Activo</li>
{% else%}
<li class="list-group-item"> <strong>Estado del dominio: </strong>Dudoso</li>
{% endif%}
<li class="list-group-item"> <strong>Entidad registrante: </strong>{{domainInfo.extra_data.entity}}</li>
<li class="list-group-item"> <strong>Cuit: </strong>{{domainInfo.extra_data.cuit}}</li>
<li class="list-group-item"> <strong>Nombre del titular: </strong>{{domainInfo.extra_data.name}}</li>
</ul>
</div>
</div>
</div>
</div>

<br>

<!--REGISTROS-->
<div class="row">
<!--REGISTROS A-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">REGISTRO TIPO A DOMINIO</h5>
<ul class="list-group">
{% for A in domainInfo.nslookup.A %}
<li class="list-group-item">{{A}}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
<!--REGISTROS A DNS-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">REGISTRO TIPO A DNS</h5>
<ul class="list-group">
{% for ADNS in domainInfo.nslookup.A_DNS %}
<li class="list-group-item">{{ADNS}}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
<!--REGISTROS MX-->
<div class="col">
<div class="card bg-secondary text-center">
<div class="card-body">
<h5 class="card-title" style="color: white;">REGISTRO TIPO MX</h5>
<ul class="list-group">
{% for MX in domainInfo.nslookup.MX %}
<li class="list-group-item">{{MX}}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>

</div>
<div class="container">
<div class="row">
Expand All @@ -87,6 +230,7 @@ <h5 class="card-title">Eventos</h5>
</div>
</div>
</div>
<br>
</div>

{% endblock content %}
24 changes: 15 additions & 9 deletions helper/tools/utils/discoverer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ def get_rdap_events(self, json_data):
try:
for event in json_data['events']:
if event['eventAction'] == 'registration':
eventData['creation_date'] = event['eventDate']
eventData['creation_date'] = self.unicode_to_datetime(event['eventDate'])

if event['eventAction'] == 'expiration':
eventData['expiration_date'] = event['eventDate']
eventData['expiration_date'] = self.unicode_to_datetime(event['eventDate'])

if event['eventAction'] == 'last update of RDAP database':
eventData['last_date_rdap'] = event['eventDate']
eventData['last_date_rdap'] = self.unicode_to_datetime(event['eventDate'])

if event['eventAction'] == 'last changed':
eventData['last_date'] = event['eventDate']
eventData['last_date'] = self.unicode_to_datetime(event['eventDate'])

except Exception as Error:
print("[DomainDiscover] - get_rdap_events\n%s" % Error)
Expand Down Expand Up @@ -113,8 +113,13 @@ def ping(self, domain):
else:
param = "-c"

command = subprocess.check_output(['ping', param, '5', domain])
command = subprocess.check_output(['ping', param, '4', domain])
result = "".join(command).split('\n')
print(len(result))
result.pop(-1)
result.pop(-1)
result.pop(-3)
print(len(result))
except Exception as Error:
print("[DomainDiscover] - ping\n%s" % Error)

Expand Down Expand Up @@ -157,7 +162,7 @@ def nslookup(self, domain, nameservers=None):
domain_data = {
'A' : None,
'MX' : None,
'A-DNS' : None,
'A_DNS' : None,
}
a_records = []
mx_records = []
Expand Down Expand Up @@ -186,7 +191,7 @@ def nslookup(self, domain, nameservers=None):
nameserver_a = dns.resolver.query(str(nameserver),'A')
for ADNS in nameserver_a:
a_dns_records.append(ADNS)
domain_data['A-DNS'] = a_dns_records
domain_data['A_DNS'] = a_dns_records

except Exception as Error:
print("[DomainDiscover] - nslookup\n%s" % Error)
Expand Down Expand Up @@ -216,22 +221,23 @@ def discover(self, domain):
has_subdomain = self.get_subdomain(domain)
if has_subdomain:

_subdomain = self.get_subdomain(domain)
domain_data['subdomain_ping'] = self.ping(domain)
domain_data['subdomain'] = _subdomain

domain = domain.replace("%s." % has_subdomain,'')

json_data = self.rdap_data_provider(domain)

if json_data['status']:
_domain = self.get_domain(domain)
_subdomain = self.get_subdomain(domain)
_suffix = self.get_suffix(domain)
_ping = self.ping(domain)
_dns = self.get_nameservers(json_data=json_data['response']['data'])
_events = self.get_rdap_events(json_data=json_data['response']['data'])
_extra_data = self.get_information(domain, json_data)

domain_data['domain'] = _domain
domain_data['subdomain'] = _subdomain
domain_data['suffix'] = _suffix
domain_data['domain_ping'] = _ping
domain_data['events'] = _events
Expand Down
15 changes: 15 additions & 0 deletions helper/tools/utils/utils_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,19 @@ def rdap_data_provider(self, domain):
return rdap_data


# @params Datetime STR
def unicode_to_datetime(self, date):
""" receive a datetime value as a strign and return it as a datetime """

try:
if date:
date = datetime.strptime(date.replace("T",' ').replace("Z", ''), "%Y-%m-%d %H:%M:%S").strftime("%d-%m-%Y %H:%M:%S")
except Exception as Error:
print "[%12s] %5s %5s %5s" % (
datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
'[FAIL]',
'[unicode_to_datetime]',
Error.__str__(),
)
return date

0 comments on commit c678383

Please sign in to comment.