僅僅代表我的觀點(diǎn).不怕見(jiàn)笑.有問(wèn)題請(qǐng)大家指教!我想如果你是牛人,那這個(gè)已經(jīng)不是值得你看的內(nèi)容,只是覺(jué)得對(duì)與很多剛?cè)腴T(mén)的ASP程序員來(lái)說(shuō)還是有點(diǎn)實(shí)際意義,所以不怕被大家笑話(huà),寫(xiě)了貼在這里!
<%
Function checkStr(str)
if isnull(str) then
checkStr = ""
exit function
end if
checkStr=replace(str," ","")
checkStr=replace(str,"'","'")
checkStr=replace(str,";","'")
checkStr=replace(str,"--","'")
checkStr=replace(str,"(","'")
checkStr=replace(str,"[","'")
checkStr=replace(str,"$","'")
end function
%>
相關(guān)函數(shù)
Left(string, length)
返回指定數(shù)目的從字符串的左邊算起的字符
Asc(string)
返回與字符串的第一個(gè)字母對(duì)應(yīng)的 ANSI 字符代碼。
Mid(string, start[, length])
從字符串中返回指定數(shù)目的字符。
***********************************
我自己的做法是把字符串限定在8個(gè)字符內(nèi),呵。ㄇf(wàn)條數(shù)據(jù)啊,沒(méi)誰(shuí)有這樣大的記錄吧?99,999,999呵!不夠用,才怪了!除非你的數(shù)據(jù)從來(lái)不更新刪出,那也沒(méi)辦法,問(wèn)題是sql到了這樣的時(shí)會(huì)是怎么樣的速度)
---<%
if len(request.querystring("ddd"))> 8 then
response.write(黑我啊,不要了。少來(lái))
response.end '最好有這句
'''初步是判斷是否是數(shù)字=======IsNumeric 函數(shù)
if IsNumeric(request.querystring("ddd")) then
Execute("select * from [table]")
....
else
response.write(黑我啊,不要了。少來(lái))
response.end '最好有這句
%>
當(dāng)然了,加上上面的函數(shù),在你的SQL過(guò)程里,效果就非常完美了!
呵!。≡谧儜B(tài)點(diǎn)做個(gè)函數(shù)。
---<%
Function checkStr(str)
if isnull(str) then
checkStr = ""
exit function
end if
checkStr=replace(str," ","")
checkStr=replace(str,"'","'")
checkStr=replace(str,";","'")
checkStr=replace(str,"--","'")
checkStr=replace(str,"(","'")
checkStr=replace(str,"[","'")
checkStr=replace(str,"$","'")
checkStr=replace(str,"asc'," ")
checkStr=replace(str,"mid"," ")
checkStr=replace(str,"delete"," ")
checkStr=replace(str,"drop"," ")
'''呵!我這里沒(méi)屏蔽select,count,哈!想起來(lái)我就笑,太變態(tài)了,那其不是我什么都不用了不是更更安全。。!呵。^)^~
end function
%>
足夠了,這個(gè)函數(shù)加載到sql選取記錄集的地方。
如:rsql="select * from table where xxx="&checkstr(request.querystring("xxyy"))&""
或者來(lái)就判斷字符串
說(shuō)的有點(diǎn)林亂,但是就是這些了,對(duì)于普通的"黑客"已經(jīng)足夠他毫些時(shí)間了。但是對(duì)于老到的真正意義的黑客,這些都不是萬(wàn)能的東西,人家連服務(wù)器都黑,你能怎么樣啊?嘿。
看了些資料,結(jié)合自己的經(jīng)驗(yàn),寫(xiě)在這里。算是自己復(fù)習(xí)一下,看到的朋友也可以一起交流!