Local File Inclusion terjadi karena penggunaan metode GET yang digunakan ntuk menginclude atau memanggil halaman web pada halaman index/utama.
Lebih jelasnya ini adalah contoh source code yang vulnerability LFI:
echo("Home | ");
echo("Contact Us | ");
echo("Services");
if(empty($_GET[page])){
$page = "home.php";
}else{
$page = $_GET[page].".php";
}
include("$page");
Untuk menutup celah ini, modifikasi codenya menjadi:
echo("Home | ");
echo("Contact Us | ");
echo("Services");
$hal = array(
0 => "home",
1 => "contact",
2 => "services"
);
for($x=0;$x<=2;$x++){
if(empty($_GET[page])){
$page = "home.php";
include("$page");
exit;
}elseif ($_GET[page] == $hal[$x]){
$page = $_GET[page].".php";
include("$page");
exit;
}
}
Semoga bermanfaat!^_^)


0 Komentar:
Post a Comment