当前位置:网站首页>Primary code audit [no dolls (modification)] assessment
Primary code audit [no dolls (modification)] assessment
2022-07-05 13:42:00 【Snow is not cold 1】
Code audit
First, let's open the topic link :http://1.15.152.9:1111/sre-winter/, Then you can see this page directly :
Analyze the code :
First say file_get_contents:
This function is the preferred method to read the entire file into a string . At the same time $filename Parameters are not just local file paths , It can also be a network path URL
So we look down
if(isset($resolve)&&(file_get_contents($resolve,'r')==="try hard to become a redrocker"))
Here we need to pass in a file with the content try hard to become a redrocker To get to the next step , It said file_get_contents() Medium $filename It can also be a URL, So we can use data:// Fake protocol to bypass
Besides, data:// Fake protocol :
effect : since PHP>=5.2.0 rise , have access to data:// Data flow wrapper , To transfer data in the corresponding format . Can usually be used to perform PHP Code . Generally, we need to use base64 Code transmission
So use pseudo Protocol :
?resolve=data://text/plain;base64,dHJ5IGhhcmQgdG8gYmVjb21lIGEgcmVkcm9ja2Vy
//dHJ5IGhhcmQgdG8gYmVjb21lIGEgcmVkcm9ja2Vy Decoded as --->try hard to become a redrocker
Then we noticed unserialize(), This is a deserialization function , Then, if we pass a serialized object, that is, a string of strings, to $fxl, Then we will get an instance object ,wow! Fantastic! !!
So the structure :

obtain :
O:3:"SRE":1:{
s:8:"document";s:12:"printenv.php";}
therefore :
?resolve=data://text/plain;base64,dHJ5IGhhcmQgdG8gYmVjb21lIGEgcmVkcm9ja2Vy&fxl=O:3:"SRE":1:{s:8:"document";s:12:"printenv.php";}
stay url After adding the above sentence, we get :

Right click on the source , notice :

Then let's analyze the source code , See what happens
First of all to see 4 individual if Then there is a eval That means we need to meet these four conditions at the same time ;
First of all if(isset($_GET['st'])) Sentenced to empty , If it is not empty, execute the following statement ;
And then there was if (!preg_match('/data:\/\/|filter:\/\/|php:\/\/|phar:\/\//i', $_GET['st'])) Filtered here data、filter、php Wait for the fake agreement , Prevent using pseudo protocol to read files ,
Next is if(';' === preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['st'])) Here, it means that you can only pass functions without parameters ;
And finally if (!preg_match('/es|info|bin|hex|log|dec|oct|na|os|pi/i', $_GET['st'])) Many keywords are matched here , So many functions can't be used .
that ,
The first use of scandir() Function to get the files in the current directory and use print_r() Output function .localeconv() Function returns an array containing local numbers and currency information .
?st=print_r(scandir(current(localeconv())));
obtain 
Found the file redrock.php, This should be flag.
So what should we do next ?
Look up the information and think hard for a long time , Suddenly thought of :
We can use readfile Plus a random function array_rand(array_flip()) To read :
?st=readfile(array_rand(array_flip(scandir(current(localeconv())))));
array_flip(): Swap the keys and values of the array .
array_rand(): Take one or more cells out of an array at random , Constantly refreshing the access will continue to return randomly , In this topic scandir() The returned array is only 5 Elements , Refresh a few times and you can brush it out .
Just refresh a few more times , harmless :
At last we get 
And then I got it flag
flag{Congratulation!The task completed}
边栏推荐
- French scholars: the explicability of counter attack under optimal transmission theory
- 真正的缓存之王,Google Guava 只是弟弟
- 这18个网站能让你的页面背景炫酷起来
- Solve the problem of "unable to open source file" xx.h "in the custom header file on vs from the source
- go 数组与切片
- ELK 企业级日志分析系统
- What is a network port
- [深度学习论文笔记]使用多模态MR成像分割脑肿瘤的HNF-Netv2
- restTemplate详解
- Aspx simple user login
猜你喜欢

Write API documents first or code first?

STM32 reverse entry
![[deep learning paper notes] hnf-netv2 for segmentation of brain tumors using multimodal MR imaging](/img/52/5e85743b1817de96a52e02b92fd08c.png)
[deep learning paper notes] hnf-netv2 for segmentation of brain tumors using multimodal MR imaging

jasypt配置文件加密|快速入门|实战

ELFK部署

Cloudcompare - point cloud slice

Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution

Idea设置方法注释和类注释

先写API文档还是先写代码?

Win10 - lightweight gadget
随机推荐
Win10 - lightweight gadget
stm32逆向入门
运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化
不知道这4种缓存模式,敢说懂缓存吗?
Zhubo Huangyu: these spot gold investment skills are not really bad
Clock cycle
研究生可以不用学英语?只要考研英语或六级分数高!
go map
Resttemplate details
What are the private addresses
TortoiseSVN使用情形、安装与使用
kafaka 日志收集
Interviewer soul torture: why does the code specification require SQL statements not to have too many joins?
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
asp. Net read TXT file
龙芯派2代烧写PMON和重装系统
Laravel framework operation error: no application encryption key has been specified
山东大学暑期实训一20220620
[daily question] 1200 Minimum absolute difference