xxd를 사용하여 ramdisk 파일 시스템을 분석할 수 있다.
options
-s[+/-] offset : 어디서부터 보여줄 것?(시작점)
-l len: 나타낼 길이
-g bytes : 몇 바이트씩 나눠서?
$xxd -g 4 -l 0x100 -s 0x400 /dev/ramdisk
Examination
Where to start?
Metadata for FS è Superblock
Where is superblock?
Boot block: data related to booting, 2 sectors (0~0x400)
Superblock: Start at 0x400, Group desc. : start at 0x1000 (4KB)
Examine 0x400 using xxd
inode count : 0x10000
block count : 0x10000
log block size : 0x2
blocks per group : 0x8000
inodes per group : 0x8000
block group number : 0x0
Group 0
- block bitmap : start from 0x11th block (0x11000)
- Inode bitmap : start from 0x12th block
- Inode table : start from 0x13th block
Block group number of an inode: (i_number – 1) / inodes per group ==> 0x8000 2^8 = 32000개
Root inode number of ext2 is ‘2’ (2nd)- From given example ext2 has 0x8000 inodes per group
The block group number for root: (2 – 1) / 0x8000 = 0 // 0번째 그룹으로 가서 1이라는 인덱스로 접근 가능
The index of root inode: (2 – 1) % 0x8000 = 1
The size of an inode is 128 B (0x80B) in ext2
As the index for inode of root is 1
The root inode begins at the 0x80B of the inode table