소셜로그인 중단 안내

계정으로 로그인 기능이 2023년 11월 16일 중단되었습니다.

아이보스 계정이 사라지는 것은 절대 아니며, 계정의 이메일 주소를 이용해 로그인 하실 수 있습니다.

▶️ 자세한 공지사항 확인

ms-sql 인젝션공격에 대한 기본적인 차단소스입니다.

2008.12.12 12:32

봉끌로드

조회수 6,432

댓글 1

요즘 특히 sql인젝션 공격이 많죠? 제가 의뢰받은 사이트에도 refer페이지 체크에서 보면 로그인 confirm페이지에 엄청 들어오는것을 발견하곤 합니다. 요놈들이 쿼리문으로 장난을 쳐서 db정보를 가져갈라구 하니 참...

sql인젝션 공격에 가장 좋은 방법은 소스부분을 수정하는 것이라고들 합니다.
그래서 asp소스를 사용하시는 분들은 참고하시기 바랍니다.
아래소스를 인크루드하시고 각페이지 상단에 삽입하시면 될겁니다.

예)회원로그인 confirm페이지를 member_confirm.asp라고 가정하고
아래 소스를 sql_injection.asp라고 하겠습니다. 이 파일은 루트에 존재한다고 가정합니다.

-------------------- sql_injection.asp ----------------------
<%
Function cutstringbyte(getstring, limitbyte)

Dim strlen, i, j, returnstring, totalbyte
strlen = Len(getstring)
returnstring = ""
totalbyte = 0
j = 1

For i=1 To strlen
If Asc(Mid(getstring, j, 1)) < 0 Then
totalbyte = totalbyte + 2
Else
totalbyte = totalbyte + 1
End If

If Int(totalbyte) <= Int(limitbyte) Then
returnstring = returnstring + Mid(getstring, j, 1)
Else
Exit For
End If
j = j + 1
Next
cutstringbyte = returnstring

End Function



function myrequest(getstring, cutbyte, securitylevel)
dim str_myrequest, str_lcase
str_myrequest = request(getstring)

if not(str_myrequest = "" or isnull(str_myrequest)) then
cutbyte = int(cutbyte)
securitylevel = int(securitylevel)

if securitylevel > 0 then

'level1
str_myrequest = replace(str_myrequest,"'","''")
str_myrequest = replace(str_myrequest,";","''")
str_myrequest = replace(str_myrequest,":","''")
str_myrequest = replace(str_myrequest,"--","''")
str_myrequest = replace(str_myrequest,"/*","''")
str_myrequest = replace(str_myrequest,"*/","''")

if securitylevel > 1 then

'level2
str_lcase = lcase(str_myrequest)
str_lcase = replace(str_lcase, "exec", "")
str_lcase = replace(str_lcase, "drop", "")
str_lcase = replace(str_lcase, "update", "")
str_lcase = replace(str_lcase, "delete", "")
str_lcase = replace(str_lcase, "select", "")
str_lcase = replace(str_lcase, "insert", "")
str_lcase = replace(str_lcase, "create", "")
str_lcase = replace(str_lcase, "union", "")
str_lcase = replace(str_lcase, "sp_", "")
str_lcase = replace(str_lcase, "xp_", "")

if len(str_lcase) <> len(str_myrequest) then
str_myrequest = str_lcase
end if
end if
end if

if int(cutbyte) <> 0 then
str_myrequest = cutstringbyte(str_myrequest, cutbyte)
end if
end if
myrequest = str_myrequest
end function
%>



------------------- member_confirm.asp --------------------

<!--#include virtual="/sql_injection.asp"//-->
<%

userid = myrequest("id",12,2)
pass = myrequest("pass",12,2)

''위에 12숫자는 최대 지정하는 db 바이트를 의미하고 2는 보안레벨을 의미합니다.

리쿼스트값을 위와 같이 하시면 됩니다.
%>


위 소스는 제가 인터넷을 서핑하면서 몇개소스를 조금 변형해서 사용한겁니다.
궁금한점 있으시면 댓글 달아주세요. 아는데까지 설명해드리죠^^
목록글쓰기
댓글 1
댓글 새로고침

라인_1

12-223,6660

이진수_1

12-213,5370

남궁선

12-217,246-3

물망초_1

12-204,6270

이종연

12-196,655-1

내가게

12-156,049-1

봉끌로드

12-126,4330

정두영

12-114,5460

하늘사람

12-104,5000

내가게

12-095,656-1

내가게

12-085,093-1

윤성진

12-054,0020

손은석

12-023,7730

손은석

12-024,0520

손은석

11-284,1030

손은석

11-284,0980

박철권

11-275,3967

아이스맨

11-274,6290

김세진

11-245,5710

쎄븐원

11-223,9280
목록 글쓰기
로그인 후 더욱 많은 기능을 이용하세요!아이보스 로그인