출처1 : http://www.stechstar.com/user/zbxe/index.php?mid=digital_security&page=2&document_srl=21212&m=0&category=8476

출처2 : http://unabated.tistory.com/entry/Web-Hacking-1%ED%83%84-SQL-Injection





1. MSSQL 기준 해당 데이터베이스 조회


-- db 검색

select name

from master..sysdatabases;

 

-- table 검색

SELECT name FROM sysobjects WHERE xtype = 'U';

 

-- 해당 db table column 검색

select c.name, TYPE_NAME(c.xtype) as type, length

from syscolumns as c,sysobjects as t

where c.id = t.id

        and t.name = 'dreamcis_pretable' -- list colum names and types for master..sometable





2. 대응 방안



-       Request 로 받은 인자는 항상 값의 validate 입증 후 사용(특히 code behind 단에서)

-       Request 로 받은 인자 값 중 해당 특수문자에 대해서 Replace 해야 함

str = replace(str, "<", "&lt")

str = replace(str, ">", "&gt")

str = replace(str, """, "&#34;")

str = replace(str, "|", "&#124;")

str = replace(str, "$", "&#36;")

str = replace(str, "%", "&#37;")

str = replace(str, "'", "&#39;")

str = replace(str, "/", "&#47;")

str = replace(str, "(", "&#40;")

str = replace(str, ")", "&#41;")

str = replace(str, ",", "&#44;")


-       Request 인자를 받아 처리하는 ad-hoc 쿼리 사용금지

-       Request 인자를 받아 처리하는 쿼리는 Proc 또는 Prepared 쿼리로 변경

-       특히 매니지사이트의 경우 IIS 셋팅에서 회사 IP만 허용으로 하고, 나머진 블록 시킨다.

-       IIS 에러 페이지의 내용을 따로 추가하여 만드는 방식으로 IIS 오류 메시지가 외부에 공개되지 않도록 한다.


































Posted by motolies
,