2011년 6월 1일 수요일

ASP injection 방어 함수

▣ 설명 : 로그인 창을 통해 특수 기호를 넣어 암호등을 무력화 시키는 인젝션 공격을 막을 수 있다.
▣ 넣는 위치 : 별도의 asp 파일로 만들어 include 시킨다.
                    적용시킬 항목에 ChkBadStr 를 통과시킨다.
(사용 예)
<%
Function ChkBadStr(val)
 val = lcase(val)
    badstrs = "; \  ' = select delete update drop insert shell exec"
    badstr=split(badstrs, " ")
    for i = 0 to Ubound(badstr)
 if instr(1,val,badstr(i)) <> 0 then
     response.write "<script>"
     response.write "alert('허용되지 않는 문자열이 포함되어 있습니다.');"
     response.write "history.back();"
     response.write "</script>"
     response.end
 end if
    next
    ChkBadStr = val
End Function
user_id=ChkBadStr("user_id")
%>

댓글 없음:

댓글 쓰기