I have the following PHP code that writes accepted
to a file named text.txt only if the IP is equal to 127.0.0.1 (loopback). If the IP doesn't match it writes denied
.
<?php
$file = fopen('text.txt' , 'a');
if($_SERVER['REMOTE_ADDR'] === '127.0.0.1') {
$request = $_GET['output'];
if($request === '123') {
fwrite($file, "\x0D\x0A".'accepted - ' .$_SERVER['REMOTE_ADDR']);
}
}
else {
fwrite($file, "\x0D\x0A".'denied - ' .$_SERVER['REMOTE_ADDR']);
}
?>
Can I send the get request (www.example.com/get.php?output=123) from an external network with a spoofed IP of 127.0.0.1? If it is possible, how can I do it? If not, why?