[SQL Injection] 이진탐색 기법으로 데이터 획득하기

 이진탐색 기법으로 데이터 획득하기 



이진 탐색 기법 

  • 이진 검색은 정렬된 리스트에서 중앙 값을 선택하고 해당 값 보다 큰지 작은지 비교해서 데이터를  검색하는 방식입니다 . 
  • 검색이 반복될 때마다 찾을 확률은 두배가 되므로 블라인드 데이터 획득에 적합한 기법입니다 .

이진검색 알고리즘








이진 탐색 알고리즘을 수행한 결과 8번의 요청으로 한글자 획득이 가능하며 "corea" 라는 글자를 획득하기 위해서는 40회의 요청을 수행하면 데이터 획득이 가능합니다 . 


이진 탐색 기법을 이용하여 MySQL 첫번째 ASCII코드 획득하기

case문을 이용하여 결과를 검색합니다 . 








































  1. select case when ascii(substring('corea',1,1))>64 then 1 else 0 end ; => 참
  2. select case when ascii(substring('corea',1,1))>96 then 1 else 0 end ; => 참
  3. select case when ascii(substring('corea',1,1))>112 then 1 else 0 end ; => 거짓
  4. select case when ascii(substring('corea',1,1))>104 then 1 else 0 end ; => 거짓
  5. select case when ascii(substring('corea',1,1))>100 then 1 else 0 end ; => 거짓
  6. select case when ascii(substring('corea',1,1))>98 then 1 else 0 end ; => 참
  7. select case when ascii(substring('corea',1,1))>99 then 1 else 0 end ; => 거짓
  8. select case when ascii(substring('corea',1,1))>99 then 1 else 0 end ; => 거짓
8회 실행하면 첫번째 글자의 ASCII 값 획득이 가능합니다 . 

 

>> select case when ascii(substring('corea',1,1))>99 then 1 else 0 end  ;






댓글