第 三 周 write up (TokyoWesterns-Web-shrine 2017-赛客夏令营-Web-random 2017-赛客夏令营-Web-weakphp)

我的博客:https://tothemoon2019.github.io


工作室“改革” 为了加强我们这一届的知识技能 每周3个ctfhub 的 write up。

都到周三了,一道题没做,不是这有事,就是那忙,我是菜鸡,今天晚上赶紧肝一道出来。

image-20201007211540845

2018-TokyoWesterns-Web-shrine

先百度了下题目名shrine

打开后有一堆乱码,不过隐约看见了app.py应该是python网站框架里的文件,然后看到了flask。

image-20201008103424044

应该和flask模板漏洞有关

image-20201007203558124

结果刷新页面的时候突然发现页面没有乱码了,

image-20201007203935237

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, port=80)

突然想起来有个脚本sqlmap可以跑ssti模板注入的洞,开kali跑!

image-20201007204948352

image-20201007210706826

成功接下来就是找能调用的类了。

不过源码里有写过滤,去掉了( ) ; config 和 self也加入了黑名单。不然直接查看app.config应该就能看见flag。

image-20201007211146555

image-20201007211117583

溜了,明天再肝

imback

虽然之前学过django不过只是些皮毛,跟别提jingjia了(虽然相似),看了下其他师傅的write up。

过滤了config,self这种模板注入常用的类,为了绕过,可以用current_app之类的全局函数。

有两个函数包含了current_app ( url_for 和 get_flashed_messages )

注入 url_for

image-20201008103817421

然后利用 current_app 调用 config

image-20201008104023211

全局变量 get_flashed_messages

image-20201008104115477

同理

image-20201008104428198

success

image-20201008105028312











图集

https://www.freebuf.com/column/148886.html

image-20201007201856791







2017-赛客夏令营-Web-random

random随机

image-20201008200829849

url栏里可以有num,说明是get传参。

image-20201008200940166

刷新一次数字变化一次,写个python脚本跑跑都有哪些数字,是否有规律。(好久没有编程了。。。)

一直只有一个数字

image-20201008201945846

用burp suite暴力破解试试

image-20201008203150741

跑了半天,突然刷新突然发现random的界限是在0-100

于是随便输入个100以下的数一直提交就有了。

image-20201008203308448

success

image-20201008105028312








2017-赛客夏令营-Web-weakphp

老样子百度了下weakphp的中文意思(虽然知道不可能有,结果有意外收获)

image-20201008204028421

但还没有看题目,不知道有没有用

页面就一句nonono,可以看到能对user和pass传参。

image-20201008204204624

写爬虫遍历了一遍

image-20201008204627927

一直是nonono!

image-20201008204641044

佛了,我还以为是sql呢,看到user和pass,看了师傅的提示: git泄露

跑出来的源码:

<?php
require_once "flag.php";
if (!isset($_GET['user']) && !isset($_GET['pass'])) {
    
    
    header("Location: index.php?user=1&pass=2");
}

$user = $_GET['user'];
$pass = $_GET['pass'];
if ((md5($user) == md5($pass)) and ($user != $pass)){
    
    
    echo $flag;
} else {
    
    
    echo "nonono!";
}
?>

看了半天不就是一个md5绕过吗。

用数组绕过md5的比较。

image-20201008210142932

结果weakphp与反序列化无关就是单纯嘲讽php咯。

image-20201008210727220

success

image-20201008105028312

猜你喜欢

转载自blog.csdn.net/qq_43478096/article/details/108955808