当前位置:网站首页>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}
边栏推荐
- STM32 reverse entry
- With 4 years of working experience, you can't tell five ways of communication between multithreads. Dare you believe it?
- ELK 企业级日志分析系统
- 面试官灵魂拷问:为什么代码规范要求 SQL 语句不要过多的 join?
- restTemplate详解
- Huawei push service content, read notes
- Network security HSRP protocol
- What is a network port
- FPGA 学习笔记:Vivado 2019.1 添加 IP MicroBlaze
- [daily question] 1200 Minimum absolute difference
猜你喜欢

What happened to the communication industry in the first half of this year?

内网穿透工具 netapp

不知道这4种缓存模式,敢说懂缓存吗?

嵌入式软件架构设计-消息交互

“百度杯”CTF比赛 九月场,Web:Upload

MySQL - database query - sort query, paging query

Go array and slice

Solve the problem of invalid uni app configuration page and tabbar

Jenkins installation

FPGA learning notes: vivado 2019.1 add IP MicroBlaze
随机推荐
TortoiseSVN使用情形、安装与使用
[深度学习论文笔记]使用多模态MR成像分割脑肿瘤的HNF-Netv2
[深度学习论文笔记]TransBTSV2: Wider Instead of Deeper Transformer for Medical Image Segmentation
go map
asp. Net read TXT file
stm32逆向入门
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
山东大学暑期实训一20220620
Basic characteristics and isolation level of transactions
C# 对象存储
Aspx simple user login
How to choose note taking software? Comparison and evaluation of notion, flowus and WOLAI
真正的缓存之王,Google Guava 只是弟弟
go 指针
Kafaka log collection
ETCD数据库源码分析——rawnode简单封装
“百度杯”CTF比赛 九月场,Web:Upload
asp.net 读取txt文件
My colleague didn't understand selenium for half a month, so I figured it out for him in half an hour! Easily showed a wave of operations of climbing Taobao [easy to understand]
Summit review | baowanda - an integrated data security protection system driven by compliance and security