asp常用函数
1.放注入函数
sub aspsql()
SQL_injdata = "'|;|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
SQL_inj = split(SQL_Injdata,"|")
If Request.Form<>"" Then
For Each Sql_Post In Request.Form
For SQL_Data=0 To Ubound(SQL_inj)
if instr(Request.Form(Sql_Post),Sql_Inj(Sql_DATA))>0 Then
response.write "<mce:script language='javascript'><!--
"
response.write "alert('网站安全提示:请不要在参数中包含非法字符!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "
// --></mce:script>"
response.end
end if
next
next
end if
If Request.QueryString<>"" Then
For Each SQL_Get In Request.QueryString
For SQL_Data=0 To Ubound(SQL_inj)
if instr(Request.QueryString(SQL_Get),Sql_Inj(Sql_DATA))>0 Then
response.write "<mce:script language='javascript'><!--
"
response.write "alert('网站安全提示:请不要在参数中包含非法字符!');"
response.write "location.href='javascript:history.go(-1)';"
response.write "
// --></mce:script>"
response.end
end if
next
Next
end If
end sub
2.会员名是否含有汉字
function jc(s)
r=true
str="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ"
for i=1 to len(s)
w=mid(s,i,1)
if instr(str,w)=0 then
r=false
end if
next
jc=r
end function
3.过滤字符中的特殊字符
Function inHTML(str)
Dim sTemp
sTemp = str
inHTML = ""
If IsNull(sTemp) = True Then
Exit Function
End If
sTemp = Replace(sTemp, "&", "&")
sTemp = Replace(sTemp, "<", "<")
sTemp = Replace(sTemp, ">", ">")
sTemp = Replace(sTemp, Chr(34), """)
inHTML = sTemp
End Function
4.'拒绝夸站提交代码
function postFormfrom()
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
if mid(server_v1,8,len(server_v2))<>server_v2 then
CuBox "你提交的路径有误,禁止从站点外部提交数据请不要乱该参数!",1,""
re
相关文档:
Function WriteToUTF(content,sFilen)'content为替换后的字符串,filename为生成的文件名
dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Open
&nb ......
连接代码1直接输入
<%
Dim my_conn, sql,rs
Set my_conn = createobject("ADODB.Connection")
my_conn.open = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_ '服务器名
& "DATABASE=mybase;"_ '数据库名
& "UID=root;PWD=111; OPTION=35;" '用户名和密码
Set rs = Server.Crea ......
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
if request("action")=1 then
Response.ContentType="application/ms-excel"
Response.AddHeader "content-disposition","attachment;filename=www.xls"
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E ......
指针在C中经常提到,但是任何一种语言中都隐藏着指针。
asp也是如此,在我们传递参数给function或者sub时,我们如果传递的是一个变量,那么asp会把这个变量地址传过去,所以如果你在函数和过程里面更改这个参数,那么原变量也会改变。
'函数例子
Dim i1,i2
i1=1
'=======================
Function toadd(i)'或 ......