内容简介:1.正常构造payload的话因为$op、$fliename、$content都是protected属性,序列化的的结果的属性名前面会有/002.php>7.1版本对类属性的检测不严格来绕过,将序列化里的portected属性换成public属性,就不会有/00。
题目分析
<?php
include("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);
}
}
1.传入str,经过处理反序列化。 2.is_valid过滤:传入的string要是可见字符ascii值为32-125。 3.$op:op=="1"的时候会进入write方法处理,op=="2"的时候进入read方法处理。
利用php>7.1版本对类属性的检测不严格(对属性类型不敏感)
1.正常构造payload的话因为$op、$fliename、$content都是protected属性,序列化的的结果的属性名前面会有/00 /00(或者%00 %00),/00的ascii为0不可见的字符如下图,就会被is_valid方法拦下来。
2.php>7.1版本对类属性的检测不严格来绕过,将序列化里的portected属性换成public属性,就不会有/00。
3.弱类型绕过
然后$obj = unserialize($str);会调用__destruct魔术方法,如果$op=
"2"的话就把$op="1"
这时候要使op
="2"不成立且op=="2"成立,这里可以自己使用op等于整数2使得进入read方法里面。构造payload
参考:( https://blog.csdn.net/Oavinci/article/details/106998738 )[ https://blog.csdn.net/Oavinci/article/details/106998738 ]
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
数学之美 (第二版)
吴军 / 人民邮电出版社 / 2014-11 / 49.00元
几年前,“数学之美”系列文章原刊载于谷歌黑板报,获得上百万次点击,得到读者高度评价。读者说,读了“数学之美”,才发现大学时学的数学知识,比如马尔可夫链、矩阵计算,甚至余弦函数原来都如此亲切,并且栩栩如生,才发现自然语言和信息处理这么有趣。 在纸本书的创作中,作者吴军博士几乎把所有文章都重写了一遍,为的是把高深的数学原理讲得更加通俗易懂,让非专业读者也能领略数学的魅力。读者通过具体的例子学到的......一起来看看 《数学之美 (第二版)》 这本书的介绍吧!