1.5 webshell文件上傳漏洞分析溯源(1~4)
webshell文件上傳漏洞分析溯源(第一題)
我們先來看基礎頁面:
先上傳1.php ----> ,好吧意料之中
上傳1.png ---->
我們查看頁面元素 -----> ,也沒有前端驗證
看來只能用burp抓包來改包繞過,我們修改1.php ----> 1.php .png ,然後上傳抓包改包 0x20 -----> 0x00
webshell文件上傳漏洞分析溯源(第一題)
我們先來看基礎頁面:
先上傳1.php ----> ,好吧意料之中
上傳1.png ---->
我們查看頁面元素 -----> ,也沒有前端驗證
看來只能用burp抓包來改包繞過,我們修改1.php ----> 1.php .png ,然後上傳抓包改包 0x20 -----> 0x00
看了人家的wp,發現是黑名單繞過,也就是上傳最簡單的1.php3或者1.php4或者1.php5,服務器把php給過濾了......疏忽了
菜刀鏈接:,好吧,打臉....
走到這裏了,我們來看一下源代碼:
index.php
<!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <title>Upload</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="author" content=""> <link href="static/bootstrap.css" rel="stylesheet"> <link href="static/cover.css" rel="stylesheet"> <script src="static/jquery.js"></script> <script src="static/bootstrap.js"></script> </head> <body> <div class="site-wrapper"> <form class="form-signin" action="upload.php" method="post" enctype="multipart/form-data" name="upload"> <h3>請選擇文件上傳:</h3> <input class="form-control" type="file" name="upfile"/> <input type="submit" name="submit" value="上傳文件"/> </form> </div> </body> </html>
upload.php
<?php //文件上傳漏洞演示腳本之服務端擴展名驗證 header("Content-type: text/html; charset=utf-8"); error_reporting(0); header("Content-type: text/html; charset=utf-8"); error_reporting(0); $uploaddir = ‘uploads/‘; if (isset($_POST[‘submit‘])) { if (file_exists($uploaddir)) { $deny_ext = array(‘.asp‘, ‘.php‘, ‘.aspx‘, ‘.jsp‘); //echo strrchr($_FILES[‘upfile‘][‘name‘], ‘.‘); $file_ext = strrchr($_FILES[‘upfile‘][‘name‘], ‘.‘); //echo $file_ext; if (!in_array($file_ext, $deny_ext)) { if (move_uploaded_file($_FILES[‘upfile‘][‘tmp_name‘], $uploaddir . ‘/‘ . $_FILES[‘upfile‘][‘name‘])) { echo ‘文件上傳成功保存於:‘ . $uploaddir . $_FILES[‘upfile‘][‘name‘] . "\n"; } } else { echo ‘此文件不允許上傳‘ . "\n"; } } else { exit($uploaddir . ‘文件夾不存在,請手工創建‘); } //print_r($_FILES); } ?>
它采用的是黑名單過濾php被過濾掉了,但是php還有其他版本,php3,php4,php5都能被解析器
webshell文件上傳漏洞分析溯源(第二題)
這次我們上傳1.php3 :
上傳1.png :
我們把1.php ---> 1.php .jpg ,
我們查看頁面源代碼:
<!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <title>Upload</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="author" content=""> <link href="static/bootstrap.css" rel="stylesheet"> <link href="static/cover.css" rel="stylesheet"> <script src="static/jquery.js"></script> <script src="static/bootstrap.js"></script> <script language="JavaScript"> extArray = new Array(".gif", ".jpg", ".png"); function LimitAttach(form, file) { allowSubmit = false; if (!file) return; while (file.indexOf("\\") != -1) file = file.slice(file.indexOf("\\") + 1); ext = file.slice(file.indexOf(".")).toLowerCase(); for (var i = 0; i < extArray.length; i++) { if (extArray[i] == ext) { allowSubmit = true; break; } } if (allowSubmit) form.submit(); else alert("對不起,只能上傳以下格式的文件: " + (extArray.join(" ")) + "\n請重新選擇符合條件的文件" + "再上傳."); return false; } </script> </head> <body> <div class="site-wrapper"> <form class="form-signin" action="upload.php" method="post" enctype="multipart/form-data" name="upload"> <h3>請選擇文件上傳:</h3> <input class="form-control" type="file" name="uploadfile"/> <input type="submit" name="submit" value="上傳文件" onclick="return LimitAttach(this.form, this.form.uploadfile.value)"/> </form> </div> </body> </html>
發現前端存在js驗證,只能識別圖片格式的文件進行上傳,這裏有兩種方法:
第一種是:將一句話木馬1.php的後綴名改成.jpg格式的然後進行上傳,用burpsuit進行對文件格式改為1.php,上傳成功後用菜刀進行鏈接獲取shell,並找到key.
第二種是: 先在瀏覽器輸入about:config(僅限於火狐瀏覽器),然後搜索java script .enabled將切換為false,這樣就禁用了javascript,前端驗證不起作用 ,創建一句話木馬 <?Php eval($_post[‘123’])?>,直接上傳,返回上傳路徑 uploads/1.php,然後菜刀鏈接
webshell文件上傳漏洞分析溯源(第三題)
webshell文件上傳漏洞分析溯源(第四題)
1.5 webshell文件上傳漏洞分析溯源(1~4)