SQL Server注入

发布于 2024-12-02 13:51:12 字数 552 浏览 1 评论 0原文

网络开发新手,正在接管某人的代码。他们有一个防止sql注入的功能,对于SQL Server数据库

function safe(val, maxsize)
   dim i,
   terms = array(
      "cast",
      "select",
      "varchar",
      "declare",
      "drop",
      ";",
      "--",
      "insert",
      "delete",
      "xp_"
   )
   val = left(val,maxsize)
   val = trim(val)
   for i = 0 to ubound(terms)
      val = replace(val, terms(i), "e_" & val & "_e", vbTextCompare)
   next
   val = replace(val, "'", "''")
   makesafe = val
end function

犹豫是否要触碰这个,但这是否缺少什么?似乎偶尔他们会被黑客攻击

New to web development and taking over someones code. They have a function to prevent sql injection, for SQL Server database

function safe(val, maxsize)
   dim i,
   terms = array(
      "cast",
      "select",
      "varchar",
      "declare",
      "drop",
      ";",
      "--",
      "insert",
      "delete",
      "xp_"
   )
   val = left(val,maxsize)
   val = trim(val)
   for i = 0 to ubound(terms)
      val = replace(val, terms(i), "e_" & val & "_e", vbTextCompare)
   next
   val = replace(val, "'", "''")
   makesafe = val
end function

Hesitant to touch this, but is this missing anything? Seems occasionally they get hacked

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

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

发布评论

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

评论(3

瑾夏年华 2024-12-09 13:51:12

以下文章应该有所帮助:

http://tugberkugurlu。 com/archive/sql-injection-vs-lethal-injection-protection-against-sql-injection

继续下去并不是一个好主意带有 string.Replace 的路径

following article should help :

http://tugberkugurlu.com/archive/sql-injection-vs-lethal-injection-protection-against-sql-injection

It is not good idea to go down this path with string.Replace

放血 2024-12-09 13:51:12

我会完全废弃该函数并开始使用参数化语句,就像亚伦在他的评论中提到的那样。如果您以前没有这样做过,有各种文章介绍如何操作这样做。在我链接到的文章中,请查看步骤 2。

I would completely scrap that function and start using a parameterized statement like Aaron mentioned in his comment. If you haven't done so before, there are various articles on how to do so. In the article I linked you to, look at step 2.

海螺姑娘 2024-12-09 13:51:12

我不会依赖这样的函数来防止sql注入攻击。参数化查询是必须的。几乎可以肯定,使用您列出的方法时您会错过一些注入文本。

I would not rely on such a function to prevent sql injection attacks. Parameterized queries are a must. There are almost surely some injection texts you will miss using the approach of the method you listed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文