文件上传漏洞

DVWA

File Upload

LOW

首先我们准备一个一句话木马文件

123.php

<?php phpinfo();?>

1、访问页面有一个文件上传点

image-20221027142832656

2、直接上传123.php

image-20221027142855827

3、访问文件

image-20221027142919741

Medium

1、直接上传123.php文件

image-20221027142956206

2、修改123.php文件名为456.jpg,上传时通过burp抓取上传请求包,将456.jpg修改为456.php

image-20221027143222253

image-20221027143234791

3、上传成功 访问文件

image-20221027143259456

image-20221027143313110

High

1、当我们使用第二关的方式时,显示

image-20221027143439773

2、查询后端源代码

image-20221027143609359

分析源代码:strrpos(string , find ,start): 查找find字符在string字符中的最后一次出现的位置,start参数可选,表示指定从哪里开始

substr(string,start,length): 返回string字符中从start开始的字符串,length参数可选,表示返回字符的长度

strtolower(string): 返回给定字符串的小写

对后缀名进行了判断

3、可通过文件包含漏洞结合使用,首先制作图片马

image-20221027144013278

上传666.jpg

image-20221027144037685

获取666.jpg的链接地址

http://127.0.0.1/dvwa/hackable/uploads/666.jpg

4、使用文件包含漏洞模块中的low关, 进行加载图片,成功解析

image-20221027144141179

然后抓包获取cookie

蚁剑连接,设置cookie,截图如下:

连接getshell

文件包含漏洞:

Low

1、访问页面,显示allow_url_include 没有开启,我们可以在配置里面开启

allow_url_include参数表示可以远程利用文件包含漏洞

image-20221027140310339

修改为On,并且重启服务

再次访问则没有此信息

image-20221027140401887

2、通过访问1.php,2.php, 3.php会返回不通的内容,同时会将文件名传参给page参数

image-20221027141239287

3、对page传参为http://127.0.0.1/1.php

image-20221027141420079

成功解析

image-20221027141425906

Medium

1、通过访问1.php,2.php, 3.php会返回不通的内容,同时会将文件名传参给page参数

image-20221027141654299

2、对page传参为http://127.0.0.1/1.php

image-20221027141741262

进行了报错

3、查看源码

image-20221027141808818

如果传参值中有http:// https:// …/ …\都将替换为空

image-20221027141835624

4、如果传入的是htthttp://p://127.0.0.1/1.php

image-20221027141935776

High

1、直接看后端源代码

image-20221027142309888

关键代码为 使用fnmatch()函数对page参数进行过滤,要求page必须以“file”开头,服务器才会包含相应的文件。

2、可利用file协议进行读文件

image-20221027142417006

posted @ 2025-07-16 12:01  长温不喜风云  阅读(6)  评论(0)    收藏  举报