InfoSec Forums InfoSec Forums Programming Convert Host/Domain Name to IP Address on Python

This topic contains 1 reply, has 2 voices, and was last updated by  cyber ghost 1 month, 3 weeks ago.

  • Author
  • #3797

    • Topics:11
    • Comments:7
    • Newbie

    Here is simple python code for converting a domain to IP Address


    import socket
    import urlparse
    def getIp(domain):
          trytime = 0
          while True:
                          domain = domain.split(‘:’)[0]
                          myaddr = socket.getaddrinfo(domain,None)[0][4][0]
                          return myaddr
                          if trytime>3:
                          return “”

    if __name__==’__main__’:
           www = “”
           hosts = urlparse.urlsplit(www)
           if “:” in hosts.netloc:
                 host = hosts.netloc.split(“:”)[0]
                 port = hosts.netloc.split(“:”)[1]
                 host = hosts.netloc
                 port = ’80’
                 print getIp(host)

  • #4016

    cyber ghost
    • Topics:1
    • Comments:12
    • Newbie

    Hello sir , I am kavish tyagi

    I have a question that I am beginners in pentesting and I am not good in Linux command so should you give m a way or prefer any book or something else by which I understand or learn the commands of Linux or Kali Linux .

    Plzzzzzz sir and sir thanku very much for sharing your knowledge with us thanku very much

    Waiting for postive reply sir..

You must be logged in to reply to this topic.