Академический Документы
Профессиональный Документы
Культура Документы
Brian Carrier
carrier@atstake.com
@stake
Overview
• Motivation
– EXT3FS
1
@stake
Motivation
@stake
2
@stake
Tools
@stake
3
@stake
The Disk
@stake
4
@stake
• The first 446 bytes are x86 assembly instructions that read
the partition table to identify a bootable partition
• The Partition Table starts at offset 446 and contains four 16-
byte entries (48 bytes total)
@stake
• Entries contain:
– Starting address of partition in CHS and LBA format
– Type of Partition
5
@stake
• There are more than one partition type because only four
entries exist in the MBR Partition Table.
@stake
Sec Extended
(FAT)
Secondary
(NTFS)
? 2002 @stake, Inc. 12 FIRST File System Tutorial
6
@stake
• Displaying:
– fdisk
@stake
– Size
– Type
– Flags
7
@stake
• The disk label can describe partitions that do not exist in the
x86 partition tables
@stake
f a b d e
8
@stake
– Size of partition
• Maximum of 8 or 16 partitions
prtvtoc /dev/rdsk/c0t0d0s2
@stake
9
@stake
• Content Layer
– File content (i.e. blocks, clusters). Most data falls into this category.
• Name Layer
– Human addressing format (i.e. file and directory names)
@stake
10
@stake
FAT
@stake
– FAT16: 4 gigabytes
– FAT32: 8 terabytes
11
@stake
• Boot Sector
– Contains file system details such as sizes and offsets
• Data Area
@stake
12
@stake
@stake
13
@stake
0 0 3 4 5 E 0 8 9 E
0 1 2 3 4 5 6 7 8 9
@stake
14
@stake
@stake
• FAT stores the actual time, not the number of seconds from
a known date
15
@stake
• Long File Name (LFN) Directory Entries are the same size as
normal directory entries, but have a special value in the
attribute flag (all bits are set).
@stake
• reserved (1 byte)
• reserved (2 bytes)
16
@stake
Name Attribute
1234.txt LFN
nopqrstuvwxyz LFN
abcdefghijklm LFN
abcdef~1.txt FILE
@stake
FAT: Example
cluster 5 cluster 6
File File
Root Dir Content
Content
file1 - 5
dir1 - 7 cluster 7 cluster 8
foo.c - 8
File
bar.h - 13 Content
FAT
cluster 13
File
6 E E 9 10 E 0 0 14 E Content
5 6 7 8 9 10 11 12 13 14
? 2002 @stake, Inc. 34 FIRST File System Tutorial
17
@stake
3. When the entry is found, identify the starting cluster (16 for
example)
@stake
18
@stake
@stake
19
@stake
FAT: fsstat
• The fsstat tool lists the important Boot Sector values and a
summary of the FAT.
– Sector Range
• FAT Data
– Sequence of consecutive sectors that are allocated and either the next nonconsecutive
sector or EOF.
@stake
• The clusters in the Data Area contain the file and directory
content data.
• NOTE: TASK will require the sector address and not the
cluster.
20
@stake
@stake
21
@stake
@stake
• In the last cluster, only the sectors that contain data are
overwritten (i.e. slack space)
22
@stake
@stake
23
@stake
Forensics Notes
• Because meta data is not in a static location, it can exist for a long
time before it is overwritten
@stake
24
@stake
• Solaris, HP, and other BSD flavors use the Berkley Fast File
System (FFS)
• We will present FFS first and then show the differences with
EXT2FS
@stake
25
@stake
Group
@stake
• All Cylinder Groups in a given file system are the same size,
which is identified in the Super Block
26
@stake
• Example:
– Sector Size: 512-bytes
– Block Size: 4096-bytes (8 sectors)
– Fragment Size: 1024-bytes (2 sectors)
@stake
0 1 2 3 4 5 6 7
512-byte 4096-byte
1024-byte
sector block
fragment
27
@stake
@stake
• size (8-bytes)
28
@stake
• FFS was designed on research that showed that small files were
more common the large files
@stake
direct single
19 - file
32 33 34 35 ... 100 101 ...
content
direct
32 - file 200 201 ...
content
200 - file
content
29
@stake
• UNIX saves the time & date as the number of seconds since
1/1/1970 UTC.
@stake
• The ‘.’ and ‘..’ directory entries are the first two in all
directories
30
@stake
• inode (4-bytes)
@stake
16 8357 5 file1
16 8358 5 file2
16 8359 5 file3
31
@stake
• Lookup /dir1/file1.dat
3. Analyze each directory entry for the one with the name
“dir1”. Save the inode value in the directory entry, 1810 for
example.
@stake
7. Look for an entry with the name “file1.dat” and save the
associated inode value, 2020 for example.
32
@stake
@stake
• The fsstat tool lists important Super Block values and the
groups layout
• Group Info:
– Block and inode range of each group
– Location of inode table, group descriptor, and Super Block in each group
33
@stake
@stake
• We can view the contents of the file using that inode with
‘icat’:
34
@stake
@stake
• Solaris will not fill up a group with a large file. It will fill up
half of the available blocks, then move on to the next group.
OpenBSD will fill up the group before moving on.
35
@stake
@stake
36
@stake
@stake
– ‘istat’ to get a list of all blocks and fragments that were allocated to a given
inode
37
@stake
EXT2FS
@stake
38
@stake
@stake
39
@stake
@stake
• Linux changed how they deleted files from the 2.2 kernel to
2.4
40
@stake
• debugfs runs on Linux and will let you view and change any
structure
@stake
41
@stake
@stake
42
@stake
@stake
NTFS
43
@stake
NTFS
@stake
• Boot Sector
– Contains file system details such as sizes and offsets
• Data Area
– Content area for files and objects
44
@stake
@stake
• MFT entries are called File structures and have a static size
of 1024 bytes
• Some files will require multiple MFT entries (due to static size)
45
@stake
• LogFile (2)
@stake
NTFS: Attributes
46
@stake
– resident flag
– name length and name (all have a name except the primary data one)
– Virtual Cluster Number (VCN): The address of the cluster in a run with
respect to the beginning of the attribute (0 - n), not the beginning of the file
system (Logial Cluster Number - LCN)
@stake
• Index Root (type 144) and Index Allocation (type 160) (for directory
contents)
47
@stake
• Attribute Type 16
• version
• Owner Id
• Security Id
@stake
• Attribute Type 48
• Character set
48
@stake
• The only attribute that can not have a name is the primary
data attribute, which is typically given the name $Data by
default.
@stake
• One can give the Type and Id (if there are more than one of a
given type) for a specific instance in the form of:
MFT-TYPE-ID
• For example:
49
@stake
• Data that can not fit in the MFT entry is stored in the Data
Area
@stake
NTFS: Directories
50
@stake
• Lookup \dir1\file1.dat
3. Find & read the Index Root and Index Allocation attributes
4. Process the B-Tree and analyze the file name structures for
the one with the name “dir1”. Save the file reference value,
180 for example.
6. Find & read the Index Root and Index Allocation attributes
@stake
7. Process the B-Tree and find the file name structure with
“file1.dat”. Save the reference value, 181 for example.
51
@stake
• The Super Block contains the location of the MFT and the
cluster sizes
• The MFT entry in the MFT describes the location and size of
itself
@stake
52
@stake
• All file and directory meta data is generally located in the MFT
• If the value of the meta data is too large, it will be located in the
Data Area
• The contents of the file can be viewed using icat (with no type or id
value):
# icat -f ntfs ntfs.dd 9901
@stake
• The file’s MFT entry also has all names that it uses (multiple
ones if it has hard-links)
53
@stake
• Only the sectors in the last cluster that are used are
overwritten (slack space)
@stake
54
@stake
Forensics Notes
• Deleted file names will not exist as frequently as with FAT or UNIX
because they will get overwritten when the tree is sorted
• If times in Standard Info are different than File Name, wiping tools
may have been used
@stake
55
@stake
EXT3FS
@stake
EXT3FS: Overview
56
@stake
Summary of Structures
@stake
57
@stake
• Log-structured File Systems work like a log file and append new
data to the “end” of the data
• All data and meta data are written to the current pointer.
@stake
PALM OS
58
@stake
Summary
• Knowledge will also help write tools when ones do not exist
@stake
Software References
http://www.atstake.com/research/tools/task
www.fish.com
www.porcupine.org
www.cerias.purdue.edu/homes/carrier
59
@stake
References
• FAT
– Microsoft FAT32 File System Specification
• FFS
– The Design and Implementation of the 4.4 BSD Operating System
(McKusick, Bostic , Karels , Quarterman)
• EXT2FS
– The extended-2 filesystem overview (Oxman)
@stake
References
• EXT3FS
– Transcript of Stephen Tweedie talk
(olstrans .sourceforge.net/release/OLS2000-ext3/OLS2000-ext3.html)
• NTFS
– Inside Windows 2000 - 3rd Edition (Solomon, Russinovich)
60