asp下的风讯用的SQL通用防注入模块提供了

免费源码 2025-05-15 08:41www.dzhlxh.cn免费源码

代码片段如下:

```vbscript

<%

Dim FS_NoSqlHack_AllStr, FS_NoSqlHack_Str, FS_NoSqlHack_ComeUrlGet, FS_NoSqlHack_ComeUrlPost, FS_NoSqlHack_Get, FS_NoSqlHack_Post, FS_NoSqlHack_i

'Ignore errors for now

FS_NoSqlHack_AllStr = "'|;| and |chr(|exec |insert |select |delete from|update |mid(|master."

FS_NoSqlHack_ComeUrlGet = Request.QueryString

FS_NoSqlHack_ComeUrlPost = Request.Form

FS_NoSqlHack_Str = Split(FS_NoSqlHack_AllStr,"|")

'Process Post requests

If FS_NoSqlHack_ComeUrlPost <> "" Then

For Each FS_NoSqlHack_Post In Request.Form

For FS_NoSqlHack_i = 0 To Ubound(FS_NoSqlHack_Str)

If InStr(LCase(Request.Form(FS_NoSqlHack_Post)), FS_NoSqlHack_Str(FS_NoSqlHack_i)) <> 0 Then

Response.Write("Error!!")

Response.End

End If

Next

Next

End If

'Process Get requests

If FS_NoSqlHack_ComeUrlGet <> "" Then

For Each FS_NoSqlHack_Get In Request.QueryString

For FS_NoSqlHack_i = 0 To Ubound(FS_NoSqlHack_Str)

If InStr(LCase(Request.QueryString(FS_NoSqlHack_Get)), FS_NoSqlHack_Str(FS_NoSqlHack_i)) <> 0 Then

Response.Write("Error!!")

Response.End

End If

Next

Next

End If

%>

```

这段代码中,我们首先对变量进行了声明。接着,处理了来自POST和GET请求的输入,通过循环检查每个请求中的参数是否包含预设的敏感字符串。如果包含,服务器会返回错误信息并终止响应。这个过程对于防范SQL注入攻击非常关键。代码风格简洁明了,同时保持了功能的完整性。

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板