Thread: Enter domain, receieve the IP of it.

Results 1 to 8 of 8
  1. #1 Enter domain, receieve the IP of it. 
    MybGod
    Guest
    This will add a little form to your site.
    Just fill in the domain field and click 'Check' and it will output the IP of the site.
    Might be useless, but because of making this I weren't bored any more

    [PHP]<?php
    if ($_POST['sub_address'] && $_POST['address'])
    {
    $ip_address = gethostbyname($_POST['address']);
    if ($ip_address == $_POST['address'])
    echo "Invalid domain or the IP couldn't be found.";
    else
    echo "<b>" . $_POST['address'] . "</b>'s IP is: " . $ip_address;
    }

    echo "<hr>

    <form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">
    <b>Domain:</b><br />
    <input type=\"text\" name=\"address\"><br />
    <input type=\"submit\" name=\"sub_address\" value=\"Check\">
    </form>

    ";
    ?> [/PHP]
    Received Infraction 
     

  2. #2  
    Vegeta
    Guest
    Lmao ty, i was actually looking for a script of this.
     

  3. #3  
    MybGod
    Guest
    You're welcome mate
     

  4. #4  
    Registered Member
    Join Date
    Nov 2006
    Posts
    699
    Thanks given
    1
    Thanks received
    31
    Rep Power
    524
    [PHP]<?php
    if(isset($_POST['sub_address']) && isset($_POST['address'])){
    $ip_address = gethostbyname($_POST['address']);
    if($ip_address == $_POST['address']){
    echo 'Invalid domain or the IP couldn\'t be found.';
    } else {
    echo '<b>'.$_POST['address'].'</b>'s IP is: '.$ip_address;
    }
    } else {
    echo '<hr>
    <form method="post" action="'.$_SERVER['PHP_SELF'].'">
    <b>Domain:</b><br />
    <input type="text" name="address"><br />
    <input type="submit" name="sub_address" value="Check">
    </form>';
    }
    ?>[/PHP]

    Due to recent changes in PHP (5.2.5), you can no longer say "if($variable)" -- you have to specify what exactly you want from $variable... so you have to instead do "if(isset($variable))".

    Also, if you ever have strictly double quotes in an echo, you should use single quotes for the echo starters.

    echo ' " " '; is a lot neater than echo ' \' \' '; ... They both work but it's just a lot nicer.

    Also, the only complication with gethostbyname() is that when you check something invalid, such as "asfawafsdfzdz.awefadfzdf", it'll return localhost, so then your script returns the webserver's IP.

    ~Z
     

  5. #5  
    MybGod
    Guest
    If it's working, I'm happy.
     

  6. #6  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,749
    Thanks given
    354
    Thanks received
    1,366
    Rep Power
    3032
    Vulnerability: Cross-Site Scripting Vulnerability

    Discoverer: super_

    Danger Level: 2/5

    Exploit: Script uses $_SERVER['PHP_SELF'], which, due to its nature, returns scriptname and any other data after it. E.g.

    if URL was [Only registered and activated users can see links. ], then PHP_SELF would be:

    file.php/lol

    Usage: /getip.php/"><script>alert("XSS")</script>

    Vulnerable code:

    [php]echo "<hr>

    <form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">
    <b>Domain:</b><br />
    <input type=\"text\" name=\"address\"><br />
    <input type=\"submit\" name=\"sub_address\" value=\"Check\">
    </form>

    "; [/php]

    Solution: Use $_SERVER['SCRIPT_NAME'] instead.

    Greetz to J33bles, Nmopal, ******, System79, PeeHPee, and T_X
     

  7. #7  
    Perceptionz
    Guest
    OR YOU COULD JUST DO THIS:

    start > run > type in: cmd and click ok

    Then type:
    ping domain.com

    it replys with an ip and there you go, a non idiotic way to do it.
     

  8. #8  
    Renown Programmer
    veer's Avatar
    Join Date
    Nov 2007
    Posts
    3,749
    Thanks given
    354
    Thanks received
    1,366
    Rep Power
    3032
    Quote Originally Posted by .Perceptionz View Post
    OR YOU COULD JUST DO THIS:

    start > run > type in: cmd and click ok

    Then type:
    ping domain.com

    it replys with an ip and there you go, a non idiotic way to do it.
    you're an idiot. best way is just to do gethostbyname() 2 use dns
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •