Follow us on Twitter!
Capitalism is an Island of wealth in a sea of poverty
Sunday, April 20, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 33
Guests Online: 30
Members Online: 3

Registered Members: 82843
Newest Member: hx47
Latest Articles

Obtaining a visitors IP adress

Arrow Image Here is some PHP code on getting a visitors ip adress



ok i had some problems the other day with someone using a email spoofer i created in php against me. My page originally wasnt able to get the ip of visitors to the page so i had no way of tracking them down.

Recently though one of my friends created this bit of code and now the ip adresses of all people who visit the page will be stored in a text file in the directory.

Here is the code:
<?
$ipFile = "ip.txt"; // text file that stores IP addresses
$fp_ips = fopen($ipFile, "r"); // Open the file
$ip = fgets($fp_ips, 20); // Get the IPs stored already
fclose($fp_ips); // close the file
$fp_ips = fopen($ipFile, "a"); // open it again so we start at line 0 (first one)
fputs($fp_ips, $REMOTE_ADDR . "\r\n"); // add the visiting IP address + carriage return + new line
fclose($fp_ips); // close the file
?>

Its pretty self explanatory, with the //comments there.

So what you need to do to get this to work though, is create a text document ip.txt and set both this page and the ip.txt page to chmod 777 so it can be written to.

Thats pretty much it and i hope you find this useful.
Im just awaiting the moment the person uses my page again so i can nail them.

Please vote and leave comments. Thanks
-Frozen Flame

Comments

N2Christon September 11 2005 - 04:52:33
great code! hope you catch them =D
Darth_Pengoon September 22 2005 - 10:53:04
See, I've done code like that then but i also made it log their visit like how long they stay but great code btw the commens make it look messy i was like oO whats wrong with this guy
Frozen Flameon September 23 2005 - 04:20:35
lol sorry about that. just trying to make it easily understandable what everything does. thanks for the comments btw
Fauceton March 22 2006 - 02:30:45
Umm what do you mean by "set both this page and the ip.txt page to chmod 777 so it can be written to" Does ip.txt have to be empty, and what is chmod777. New to this.
SwiftNomadon March 22 2006 - 22:25:11
I hope you can find them and this is a good example of something simple. =)
system_meltdownon May 13 2006 - 19:02:15
Nice article
Jakeon May 16 2006 - 03:20:47
Faucet, when you chmod to 777, you give all permissions on a folder (read/write/execute). This can be done by right clicking the file and clicking properties. However, if you are using windows, don't worry about it since it is insecure and will let you write to the file even if you shouldn't have permission to. Frozen Flame: The code is pretty good for beginners, but to optimize it so it runs faster and only has to open the file once, I would simply do -
Code
<?php $fp = fopen('ip.txt', 'a+'Wink;   fputs($fp, $_SERVER['REMOTE_ADDR']."\r\n"Wink;   fclose($fp); ?>


a+ means it will open the file for reading and writing, the a stands for 'append' and it is better to use the longer version for IP because not all servers have the shorthand enabled.
Jakeon May 16 2006 - 03:21:25
Stupid UBB screwed up the code. . . should still work though, just insert line breaks after the ';' to make it look nice.
s0l1dsnak3123on October 30 2006 - 19:56:09
erm... this might be a noobish comment, but all I get in ip.txt is 'rn' - why? where is the IP?
123TommY321on March 01 2008 - 17:18:52
pretty nice code Wink
Post Comment

Sorry.

You must have completed the challenge Basic 1 and have 100 points or more, to be able to post.