当前位置:网站首页>[wangdingbei 2020 Qinglong formation]areuserialz
[wangdingbei 2020 Qinglong formation]areuserialz
2022-06-29 17:57:00 【Hua Weiyun】
subject
<?phpinclude("flag.php");highlight_file(__FILE__);class FileHandler { protected $op; protected $filename; protected $content; function __construct() { $op = "1"; $filename = "/tmp/tmpfile"; $content = "Hello World!"; $this->process(); } public function process() { if($this->op == "1") { $this->write(); } else if($this->op == "2") { $res = $this->read(); $this->output($res); } else { $this->output("Bad Hacker!"); } } private function write() { if(isset($this->filename) && isset($this->content)) { if(strlen((string)$this->content) > 100) { $this->output("Too long!"); die(); } $res = file_put_contents($this->filename, $this->content); if($res) $this->output("Successful!"); else $this->output("Failed!"); } else { $this->output("Failed!"); } } private function read() { $res = ""; if(isset($this->filename)) { $res = file_get_contents($this->filename); } return $res; } private function output($s) { echo "[Result]: <br>"; echo $s; } function __destruct() { if($this->op === "2") $this->op = "1"; $this->content = ""; $this->process(); }}function is_valid($s) { for($i = 0; $i < strlen($s); $i++) if(!(ord($s[$i]) >= 32 && ord($s[$i]) <= 125)) return false; return true;}if(isset($_GET{'str'})) { $str = (string)$_GET['str']; if(is_valid($str)) { $obj = unserialize($str); }}analysis
First you need to bypass is_invalid function ,is_valid() The function specifies the number of characters ASCII Code must be 32-125, and protected Property will appear invisible characters after serialization \00*\00, Turn into ASCII The code does not meet the requirements .
Bypass method :PHP7.1 The above versions are not sensitive to attribute types ,public Attribute serialization will not appear invisible characters , It can be used public Property to bypass .== That is, we are finally constructing poc When , use public To modify attributes ==
First we see read() Inside file_get_contents Sensitive functions process() There is a call to read() function , On the condition that op == “2”
__destruct() Called process() function , On the condition that op!==“2”
You can see that there is a weak type problem , structure op=2 You can bypass it
<?phpclass FileHandler { public $op=2; public $filename="flag.php"; public $content="HappyCoder";}$a=new FileHandler();echo serialize($a);?> Or use php Pseudo protocol to read public $filename = "php://filter/read=convert.base64-encode/resource=flag.php";
边栏推荐
- SRM系统是什么系统?如何应用SRM系统?
- 牛客小Bai月赛52 D 环上食虫(尺取+st表)
- Industry application of smart city based on GIS 3D visualization
- MaxCompute Studio
- mac安装php7.2
- js两个一维数组合并并去除相同项(整理)
- JS merge two one-dimensional arrays and remove the same items (collation)
- 牛客小白月赛52 E 分组求对数和(容斥定理+二分)
- Split palindrome string [dp + DFS combination]
- /usr/bin/ld: warning: **libmysqlclient.so.20**, needed by //usr/
猜你喜欢

Digital twin energy system, creating a "perspective" in the low-carbon era

How to create a virtual image

育润多维发力慈善领域,勇抗企业公益大旗

Analyze the implementation principle of zero copy mechanism, applicable scenarios and code implementation

第42期:MySQL 是否有必要多列分区

关于日期相加减问题
![[target tracking] |stark configuration win OTB](/img/29/a6b3b99b7d2349499aede9e76ab29a.png)
[target tracking] |stark configuration win OTB

Selenium file upload method

基于STM32F103ZET6库函数串口实验

面试中问最常问的海量数据处理你拿捏了没?
随机推荐
You can do sideline work
数字孪生能源系统,打造低碳时代“透视”眼
/usr/bin/ld: warning: **libmysqlclient.so.20**, needed by //usr/
Relationship among controller, service and Dao
Bloom filter:
Openfeign use step polling strategy and weight log4j configuration of openfeign interceptor
从一个被应用商店坑了的BUG说起
Partial mock of static class of phpunit operation
VB. Net read / write NFC ntag tag source code
JS merge two one-dimensional arrays and remove the same items (collation)
[try to hack] cookies and sessions
DevCloud加持下的青软,让教育“智”上云端
MaxCompute字符串替换函数-replace
Maxcompute string replacement function -replace
跨境独立站语言unicode转希伯来语
【Try to Hack】Cookie和Session
剑指 Offer 13. 机器人的运动范围 (BFS)
如何使用B/S开发工具DevExtreme的图表控件 - 自定义轴位置?
【目标跟踪】|stark配置 win otb
POJ 1975 (传递闭包)