Friday, January 25, 2013

File System Geography - NTFS


- Create a NTFS file
Prior to Test, I made a NTFS file named ntfs.dd.
Procedures are as below.

(1) Create a File filled with zeros
# dd if=/dev/zero of=./ntfs.dd bs=1024000 count=10
10+0 records in
10+0 records out
10240000 bytes (10 MB) copied, 0.239294 s, 42.8 MB/s

(2) Identify loop device not to use
# losetup -a
# losetup -f
/dev/loop0

(3) Connect ntfs.dd and /dev/loop0
# losetup /dev/loop0 ntfs.dd
# losetup -a
/dev/loop0: [0803]:516098 (/test/ntfs.dd)

(4) format loop0 as NTFS
# mkfs.ntfs /dev/loop0
The partition start sector was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
The number of sectors per track was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
The number of heads was not specified for /dev/loop0 and it could not be obtained automatically.  It has been set to 0.
Cluster size has been automatically set to 4096 bytes.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
Initializing device with zeroes: 100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

(5) Mount loop0 and Copy a file to test
# mount -o loop ./ntfs.dd ./NTFS/
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3             28755580   4829808  22465064  18% /
udev                    513268       232    513036   1% /dev
none                    513268       136    513132   1% /dev/shm
none                    513268       348    512920   1% /var/run
none                    513268         0    513268   0% /var/lock
none                    513268         0    513268   0% /lib/init/rw
none                  28755580   4829808  22465064  18% /var/lib/ureadahead/debugfs
/dev/sda1               233333     23889    197397  11% /boot
/dev/sdb1            206422036    191748 195744668   1% /cases
/dev/loop0                9996      2500      7496  26% /test/NTFS

# cp ~/Desktop/forensics.jpg ./NTFS/
# umount /dev/loop0



- NTFS Layout
VBR(Volume Boot Record) has a $MFT Offset.















- Tracking a NTFS
HexEditor shows file structure. there is the file inputed JPG.(forensics.jpg)







































- VBR(Volume Boot Record)
VBR is first sector of volume. So searching is very easy.
VBR = MBR + reserved

VBR has a $MFT Offset by cluster, size of sector, size of cluster... etc.
For indicating a file like forensics.jpg, Tester go to $MFT.
Because $MFT has all attributes about files.





































- MFT
I checked first cluster of MFT. it is 4. 4 is 4 cluster offset.
a sector is 512. a cluster is 4096. 4 cluster are 16384 => 0x4000.

In 0x4000
I can identify MFT record record signature. The Size of each record is 1024 => 0x400.
The Size of MFT is 0x010400 => 66560.
66560 / 1024 = 65. in other words, MFT has 65 record.

NTFS checks each record like 1024 -> 1024 -> 1024...... -> end of 1024.

































- MFT Record of JPEG(forensics.jpg)
I searched for forensics.jpg at 0x14000 =>81920.
The Start offset of MFT is 0x4000. So 0x14000 - 0x4000 = 0x10000.
0x10000 => 65536 / 1024 = 64. forensics.jpg is record 64.

Each Record has a lot of attributes like MAC times, File Size, File offset.....ETC

The offset of forensics.jpg is 0x1A2. but this value must Multiply 0x1000.
0x1A2 * 0x1000 = 1A21000

The size of forensics.jpg is 5 Cluster
0x1A2000 + 0x5000(5 Cluster) = 1A7000





























- DATA of JPEG(forensics.jpg)
0x1A2000 has JPEG header signature(FFD8). 0x1A6320 has JPEG footer signature(FFD9)




























- Idendify a JPEG(forensics.jpg)
For identification of forensics.jpg, I used dd tool.
if => input
of => output
bs => block size (=block is cluster in unix)
skip => skip as much as block size.

bash-3.2# dd if=ntfs.dd of=forensics.jpg bs=4096 count=5 skip=418
5+0 records in
5+0 records out
20480 bytes transferred in 0.000217 secs (94394886 bytes/sec)

File : forensics.jpg
URL : http://pchs.peachschools.org/sites/pchs.peachschools.org/files/computer-forensics.jpeg




Monday, January 21, 2013

File System Geography - FAT32



- Create a FAT32
# dd if=/dev/zero of=./fat32.dd bs=1024000 count=34
# mkfs.vfat -F 32 fat32.dd



- Identify created FAT32
# file fat32.dd
fat32.dd: x86 boot sector, mkdosfs boot message display, code offset 0x58, OEM-ID " mkdosfs", Media descriptor 0xf8, heads 64, sectors 68000 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 523, serial number 0x98118991, label: " "



- FAT Layout

(1) FAT16
BR Reserved FAT #1 FAT #2 Root Directory               Data              


(2) FAT32
BR Reserved FAT #1 FAT #2     Root Directory             Data            



- Tracking a FAT32

For Tracking a file system, I input a jpeg file named forensics.jpg.
































- Boot Sector
You can identify total Sectors, size of per sector, root directory cluster, size of FAT.




- FAT32 Table



Media Type Partition State Cluster 2 Cluster 3
Cluster 4 Cluster 5 Cluster 6 Cluster 7
Cluster 8 Cluster 9 Cluster 10 Cluster 11
Cluster 12 Cluster 13 Cluster 14 Cluster 15
....................... ...................... ...................... ......................

# Medial Type    -       Hard Disk : F8 FF FF 0F
# Partition State -       Nomal : FF FF FF FF
# Cluster 2         -       Cluster of Root Directory

Hex Value Description
0x?0000000 Empty Cluster
0x?0000001 Reserved Cluster
0x?0000002 ~ 0x?FFFFFEF Used Cluster / Each number is cluster number
0x?FFFFFF0 ~ 0x?FFFFFF6 Reserved Cluster
0x?FFFFFF7 Bad Cluster like bad sector
0x?FFFFFF8 ~ 0x?FFFFFFF End of Cluster



- Moving to FAT1 and FAT2

(1) Moving to FAT1
512 * 32 = 16384 => 0x4000    Move to 0x4000 offset
Because The size of Reseved in FAT32 is 32Sector.

FAT size is 523 Sectors => 523 * 512 = 267776 => 0x41600






























(2) Moving to FAT2
The size of FAT is 26776. => 523 * 512 => 0x41600

Boot Sector + Reserved + FAT1         =    FAT2
        0         +   0x4000  + 0x41600     =    0x45600






























The end of FAT3 is 0x86C00 offset. => 0x45600 + 0x41600

The next of FAT2 is Directory Entry.



- Directory Entry
Name Extender Attr NT Res Reserved Create Time
Create Date Last Access Date First Cluster High Bytes Write Time Write Date First Cluster Low Bytes File Size

# 0 offset of Name
-> 0x00
This Directory is Empty. including under this directory.

-> 0xE5
Deleted Data

-> 0x05
Deleted Data for Japanese. / if it uses 0xE5, It will happen crash.

-> 0x20
If name length is below 8, it uses 0x20.


# Attribute
Hex Value Attribute/td> Description
0x01/td> Read Only Read Only Attribute
0x02/td> Hidden Hidden File Attribute
0x04/td> System OS File
0x08/td> Volume Label Volume Label, It must be root and only one.
0x10/td> Directory Directory
0x20/td> Archive Nomal File
0x0F/td> Long File Name Entry Long File Name Entry not Directory Entry


# Directory Entry Sample































The size of forensics.jpg is 33 Sectores. => 17192 / 512 = 33
forensics.jpg is From 3 sector to 36 Sectors.































File's First : From Data's 3 sector.































File's End :  To Data's 33 sector.































File : forensics.jpg
URL : http://pchs.peachschools.org/sites/pchs.peachschools.org/files/computer-forensics.jpeg