¾È±Ô °øºÎ¹æ

security > ¸ðµç »ç¿ëÀÚ ÀԷ°ªÀ» üũÇÏ´Â Function

µî·ÏÀÏ : 2017-06-30 14:43 Á¶È¸¼ö : 53,622

À̹ø³»¿ëÀº http://www.taeyo.pe.kr/ ȨÆäÀÌÁö¿¡¼­ ¹ßÃéÇÑ ÀÚ·áÀÓÀ» ¾Ë·Áµå¸³´Ï´Ù.    
¿äÁò Sql Injection °ø°ÝÀ¸·Î ÀÎÇØ ¸¹Àº ¼­¹ö °ü¸®ÀÚ¹× °³¹ßÀÚµéÀÌ °í»ýÀ» ¸¹ÀÌ ÇÏ°í ÀÖ½À´Ï´Ù.
¾Æ·¡ ¼Ò½º´Â ÀÌ·± °ø°Ý¿¡ ´ëÇÑ Â÷´ÜÀ» ÇØ ÁÖ´Â ¼Ò½º ÀÔ´Ï´Ù.

µ¥ÀÌŸ º£À̽º Å×À̺í

CREATE TABLE [dbo].[hacking_log](
[board_idx] [int] IDENTITY(1,1) NOT NULL,
[hl_date] [datetime] NULL,
[hl_ip] [varchar](100) COLLATE Korean_Wansung_CI_AS NULL,
[hl_page] [varchar](100) COLLATE Korean_Wansung_CI_AS NULL,
[hl_text] [varchar](2000) COLLATE Korean_Wansung_CI_AS NULL
) ON [PRIMARY]
ASP ¼Ò½º ÄÚµå

TmpHackString = Split("insert,update,select,delete,drop,--,char,exec",",")

strcon="Provider=SQLOLEDB;User ID=sa;Password=;Data Source=¼­¹ö ¾ÆÀÌÇÇ;Initial Catalog=¿¬°áµðºñ;"
Set objCnn = Server.CreateObject("ADODB.Connection") 
objCnn.Open strcon 

Function CheckRequestValue(byVal c_value)
	tmpValue = trim(Lcase(c_value))
	for TmpLoopi = lbound(TmpHackString) to ubound(TmpHackString)
	
		if InStr(tmpValue,TmpHackString(TmpLoopi)) > 0 then 
			' ÇØÅ· °æ°í ¸Þ½ÃÁö	
			tmp_HackLog = "ÀÇ½É ¹®ÀÚ : " & TmpHackString(TmpLoopi) & "<br>"

			For each Query_Item in Request.QueryString
				For i = 1 to Request.QueryString(Query_Item).Count
				  tmp_HackLog = tmp_HackLog & "Request.QueryString(" & Query_Item & ")(" & i & ") = " & Request.QueryString(Query_Item)(i) & "<br>"
				Next
			Next
 
			For each Query_Item in Request.Form
				For i = 1 to Request.Form(Query_Item).Count
				  tmp_HackLog = tmp_HackLog & "Request.Form(" & Query_Item & ")(" & i & ") = " & Request.Form(Query_Item)(i) & "<br>"
				Next
			Next
 

			strSql = " Insert Into hacking_log (hl_date,hl_ip,hl_page,hl_text) values (getdate(),'"&Request.ServerVariables("REMOTE_ADDR")&"'" &_
				 " ,'"&Request.ServerVariables("URL")&"','"&tmp_HackLog&"') "
			set objRs=objCnn.Execute(strSql)
		
			p_html = "Á¢±ÙÁ¦ÇÑ -- SQL ÀÎÁ§¼ÇÀ¸·Î ÆǴܵǾî Á¢±ÙÀ» Á¦ÇÑÇÕ´Ï´Ù.(insert,update,select,delete,drop,--) µîµî"

			response.Write(p_html)         
			response.end
		end if
	Next
End Function 

For each Query_Item in Request.QueryString
	For i = 1 to Request.QueryString(Query_Item).Count
		Call CheckRequestValue(Request.QueryString(Query_Item)(i))
	Next
Next

For each Query_Item in Request.Form
	For i = 1 to Request.Form(Query_Item).Count
		Call CheckRequestValue(Request.Form(Query_Item)(i))
	Next
Next
³Ñ¾î¿À´Â QueryString °ªÀ» ºñ±³ÇÏ¿© TmpHackString ¿¡ Á¤ÀÇÇÑ ¹®ÀÚ°¡ Á¸ÀçÇϸé Á¢±ÙÀ» Á¦ÇÑÇÏ´Â ¼Ò½ºÀÔ´Ï´Ù.

À§ ¼Ò½º´Â ÇêÁ¡ÀÌ ³Ê¹« ¸¹¾Æ¼­ Àúµµ »ç¿ëÀ» ÇÏÁö ¾Ê°í ÀÖ½À´Ï´Ù. ÀÌ·±¹æ¹ýÀÌ ÀÖ´Ù´Â Á¤µµ¸¸ ¾Ë°í °è½Ã¸é µÉ°Å °°½À´Ï´Ù.
 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.