在经典 asp 中清理输入的好方法

发布于 2024-07-12 00:09:47 字数 161 浏览 10 评论 0原文

我必须更新工作中的旧项目。 尽管我熟悉 php 脚本,但我没有任何经典 asp 的经验。

  • 有什么我应该使用的功能吗?
  • 能给我提供一些基本的保护功能吗?
  • asp中有类似参数化查询的东西吗?

谢谢!

I have to update old projects at work. I do not have any experience with classic asp, although i'm familiar with php scripting.

  • Are there any functions I should use?
  • Can you provide me with a good function for some basic protection?
  • Is there something like a parameterized query in asp?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

梦年海沫深 2024-07-19 00:09:47

是的,您可以在经典 ASP(更准确地说,经典 ADO)中使用参数化查询。

这是链接

至于编码输出,我可能会想为最新的 Microsoft Anti-XSS 库创建一个包装器,并使用 Server.CreateObject 调用它。 我远不是这类事情的专家,因为我在 .Net 上花费了更多时间,所以我认为这会起作用。

Server.HTMLEncode 确实不够好,因为它只将一些编码字符列入黑名单。 Anti-XSS 库要好得多,因为它将可接受的内容列入白名单。

Yes you can use parametrized queries in classic ASP (more accurately, classic ADO).

Here is a link.

As for encoding output, I might be tempted to create a wrapper for the latest Microsoft Anti-XSS library and call it with Server.CreateObject. I am far from an expert on this kind of thing as I spend much more time in .Net, so I only think this would work.

Server.HTMLEncode is really not good enough, as it only blacklists a few encoding characters. The Anti-XSS library is much better as it whitelists what is acceptable.

晌融 2024-07-19 00:09:47

始终使用 Server.HTMLEncode 来清理用户输入。

例如,如果您要从表单文本框设置变量:

firstName = Server.HTMLEncode(trim(request.form("firstname")))

Always use Server.HTMLEncode to sanitize user input.

For example, if you're setting a variable from a form text box:

firstName = Server.HTMLEncode(trim(request.form("firstname")))

软的没边 2024-07-19 00:09:47

注意 SQL 注入。 不要将用户输入连接到 SQL 字符串然后执行它。 相反,始终使用参数化查询。

Watch out for SQL injection. Do not concatenate user input to a SQL string and then execute it. Instead, always used parameterized queries.

枕花眠 2024-07-19 00:09:47

有很多以 Is 开头的函数,例如 IsNumberIsArray 等,您可能会感兴趣。 另外,如果您需要一个整数,则可以使用 CLng(Request("blabla")) 来获取它,因此如果它不是整数,则 CLng 函数将引发错误。

There is a bunch of functions starting with Is, such as IsNumber, IsArray etcetera, that might be of interest. Also if you're expecting a integer, you could use CLng(Request("blabla")) to get it, thus if it's not a integer the CLng function will raise an error.

心如狂蝶 2024-07-19 00:09:47

一种方法可能是在 header.asp 文件中添加一个检查,该文件循环访问 Request 对象以查找不适当的字符。 例如:

<%
    for each x in Request.Form ' Do this for Request.Querystring also
        If InStr(x,"<") <> 0 Then
            ' encode the value or redirect to error page?
        End If
    next
%>

One way to do it might be to add a check in a header.asp file that iterates through the Request object looking for inappropriate characters. For example:

<%
    for each x in Request.Form ' Do this for Request.Querystring also
        If InStr(x,"<") <> 0 Then
            ' encode the value or redirect to error page?
        End If
    next
%>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文