SQL注入获取对传统的ASP - 重新发布形式,很多蜱放 [英] SQL injection capturing on classic asp - reposting form puts in lots of ticks

查看:145
本文介绍了SQL注入获取对传统的ASP - 重新发布形式,很多蜱放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是SQL Server 2005的经典ASP和形式重新发布(我回发到同一页),我替换每个文本字段如下:

I'm using SQL Server 2005 with classic ASP and on a form repost (I post back to the same page), I replace each text field as follows:

course = trim(replace(request("course"),"'","''"))\

这里的问题是,如果我不得不多次重新发布形式验证错误的情况下,刻度线替换我乘。

The problem with this is if I have to repost the form multiple times in case of validation errors, the tick marks I replace multiply.

有另一种方式安全地审核,而不做这种替换的字符串字段?

Is there another way to safely vet the string fields without doing this kind of replace?

推荐答案

您更好的使用参数化查询:

you better use a parametrized query:

dim cmd : set cmd = server.createObject("ADODB.Command")
dim param
dim sql : sql = "INSERT INTO table(course) VALUES (?)"
cmd.ActiveConnection = yourDBconnection
cmd.CommandType = adCmdText

set param = cmd.CreateParameter("course", adVarChar, , 20, request("course"))
cmd.Parameters.Append param

cmd.CommandText = sql
cmd.Execute

所以你是SQL注入完全安全的。

so you are completely safe with sql injection

这篇关于SQL注入获取对传统的ASP - 重新发布形式,很多蜱放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆