본문 바로가기
정보보안/Forensic

[Forensic] 하드디스크 MBR 구조

by Murl0c 2021. 12. 29.
반응형

1. MBR(Master Boot Record)

부팅 시 필요한 부트 코드와 파티션 테이블 정보를 저장하고 있으며, MBR이 손상되면 부팅이 불가능하다. MBR은 하드디스크의 첫 번째 섹터(Sector 0)에 위치하고 있고 512Byte로 구성이 되어 있으며 구성 내용은 다음과 같다.

공통 (512 Byte)(Boot Code(446 Byte)(Code area 440 Byte + Disk Signature 4Byte + Usually nulls 2Byte) + Patition Table(64 Byte)) + Signatrue(2 Byte)

 

0x0 - 0x1B7 MBR code area (440Byte)

0x1B8 - 0x1BB 32-bit disk signature ( optional 4Byte)

0x1BC - 0x1BD 0x000 or 0x5A5A (2Byte)

0x1BE - 0X1FD Patition entries (64Byte)

0X1FE - 0X1FF MBR signature 0x55AA (2Byte)

 

MBR 구조 [출처 : What's at 1st sector/MBR of hard disk(MBR Forensics) (nixhacker.com)]

파티션 테이블은 각 16바이트로 구성되는데 구조와 의미는 다음과 같다.

 

파티션 테이블 구조 [출처 : What's at 1st sector/MBR of hard disk(MBR Forensics) (nixhacker.com)]

 

0x0 - Bootable flag (0x80 - bootable | 0x00 - non-bootable | 0x01-0x07 - Invalid)
0x01 - 0x03 - CHS address of the starting of partition in hard disk
0x04 - Partition type
0x05 - 0x07 - CHS address of the end of partition in hard disk
0x08 - 0x0B - LBA of first sector in the partition
0x0C - 0x0F - Number of sectors in partition 

 

0x04에서 명시되는 파티션 타입

 

0x00 EMPTY 0x01 FAT12
0x04 FAT16 0x05 MS Extended
0x06 FAT16 0x07 NTFS
0x0b FAT32 0x0c FAT32
0x0e FAT16 0x0f MS_ Extended
0x83 Linux 0x85 Linux_ Extended
0xa5 FreeBSD 0xa8 MAC OS X
0xab MAC OS X Boot 0xee EFI GPT DISK

※ 파티션이 4개가 넘어 갈 경우 마지막 테이블은 확장 파티션으로 지정됨

 * 마지막 파티션 테이블의 파일 시스템 타입 0x05

 

MBR을 분석할 수 있는 도구로는 MBR-extractor가 있다.

GitHub - shubham0d/MBR-extractor: A python based tool to extract the MBR and parse its data.

 

GitHub - shubham0d/MBR-extractor: A python based tool to extract the MBR and parse its data.

A python based tool to extract the MBR and parse its data. - GitHub - shubham0d/MBR-extractor: A python based tool to extract the MBR and parse its data.

github.com

 

출처 : What's at 1st sector/MBR of hard disk(MBR Forensics) (nixhacker.com)

 

What's at 1st sector/MBR of hard disk(MBR Forensics)

MBR have lots of details about the hard disk or other storage disk which can be used for forensics purposes. In this article we will analyze the MBR's 512 bytes of data and try to interpret it.

nixhacker.com

 

2. 하드 디스크 헤더

FAT32

 - MS DOS5.0(EB 58 90 4D 53 44 4F 53 35 2E 30)

 

NTFS

 - eR.NTFS(EB 52 90 4E 54 46 53 20)

 

EFI

 - EFI PART(45 46 49 20 50 41 52 54)

 

3. 파티션 VBR 백업 본 확인

FAT32

 1) MBR의 LBA 시작주소를 구하고 10진수로 계산 후 해당 파티션 시작 위치로 이동

 2) FAT32의 VBR 백업 본은 파티션 시작위치 +6을 더한 섹터에 저장

 3) 해당 백업 본 512byte를 복사 후 LBA(VBR의 시작위치)에 복사

  ex) LBA의 값이 3F라면 백업 본은 69섹터에 저장

 

NTFS

 1) MBR의 LBA 시작 주소와 총 섹터 수를 더한 후 -1을 계산하여 NTFS VBR 백업본 확인

   * LBA 시작주소 + 총 섹터 수 - 1

 2) 백업본을 LBA의 시작주소(VBR 위치)에 512Byte 복사

 ex) LBA의 값이 3F, 총 섹터 수가 00 3C 3F C0이라면 3948542 섹터에 저장

 

GPT

 1) MBR의 LBA 시작 주소와 총 섹터 수를 더한 후 -1을 계산하여 EFI 백업본 확인

   * EFI의 총 섹터 수는 EFI 파티션 섹터의 33바이트에 위치

 

Extend(확장 파티션)

 1) 첫 번째 섹터의 파티션 테이블 정보에서 파일 타입 0x05가 확인될 경우 LBA의 시작주소로 이동

 2) LBA의 시작 주소에서 파티션 테이블의 LBA 주소 값을 다시 구한 후 현재 LBA 주소에 플러스

 

4. FAT32 파일 시스템(VBR)

 

 

반응형