Hack Forums
[TUT] Logging IPs with PHP & Images - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45)
+--- Forum: Grayhat • Purple Team • Hybrid Security (https://hackforums.net/forumdisplay.php?fid=449)
+---- Forum: Beginner Hacking (https://hackforums.net/forumdisplay.php?fid=4)
+----- Forum: Hacking Tutorials (https://hackforums.net/forumdisplay.php?fid=47)
+----- Thread: [TUT] Logging IPs with PHP & Images (/showthread.php?tid=3244201)



[TUT] Logging IPs with PHP & Images - Сlassy - Feb 9, 2013

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


* - Edward H - Feb 9, 2013

Simple and easy tutorial! Thanks. :)


* - i.o.o.i - Feb 9, 2013

simple and great tutorial .Thanks for the share.


* - Turtle™ - Feb 9, 2013

Pretty nice, pretty simple, nice HQ tutorial, well explained


* - Сlassy - Feb 9, 2013

Thanks for the feedback. :)
Just remember not to use this on hackforums to keep your account from being banned. :)


* - Vlad1k - Feb 9, 2013

No need to repost the same thing 500 times.


* - Сlassy - Feb 9, 2013

(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.


* - Artisanal - Feb 9, 2013

Nice and simple tutorial 👍
Gonna be helpfull 🙂


* - N1Gh7 F0x - Feb 9, 2013

Short n nice tutorial

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


* - Сlassy - Feb 9, 2013

(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?