当前位置:网站首页>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}
边栏推荐
- 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]
- [public class preview]: basis and practice of video quality evaluation
- kafaka 日志收集
- These 18 websites can make your page background cool
- 【公开课预告】:视频质量评价基础与实践
- Shuttle INKWELL & ink components
- leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)
- Catch all asynchronous artifact completable future
- Go string operation
- asp. Net read TXT file
猜你喜欢

法国学者:最优传输理论下对抗攻击可解释性探讨
![[server data recovery] a case of RAID5 data recovery stored in a brand of server](/img/04/c9bcf883d45a1de616c4e1b19885a5.png)
[server data recovery] a case of RAID5 data recovery stored in a brand of server

Cloudcompare - point cloud slice

Flutter 3.0更新后如何应用到小程序开发中

redis6事务和锁机制

百度杯”CTF比赛 2017 二月场,Web:爆破-2
![[深度学习论文笔记]UCTransNet:从transformer的通道角度重新思考U-Net中的跳跃连接](/img/b6/f9da8a36167db10c9a92dabb166c81.png)
[深度学习论文笔记]UCTransNet:从transformer的通道角度重新思考U-Net中的跳跃连接

go 数组与切片

NFT value and white paper acquisition

How to apply the updated fluent 3.0 to applet development
随机推荐
zabbix 监控
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
go 字符串操作
How to apply the updated fluent 3.0 to applet development
Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
Mmseg - Mutli view time series data inspection and visualization
【Hot100】33. 搜索旋转排序数组
mysql获得时间
内网穿透工具 netapp
Log4j utilization correlation
The "Baidu Cup" CTF competition was held in February 2017, Web: explosion-2
leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)
redis6主从复制及集群
Difference between avc1 and H264
MySQL - database query - sort query, paging query
Matlab paper chart standard format output (dry goods)
【华南理工大学】考研初试复试资料分享
The real king of caching, Google guava is just a brother
【Hot100】34. Find the first and last positions of elements in a sorted array
leetcode 10. Regular expression matching regular expression matching (difficult)