比较好的一个数据库连接文件conn.asp
2011-01-28 11:48
330 查看
<%
dim db
db="datebase/datebase.mdb" '数据库文件位置
'on error resume next
connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
if err then
err.clear
else
conn.open connstr
end if
sub CloseConn()
conn.close
set conn=nothing
end sub
%>
<%
IDCCFy_In="'|;|--|<script|<iframe|char |char(|char%|char/*|select |select%|select/*|insert |insert%|insert/*|delete |delete%|delete/*|union |union%|union/*|join |join%|join/*|drop |drop%|drop/*|declare |declare%|declare/*|update |update%|update/*|truncate |truncate%|truncate/*|create
|create%|create/*|xp_cmdshell|exec |exec%|exec/*|alter |alter%|alter/*|cast |cast(|cast%|cast/*|modify |modify%|modify/*"
IDCCFy_Inf = split(IDCCFy_In,"|")
'--------POST部份------------------
If Request.Form<>"" Then
For Each IDCCFy_Post In Request.Form
For IDCCFy_Xh=0 To Ubound(IDCCFy_Inf)
If Instr(LCase(Request.Form(IDCCFy_Post)),IDCCFy_Inf(IDCCFy_Xh))<>0 Then
'写入txt记录功击者IP跟功击时间
call FsoWriteLog("sqlinLog.txt","注入IP:"& Request.ServerVariables("REMOTE_ADDR") & "----注入时间:"&now() &"-------POST注入内容:"& Request.ServerVariables("HTTP_URL")&"?"&Request.Form(IDCCFy_Post))
cuowu="<Script Language=JavaScript>alert('您提交的内容包含了字符["&IDCCFy_Inf(IDCCFy_Xh)&"],请去除后重新提交...');</Script>"
'Response.Write (cuowu)
Response.End
End If
Next
Next
End If
'----------------------------------
'--------GET部份-------------------
If Request.QueryString<>"" Then
For Each IDCCFy_Get In Request.QueryString
For IDCCFy_Xh=0 To Ubound(IDCCFy_Inf)
If Instr(LCase(Request.QueryString(IDCCFy_Get)),IDCCFy_Inf(IDCCFy_Xh))<>0 Then
call FsoWriteLog("sqlinLog.txt","注入IP:"& Request.ServerVariables("REMOTE_ADDR") & "----注入时间:"&now() &"-------GET注入内容:"& Request.ServerVariables("HTTP_URL")&"?"&Request.QueryString(IDCCFy_Post))
cuowu="<Script Language=JavaScript>alert('您提交的内容包含了字符["&IDCCFy_Inf(IDCCFy_Xh)&"],请去除后重新提交...');</Script>"
'Response.Write (cuowu)
Response.End
End If
Next
Next
End If
'--------Cookie部份-------------------
If Request.Cookies<>"" Then
For Each IDCCFy_Get In Request.Cookies
For IDCCFy_Xh=0 To Ubound(IDCCFy_Inf)
If Instr(LCase(Request.Cookies(IDCCFy_Get)),IDCCFy_Inf(IDCCFy_Xh))<>0 Then
call FsoWriteLog("sqlinLog.txt","注入IP:"& Request.ServerVariables("REMOTE_ADDR") & "----注入时间:"&now() &"-------Cookie注入内容:"& Request.ServerVariables("HTTP_URL")&"?"&Request.Cookies(IDCCFy_Post))
cuowu="<Script Language=JavaScript>alert('您提交的内容包含了字符["&IDCCFy_Inf(IDCCFy_Xh)&"],请去除后重新提交...');</Script>"
'Response.Write (cuowu)
Response.End
End If
Next
Next
End If
'写入txt记录功击者IP跟功击时间
Function FsoWriteLog(filename,Linecontent)
Dim FSO,Fs
Set FSO= Server.CreateObject("Scripting.FileSystemObject")
if not FSO.FileExists(Server.MapPath("/")&"/"&filename) then
Set Fs = FSO.CreateTextFile(Server.MapPath("/")&"/"&filename, True)
Fs.Close
end if
Set Fs = FSO.OpenTextFile(Server.MapPath("/")&"/"&filename,8,1)
Fs.WriteLine(Linecontent)
Fs.close
Set Fs = nothing
Set FSO = nothing
End Function
%>
本代码是由小弟经一位高人指点而得
贴出来给大家分享分享
祝大家兔年吉祥!
dim db
db="datebase/datebase.mdb" '数据库文件位置
'on error resume next
connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
if err then
err.clear
else
conn.open connstr
end if
sub CloseConn()
conn.close
set conn=nothing
end sub
%>
<%
IDCCFy_In="'|;|--|<script|<iframe|char |char(|char%|char/*|select |select%|select/*|insert |insert%|insert/*|delete |delete%|delete/*|union |union%|union/*|join |join%|join/*|drop |drop%|drop/*|declare |declare%|declare/*|update |update%|update/*|truncate |truncate%|truncate/*|create
|create%|create/*|xp_cmdshell|exec |exec%|exec/*|alter |alter%|alter/*|cast |cast(|cast%|cast/*|modify |modify%|modify/*"
IDCCFy_Inf = split(IDCCFy_In,"|")
'--------POST部份------------------
If Request.Form<>"" Then
For Each IDCCFy_Post In Request.Form
For IDCCFy_Xh=0 To Ubound(IDCCFy_Inf)
If Instr(LCase(Request.Form(IDCCFy_Post)),IDCCFy_Inf(IDCCFy_Xh))<>0 Then
'写入txt记录功击者IP跟功击时间
call FsoWriteLog("sqlinLog.txt","注入IP:"& Request.ServerVariables("REMOTE_ADDR") & "----注入时间:"&now() &"-------POST注入内容:"& Request.ServerVariables("HTTP_URL")&"?"&Request.Form(IDCCFy_Post))
cuowu="<Script Language=JavaScript>alert('您提交的内容包含了字符["&IDCCFy_Inf(IDCCFy_Xh)&"],请去除后重新提交...');</Script>"
'Response.Write (cuowu)
Response.End
End If
Next
Next
End If
'----------------------------------
'--------GET部份-------------------
If Request.QueryString<>"" Then
For Each IDCCFy_Get In Request.QueryString
For IDCCFy_Xh=0 To Ubound(IDCCFy_Inf)
If Instr(LCase(Request.QueryString(IDCCFy_Get)),IDCCFy_Inf(IDCCFy_Xh))<>0 Then
call FsoWriteLog("sqlinLog.txt","注入IP:"& Request.ServerVariables("REMOTE_ADDR") & "----注入时间:"&now() &"-------GET注入内容:"& Request.ServerVariables("HTTP_URL")&"?"&Request.QueryString(IDCCFy_Post))
cuowu="<Script Language=JavaScript>alert('您提交的内容包含了字符["&IDCCFy_Inf(IDCCFy_Xh)&"],请去除后重新提交...');</Script>"
'Response.Write (cuowu)
Response.End
End If
Next
Next
End If
'--------Cookie部份-------------------
If Request.Cookies<>"" Then
For Each IDCCFy_Get In Request.Cookies
For IDCCFy_Xh=0 To Ubound(IDCCFy_Inf)
If Instr(LCase(Request.Cookies(IDCCFy_Get)),IDCCFy_Inf(IDCCFy_Xh))<>0 Then
call FsoWriteLog("sqlinLog.txt","注入IP:"& Request.ServerVariables("REMOTE_ADDR") & "----注入时间:"&now() &"-------Cookie注入内容:"& Request.ServerVariables("HTTP_URL")&"?"&Request.Cookies(IDCCFy_Post))
cuowu="<Script Language=JavaScript>alert('您提交的内容包含了字符["&IDCCFy_Inf(IDCCFy_Xh)&"],请去除后重新提交...');</Script>"
'Response.Write (cuowu)
Response.End
End If
Next
Next
End If
'写入txt记录功击者IP跟功击时间
Function FsoWriteLog(filename,Linecontent)
Dim FSO,Fs
Set FSO= Server.CreateObject("Scripting.FileSystemObject")
if not FSO.FileExists(Server.MapPath("/")&"/"&filename) then
Set Fs = FSO.CreateTextFile(Server.MapPath("/")&"/"&filename, True)
Fs.Close
end if
Set Fs = FSO.OpenTextFile(Server.MapPath("/")&"/"&filename,8,1)
Fs.WriteLine(Linecontent)
Fs.close
Set Fs = nothing
Set FSO = nothing
End Function
%>
本代码是由小弟经一位高人指点而得
贴出来给大家分享分享
祝大家兔年吉祥!
相关文章推荐
- 后台管理数据库连接出错,请检查Conn.asp文件中的数据库参数设置的解决办法
- 用WIN7系统IIS的提示:数据库连接出错,请检查Conn.asp文件中的数据库参数设置
- 科讯CMS--数据库连接出错,请检查Conn.asp文件中的数据库参数设置
- ASP.NET通过配置Web.config文件提高手动绑定数据库效率的一个简单方法,不用每次手动连接数据库地址,或者数据库地址变更时只改一处即可。
- asp.net数据库配置文件连接字符串的两种方式
- asp.net 2.0 的数据库的连接类(通过配置文件读连接串)
- rails 关于连接多个数据库使用同一个database.yml文件的方法
- 在ASP.NET项目中的web.config文件里配置数据库连接并在程序代码中获取连接字符串
- hibernate和spring整合时,把连接数据库的信息单独提出一个文件的方法
- asp.net当文件在不同目录下,需要获取数据库连接字符串收藏
- ASP.NET 2.0 遍历配置文件的数据库连接字符串
- 一个测试SQL2005数据库连接的JSP文件
- asp.net文件上传代码/数据库巧妙连接
- asp连接access 2007与 access 2003数据库的conn代码
- 之前创建了一个表空间,然后今天不小心把表空间文件给删除了。然后用pl/sql连接数据库的时候,报ORA-01033错误。ora-01033:oracle initializationg or shut
- ASP.NET数据库连接字符串写在config.web配置文件中
- 郁闷ing!有没有谁可以提供asp.net一个数据库连接的例子
- [导入]ASP.NET 2.0 遍历配置文件的数据库连接字符串
- asp+sql连接字符串conn.asp文件
- 一个用配制文件连接数据库的类