asp
                
              Database Filtering injection
                duraboys
                 2010. 12. 29. 11:36
              
              
                            
        
근대 이거 왜 만들었을까?;;;
Replace 한줄 한줄 넣다 보니 계속 적게 되어 버렸네요
몇년전 인젝션 들어와 난리 칠때 만들었던 펑션입니다.
요즘 간만에 ASP를 뒤적 뒤적 거리는 중이에요 ㅎ
'*******************************************************************
'## Duraboys Plugins Database Filtering
'*******************************************************************
function InjectionFilter(pType)
	if ptype = null then
		InjectionFilter = ""
	Else
		'pType = Trim(pType)
		pType = replace(pType,"1'1","")	'Blind SQL Injection 시 현재 사용 중인 Encapsulating Quites를 알아 내기 위한 에러 유발   
		pType = replace(pType,"1 EXEC SP_(or EXEC XP_)","")	'EXEC를 사용하여 에러를 유발하는 Blind SQL Injection
 		pType = replace(pType,"1 AND 1=1","")	'Blind SQL Injection    
		pType = replace(pType,"1' AND 1=(SELECT COUNT(*) FROM tablenames);","")	'' Table 이름을 찾기 위한 Blind SQL Injection. 일반적으로 아래 tablenames에 추측 가능한 테이블 이름이나, Brute Force를 수행함.     
		pType = replace(pType,"1 AND USER_NAME() = 'dbo'","")	'알고 있는 사용자가 administrator로 Running하고 있는지 확인
		pType = replace(pType,"1\'1","")	' Blind SQL Injection을 위한 에러 유발 코드
		pType = replace(pType,"1' AND non_existant_table = '1","")	' Blind SQL Injection을 위해 존재하지 않는 테이블을 호출함으로써 에러를 유발
		pType = replace(pType,"' OR username IS NOT NULL OR username = '","")	' username 추출     
		pType = replace(pType,"; exec master..xp_cmdshell 'ifconfig'--","")	'프로그램 실행
		pType = replace(pType,"sysobjects","")
		pType = replace(pType,"1 OR 1=1","")
		pType = replace(pType,"1' OR '1'='1","")
		pType = replace(pType,"'1 OR '1=1 --","")
		pType = replace(pType,"' or 1=1 ; --","")
		pType = replace(pType,"' or 1=1 --","")
		pType = replace(pType," A' or 'A'='A","")
		pType = replace(pType,";","")
		pType = replace(pType,"'","")
		pType = replace(pType,"","")
		pType = replace(pType,"?","")
		pType = replace(pType,"\","")
		pType = replace(pType,"\'","")	
		pType = replace(pType,"\'`","")	
		pType = replace(pType,"\`","")
		pType = replace(pType,"/","")
		pType = replace(pType,"%","")
		pType = replace(pType,"--","")
		pType = replace(pType,"<p>","<br>")
		pType = replace(pType,"</p>","")
		pType = replace(pType,"<script","<xscript")
		pType = replace(pType,"script>","xscript>")
		'Response.Write "<script>alert('"&pType&"')</script>"
		pType = replace(pType,"""","xscript>")
		pType = replace(pType,"script>",""")
		pType = replace(pType,"&","&")
		pType = replace(pType,"<","<")
		pType = replace(pType,">",">")
		InjectionFilter = pType
	end if
end Function