以下方法我百试不爽~加密在客户端用js:
<script>
str = escape(queryString)
</script>在服务端解密:
<%'asp解密
function URLDecode(enStr)
dim deStr,strSpecial
dim c,i,v
deStr=""
strSpecial="!""#$%&’()*+,.-_/:;<=>?@[\]^`{|}~%"
for i=1 to len(enStr)
c=Mid(enStr,i,1)
if c="%" then
v=eval(" &h"+Mid(enStr,i+1,2))
if inStr(strSpecial,chr(v))>0 then
deStr=deStr&chr(v)
i=i+2
else
v=eval(" &h"+ Mid(enStr,i+1,2) + Mid(enStr,i+4,2))
deStr=deStr & chr(v)
i=i+5
end if
else
if c="+" then
deStr=deStr& " "
else
deStr=deStr&c
end if
end if
next
URLDecode=deStr
End function%>
<script>
str = escape(queryString)
</script>在服务端解密:
<%'asp解密
function URLDecode(enStr)
dim deStr,strSpecial
dim c,i,v
deStr=""
strSpecial="!""#$%&’()*+,.-_/:;<=>?@[\]^`{|}~%"
for i=1 to len(enStr)
c=Mid(enStr,i,1)
if c="%" then
v=eval(" &h"+Mid(enStr,i+1,2))
if inStr(strSpecial,chr(v))>0 then
deStr=deStr&chr(v)
i=i+2
else
v=eval(" &h"+ Mid(enStr,i+1,2) + Mid(enStr,i+4,2))
deStr=deStr & chr(v)
i=i+5
end if
else
if c="+" then
deStr=deStr& " "
else
deStr=deStr&c
end if
end if
next
URLDecode=deStr
End function%>
<script>
a="id=5"
document.write("<a href=1.asp?"+escape(a)+">aaaaa</a>")
</script>---------------1.asp-----------------------<%execute(URLDecode(Request.QueryString))
response.write idfunction URLDecode(enStr)
dim deStr,strSpecial
dim c,i,v
deStr=""
strSpecial="!""#$%&’()*+,.-_/:;<=>?@[\]^`{|}~%"
for i=1 to len(enStr)
c=Mid(enStr,i,1)
if c="%" then
v=eval(" &h"+Mid(enStr,i+1,2))
if inStr(strSpecial,chr(v))>0 then
deStr=deStr&chr(v)
i=i+2
else
v=eval(" &h"+ Mid(enStr,i+1,2) + Mid(enStr,i+4,2))
deStr=deStr & chr(v)
i=i+5
end if
else
if c="+" then
deStr=deStr& " "
else
deStr=deStr&c
end if
end if
next
URLDecode=deStr
End function%>1.asp 能够显示 id 的值 5
但这是在使用了 execute方法 才获取到的塞,如果把 execute(URLDecode(Request.QueryString)) 改成 URLDecode(Request.QueryString) ,那么什么都不显示了如果使用 execute 方法,我担心客户传递一个危险的可执行的 SQL 语句过来运行怎么办?
是不是传递加密函数,要想获得该值就必须使用 execute 方法呢?