應對ASP溢出漏洞我們應該做全面的字符過濾 一種是會員登陸 下面這一段代碼是把username的非法字符過濾掉 <% username=trim(request.form("username")) userpws=trim(request.form("password")) if username="" or userpws="" or Instr(username,"=")>0 or Instr(username,"%")>0 or Instr(username,chr(32))>0 or Instr(username,"?")>0 or Instr(username,"&")>0 or Instr(username,";")>0 or Instr(username,",")>0 or Instr(username,"'")>0 or Instr(username,",")>0 or Instr(username,chr(34))>0 or Instr(username,chr(9))>0 or Instr(username,"")>0 or Instr(username,"$")>0 then response.write('' 請正確輸入用戶名和密碼'') response.end end if %> 還有一種是通過地址欄輸入非法字符的溢出漏洞 如 一有頁面為newslist.asp一頁面為newspage.asp 我們從newslist.asp傳遞newsid參數到newspage.asp 在newspage.asp接收參數時一般我們只用, <% dim newsid newsid=request(''newsid'') .................... %> 為安全起見我們至少要加一句 <% dim newsid newsid=tirm(request''id'') if newsid='''' or Instr(newsid,"'")>0 or Instr(newsid,"%")>0 then response.write(''非法參數'') response.end %> 我說的基本上就以上兩點,如有不到之處請多多指教。 雖然在INTERNET中我們還存在著一些漏洞,但我們多輸入幾行代碼就更好地增加了網站的安全性! 利用非法字符溢出漏洞攻擊網站簡單的應對方法
|