作者:My5t3ry
漏洞存在于User/ChinaBankAutoReceive.asp
01
|
<%@LANGUAGE=
"VBSCRIPT"
CODEPAGE=
"936"
%>
|
03
|
<!--#include file=
"../Conn.asp"
-->
|
04
|
<!--#include file=
"../Plus/md5.asp"
-->
|
05
|
<!--#include file=
"../KS_Cls/Kesion.MemberCls.asp"
-->
|
06
|
<!--#include file=
"payfunction.asp"
-->
|
14
|
Response.Buffer = true
|
16
|
Response.CacheControl =
"no-cache"
|
18
|
Dim
KSUser:
Set
KSUser=
New
UserCls
|
19
|
Dim
KS:
Set
KS=
New
PublicCls
|
20
|
Dim
PaymentPlat:PaymentPlat=1
|
22
|
Dim
RSP:
Set
RSP=Server.CreateObject(
"ADODB.RECORDSET"
)
|
23
|
RSP.Open
"Select top 1 * From KS_PaymentPlat where id="
& PaymentPlat,conn,1,1
|
25
|
RSP.Close:
Set
RSP=
Nothing
|
26
|
Response.Write
"Error!"
|
29
|
Dim
AccountID:AccountID=RSP(
"AccountID"
)
|
30
|
Dim
MD5Key:MD5Key=RSP(
"MD5Key"
)
|
31
|
Dim
PayOnlineRate:PayOnlineRate=KS.ChkClng(RSP(
"Rate"
))
|
32
|
Dim
RateByUser:RateByUser=KS.ChkClng(RSP(
"RateByUser"
))
|
33
|
RSP.Close:
Set
RSP=
Nothing
|
38
|
Dim
v_oid,v_pmode,v_pstatus,v_pstring,v_string,v_amount,v_moneytype,remark2,v_md5str,text,md5text,zhuangtai
|
40
|
v_oid=request(
"v_oid"
)
|
41
|
v_pmode=request(
"v_pmode"
)
|
42
|
v_pstatus=request(
"v_pstatus"
)
|
43
|
v_pstring=request(
"v_pstring"
)
|
44
|
v_amount=request(
"v_amount"
)
|
45
|
v_moneytype=request(
"v_moneytype"
)
|
46
|
remark2=request(
"remark2"
)
|
47
|
v_md5str=request(
"v_md5str"
)
|
48
|
if request(
"v_md5str"
)=
""
then
|
49
|
response.Write(
"v_md5str:空值"
)
|
52
|
text = v_oid&v_pstatus&v_amount&v_moneytype&MD5Key
|
53
|
md5text = Ucase(trim(md5(text,32)))
|
54
|
if md5text<>v_md5str then
|
55
|
response.write(
"error"
)
|
58
|
response.write(
"ok"
)
|
60
|
Call
UpdateOrder(v_amount,remark2,v_oid,v_pmode)
|
61
|
Conn.Execute(
"Update KS_LogMoney Set PaymentID=1 Where OrderID='"
& v_oid &
"'"
)
|
63
|
response.write(
"error"
)
|
69
|
上面代码中的v_oid=request(
"v_oid"
)没有过滤,然后就调用了
|
71
|
Call
UpdateOrder(v_amount,remark2,v_oid,v_pmode)
|
我们接着看UpdateOrder
001
|
Sub
UpdateOrder(v_amount,remark2,v_oid,v_pmode)
|
002
|
Dim
KSUser:
Set
KSUser=
New
UserCls
|
003
|
Dim
UserName,MoneyType,Money,Remark,sqlUser,rsUser,orderid,mobile,Action
|
005
|
IF Cbool(KSUser.UserLoginChecked)
Then
UserName=KSUser.UserName
Else
UserName=KS.S(
"UserName"
)
|
008
|
If
UserName=
""
Then
UserName=SUserName
|
010
|
UserCardID=KS.ChkClng(KS.S(
"UserCardID"
))
|
011
|
iF UserCardID=0
Then
UserCardID=sUserCardID
|
012
|
Action=KS.G(
"Action"
):
If
Action=
""
Then
Action=Saction
|
015
|
Mobile=KSUser.GetUserInfo(
"Mobile"
)
|
019
|
Set
RSLog=Server.CreateObject(
"ADODB.RECORDSET"
)
|
020
|
RSLog.Open
"Select top 1 * From KS_LogMoney where orderid='"
& v_oid &
"'"
,Conn,1,1
|
021
|
if RSLog.Eof
And
RSLog.BoF
Then
|
024
|
Set
RS=Server.CreateObject(
"ADODB.RECORDSET"
)
|
025
|
RS.Open
"Select top 1 * From KS_Order Where OrderID='"
& v_oid &
"'"
,Conn,1,3
|
027
|
RS.Close:
Set
RS=
Nothing
|
028
|
KS.Die
"<br><li>支付过程中遇到问题,请联系网站管理员!"
|
031
|
Mobile=RS(
"Mobile"
)
|
033
|
RS(
"MoneyReceipt"
)=Money
|
034
|
If
Money>=RS(
"MoneyTotal"
)
Then
|
041
|
Dim
OrderStatus:OrderStatus=rs(
"status"
)
|
043
|
RS(
"PaymentPlatId"
)=KS.ChkClng(Request(
"PaymentPlat"
))
|
046
|
orderid=RS(
"OrderID"
)
|
047
|
Dim
XID:XID=RS(
"ID"
)
|
048
|
Call
KS.MoneyInOrOut(rs(
"UserName"
),RS(
"Contactman"
),Money,2,1,now,rs(
"orderid"
),
"System"
,
"为购买订单:"
&v_oid &
"使用"
& v_pmode &
"在线充值"
,0,0,0)
|
049
|
Call
KS.MoneyInOrOut(rs(
"UserName"
),RS(
"Contactman"
),Money,4,2,now,rs(
"orderid"
),
"System"
,Remark,0,0,0)
|
053
|
Dim
rsp:set rsp=conn.execute(
"select id,title from ks_product where id in(select proid from KS_OrderItem where orderid='"
& rs(
"orderid"
) &
"')"
)
|
056
|
dim rsi:set rsi=conn.execute(
"select amount,attrid from ks_orderitem where orderid='"
& rs(
"orderid"
) &
"' and proid="
& rsp(0))
|
058
|
if OrderStatus<>1
Then
|
059
|
If
RSI(
"AttrID"
)<>0
Then
|
060
|
Conn.Execute(
"update KS_ShopSpecificationPrice set amount=amount-"
& RSI(0) &
" Where amount>="
& RSI(0) &
" and ID="
& RSI(1))
|
062
|
conn.execute(
"update ks_product set totalnum=totalnum-"
& rsi(0) &
" where totalnum>="
& rsi(0) &
" and id="
& rsp(0))
|
077
|
RS.Close:
Set
RS=
Nothing
|
078
|
IF KS.C(
"UserName"
)<>
""
Then
response.Redirect
"User_Order.asp?Action=ShowOrder&ID="
& XID
|
080
|
Set
rsUser=Server.CreateObject(
"Adodb.RecordSet"
)
|
081
|
sqlUser=
"select top 1 * from KS_User where UserName='"
& UserName &
"'"
|
082
|
rsUser.Open sqlUser,Conn,1,1
|
083
|
if rsUser.bof and rsUser.eof then
|
084
|
Response.Write
"<br><li>充值过程中遇到问题,请联系网站管理员!"
|
085
|
rsUser.close:set rsUser=
Nothing
|
088
|
Dim
RealName:RealName=rsUser(
"RealName"
)
|
089
|
Dim
Edays:Edays=rsUser(
"Edays"
)
|
090
|
Dim
BeginDate:BeginDate=rsUser(
"BeginDate"
)
|
091
|
rsUser.Close :
Set
rsUser=
Nothing
|
093
|
If
UserCardID<>0
Then
|
094
|
Call
UpdateByCard(0,UserCardID,UserName,RealName,Edays,BeginDate,v_oid,v_pmode)
|
096
|
Call
KS.MoneyInOrOut(UserName,RealName,Money,3,1,now,v_oid,
"System"
,v_pmode &
"在线充值,订单号为:"
& v_oid,0,0,0)
|
103
|
RSLog.Close:
Set
RSLog=
Nothing
|
106
|
RSLog.Open
"Select top 1 * From KS_LogMoney where orderid='"
& v_oid &
"'"
,Conn,1,1
|
这句带入SQL了!那么然后构造参数才能触发漏洞呢?
我们这样构造:
/User/ChinaBankAutoReceive.asp?v_oid=1%27&v_pstatus=20&v_amount=1&v_moneytype=1&v_md5str=9B5BF7166AFBB5E1602BBCC964459B9B
其中的v_oid带入我们的SQL注射语句…你懂的,后面的v_md5str是md5(v_oid&v_pstatus&v_amount&v_moneytype&MD5Key)得到的,MD5Key的值来自数据库值为0
简单地说,v_oid构造SQL后,md5(v_oid&v_pstatus&v_amount&v_moneytype&MD5Key)计算出v_md5str,然后提交就行了