Python Forum
anyway to get the domain name from the ip ??
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
anyway to get the domain name from the ip ??
#1
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 :
    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
Reply


Messages In This Thread
anyway to get the domain name from the ip ?? - by evilcode1 - Aug-08-2019, 06:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  unix domain sockets Skaperen 8 4,991 Sep-02-2018, 07:02 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020