5

CTF中PHP代码审计小tips-10

 2 years ago
source link: https://jianmou.github.io/jm-miniproject-php-code-audit-10/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

MiniProject_PHP_Code_audit-10 Writeup

整体逻辑:

这是当时高校安全运维赛的一道题目,一直没有时间来整理,前段时间刚好又看到了这个源代码,给大家提供一些CTF中的思路.
用户需要输入一个page参数,作为程序员,会希望您访问到Y29uZmln.php中的phpinfo信息,但是攻击者可以获取源代码。

考点:文件上传的一点思路【web思路】

测试代码:源代码如下

Alt textAlt text

Writeup:

梳理一遍逻辑:
默认role为guest,auth为false,如果获取不到cookie里面的role值就将guest的值序列化后在base64编码后放到cookie中并输出”Sorry. You have no permissions.”,如果获取到cookie里面的值就将值反序列化后用base64解码如果为admin则开始获取post提交的filename参数和data参数的值,如果data参数中带有[<>?]就输出’No No No!’,如果输入的是一个数组,就是先拼接这个数组,然后匹配里面是否存在[<>?],如果存在,就可以得到正确的flag了。
Alt textAlt text
Alt textAlt text
Alt textAlt text
Alt textAlt text
这里主要关心的是逻辑,使用数组的时候既可以满足源代码的一切条件~ 刚开始没看到代码的时候还以为是file_put_content函数呢0.0.

参考链接:

Pwnhub 第一次线下沙龙竞赛Web题解析:https://www.leavesongs.com/PENETRATION/pwnhub-first-shalon-ctf-web-writeup.html


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK