1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| #!/usr/bin/python
# -*-coding:UTF-8 -*-
import os,dns,dns.resolver,geocoder, socket, urllib
from pierky.ipdetailscache import IPDetailsCache
def contenu():
try:
name = socket.gethostbyname(QUERY['valeur']) # Convert the site web name in address ip x.x.x.x
cache = IPDetailsCache() #call the Class 'IPDetailsCache()'
r = cache.GetIPInformation(name) #use the 'GetIPInformation()' methods
print("<b>adresse IPV4</b> : {0}".format(name)) # show the website ip
print("<br><br><br><b>ASN informations</b>:<br>") # show ASN informations
for cle, valeur in r.items(): #select the items methods for show 'cle and valeur' values in boucle
print cle,":",valeur
print("<br><br><br><br><b>Localisation</b>:<br>")
try:
i = geocoder.maxmind(name)
a = i.json
for local, loac in a.items():
print local,":",loac
except:
print ("Donnees de localisation non trouve"
"<br>Veuillez ressayer <a href='/audit'>ici</a> SVP!")
print("<br><br><br><br><b>Mails Server</b>:<br>")
try:
reponse = dns.resolver.query((QUERY['valeur']), 'MX') #the variable 'reponse' contains the value MX of dns server
for rdata in reponse:
print"mail server:", (rdata.exchange) # show the server mail
except:
print ("Aucun serveur Mail trouve"
"<br>Veuillez ressayer <a href='/audit'>ici</a> SVP!")
print("<br><br><br><br><b>Dns Server</b>:<br>")
contenu = dns.resolver.query((QUERY['valeur']), 'NS') # the variable 'contenu' contains the value NS of dns server
for resultat in contenu:
print"seveurs DNS:", (resultat) # show all name servers dns
print("<br><br><br><b>Whois gathering</b>:<br>")
try:
command = "whois" + " " + (QUERY['valeur'])
process = os.popen(command)
results = str(process.read())
print results
except:
print ("Aucun serveur Whois trouve"
"<br>Veuillez ressayer <a href='/audit'>ici</a> SVP!")
except socket.gaierror:
print("Connexion echoue, URL non valide ou verifier votre configuration reseau<br>"
"<br>Veuillez entrer une URL valide <a href='/audit'>ici</a> SVP!")
print("<p>"
"<center><input type = 'submit' style='background-color: #34C924;' style='text-align: center;' "
"style='font-weight: bold;' value = 'TELECHARGER'"
"style='width:120px; height:50px'> </center>"
"</p>")
def save_file():
with open ("/opt/data.csv", "w") as f:
txt = (QUERY['valeur'])
source = urllib.urlopen("http://127.0.0.1:4080/findme.py?valeur={0}".format(txt))
f.write(source.read())
contenu()
save_file() |
Partager