Aug-08-2019, 06:51 PM
hello all ...
i have a list of ip's range for a websites in the server .... i try to get the domain name from ip i used python requests lib. to grep get the HEAD and then grep the location ... it's work in some cases but not all .. this is my code :
i have a list of ip's range for a websites in the server .... i try to get the domain name from ip i used python requests lib. to grep get the HEAD and then grep the location ... it's work in some cases but not all .. this is my code :
x = "194.187.80.65" url = ("http://" + x) try: r = requests.head(url,timeout=1) if r.status_code == 403: print("[~] 403 Forbidden -- " , url + "\n") if r.status_code == 401: print("[~]401 Unauthorized -- Maybe it's a control panel protected by Firewall ( check it manually ) ! " , url + "\n") else: qan = (f"\n[+]Testing : {url}\t (Y)\t OK\t\t : " + url + " [!]INFO : ") dd =(r.headers) print(Fore.GREEN + qan + str(dd) + "\n") except requests.exceptions.HTTPError as errh: print ("Http Error:",errh) except requests.exceptions.ConnectionError as errc: print (Fore.RED + f"[-]Testing : {url}\t (N) \t Error Connecting: " + url ) except requests.exceptions.Timeout as errt: print ("Timeout Error:",errt) except requests.exceptions.RequestException as err: print ("OOps: Something Else",err)
Output:http://194.187.80.65 [!]INFO : {'Expires': '0', 'Cache-Control': 'no-cache', 'X-Powered-By': 'JSP/2.3, JSP/2.3', 'Set-Cookie': 'JSESSIONID=3GkFeBQdOxugDl9x5sWx5nZH6qbUSCX1MJqtLEZu.alumni; path=/', 'Pragma': 'no-cache', 'Date': 'Thu, 08 Aug 2019 19:05:04 GMT', 'Connection': 'keep-alive', 'Content-Type': 'text/html;charset=UTF-8', 'Content-Length': '57530'}
and i try this code : import socket socket.gethostbyaddr("194.187.80.65")
Output:socket.gethostbyaddr("194.187.80.65")
socket.herror: [Errno 11004] host not found
how to do that !! i need it to return the domain name : alumni.qou.edu