External IP Address Lookup Service

As a penetration testing having the ability to easily preform an internet facing or external IP address lookup is very important. Weather you end up on a box in a clients DMZ or you just need to set up that handler for your social engineering engagement, being able to quickly get the IP makes things a lot easier. I for one, like to do a great deal of automation and I’ve used several of these external IP address lookup services over the years. However, as I’m sure many people are aware, these services some and go like the wind.

One of my favorites that I’ve come to relay on over the years is ifconfig.me. Not only did this external ip address lookup service have some of the coolest domain names ever, but it also responded very quickly via the terminal with just the IP; while offering additionally information if you viewed the web page directly. Needless to say, I kinda just fell in love and mindlessly used its services for over a year.

Sadly ifconfig.me and several other external IP address lookup services have since slowed to a crawl or been shutdown. Likely because they begin to receive heavy traffic once they take off and generate little to no revenue for the host. Nevertheless, I’ve decided that instead of finding a new external ip address lookup service to fall in love with, I would just piggy back off my blog to release my own simple version of the site. My goal being, to maintain the external IP address lookup service, via the terminal, that I’ve come accustom to using for scripting and automation.

So without further a due I give you hackersvanguard.com/ip.php, your one stop stop for external ip address lookup. I know some people like be wondering why the heck they would ever trust me so I’ve included the complete source code bellow.

 

<?php
function getIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check to see if the ip is internal
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //check and to if the ip is being properly proxied
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR']; //else use the value given in the remote ip address header
}
return $ip;
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.