[0CTF 2016]piapiapia

[0CTF 2016]piapiapia

1.御剑扫描扫出来源码 (www.zip),打开后发现了登入注册等功能的源码

2.登入注册俩个源码要求用户名密码长度都在(3-16)之间

3.在class.php中存在过滤,一些关键字会被替换成hacker

 

 4.在config.php中看到了flag,推测是打印出来config.php中的内容

 5.然后在profile.php里存在反序列

<?php
    require_once('class.php');
    if($_SESSION['username'] == null) {
        die('Login First');
    }
    $username = $_SESSION['username'];
    $profile=$user->show_profile($username);
    if($profile  == null) {
        header('Location: update.php');
    }
    else {
        $profile = unserialize($profile);
        $phone = $profile['phone'];
        $email = $profile['email'];
        $nickname = $profile['nickname'];
        $photo = base64_encode(file_get_contents($profile['photo']));
?>
可以看到photo中有file_get_contents函数,可以通过该函数读取出来flag
6.update.php
在这个页面我们要输入phone,要求是11为的数字。email格式要求类似于1@qq.com。nickname要求为数字字母下划线并且长度要小于等于10。
nickname我们可以用数组形式绕过来正则
7.然后因为nickname是数组传入,所以我们可以payload:
wherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewherewhere";}s:5:"photo";s:10:"config.php";}
第一个大括号会闭合数组反序列化后的大括号,然后因为where会被替换成hacker,这样长度多了的更好等于 ";}s:5:"photo";s:10:"config.php这段的长度,所以这段字符就逃逸出来了
抓包后输入电话,邮箱,nickname[],还有图片,然后查看源码
 

 

 解码得到flag

 

 

posted @ 2022-06-28 16:06  L0VEhzzz  阅读(112)  评论(0编辑  收藏  举报