Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

B-­‐Tree

 Nodes   Catalog  File  


HFS+  File  System  Format  Reference  Sheet  
By:  Sarah  Edwards   Catalog  File  Key  
Twi2er:  @iamevltwin   • Four  types  of  B-­‐Tree  Nodes   Size   Field  
Email:  oompa@csh.rit.edu     • Only  one  Header  Node  per  B-­‐Tree   2   Key  Length  
• Each  B-­‐Tree  Specifies  its  size  in  the  Node  Size  field  of  the  Header  Record   4 Parent  CNID    
(or  CNID  of  file/folder  for  thread  records)  
Volume  Header   Variable   Node  Name  (File  or  Folder  Name)  
HFSUniStr255     2  Byte  Length  +  Variable  Unicode  Name  (<=255)  
Catalog  File/Folder  Record  [88  or  248  bytes]   Catalog  Thread  Record  
Offset   Size     Data  
LocaMon   1024  bytes  from  beginning  of   Special  File  
the  volume   Size  (in  bytes)   Field   Size   Field  
(in  bytes)   Node  Layout  
Size   512  bytes   2 Record  Type     2  Bytes   Record  Type  
Alternate   1024  bytes  from  the  end  of   (0x0001)  –  Folder  Record   (0x0003)  –  Folder  Thread  
0   2   Signature  
Node  Descriptor   Header  Node   Node  Descriptor   Record  
2   2   Version   VH   the  volume   (0x0002)  –  File  Record  
Record  1   Leaf  Node   Header  Record   2 Flags   (0x0004)  –  File  Thread  
4   4   A2ributes   Special  File  Size  &  LocaMon  /  File  Extents  
Record  2   Leaf  Node   User  Data  Record   4 Valence    
Record  
8   4   Last  Mounted  Version   [80  bytes]   2  Bytes   Reserved  
12   4   Journal  Info  Block   …   Index  Node   Map  Record   (File  Records  -­‐  Reserved)  
4  Bytes   Parent  ID  (CNID)  
16   4   Create  Date   Offset   Size   Data   Free  Space   Index  Node   Free  Space   4 File  or  Folder  ID  (CNID)  
HFSUniStr255     Node  Name  (File  or  
(in  bytes)   Offset  to  Free  Space   4 Create  Date   Folder  Name)  
20   4   Modify  Date   Offset  to  Free  Space   Leaf  Node   4 Content  ModificaMon  Date   2  Byte  Length  +    
24   4     Backup  Date   0   8   Logical  Size   …   Leaf  Node   Offset  to  Map  Record   Variable  <=255  Unicode  
4 A2ribute  ModificaMon  Date  
28   4     Checked  Date  
8   4   Clump  Size   Offset  to  Record  2   Index  Node   Offset  to  User  Data  Record   Name  
32   4     File  Count   4 Access  Date  
12   4   Total  Blocks   Offset  to  Record  1   …   Offset  to  Header  Record  
36   4     Folder  Count   4 Backup  Date  
16   4   Extent  1  –  Start  Block   Size     HFSPlusBSDInfo  
40   4     Block  Size   HFSPlusBSDInfo  [16  Bytes] Permissions  
20   4   Extent  1  –  Block  Count   (in  bytes)  
44   4     Total  Blocks   FolderInfo  or  FileInfo  [16  Bytes] User  InformaMon   4 Owner  ID  
24   4   Extent  2  –  Start  Block  
48   4     Free  Blocks   ExtendedFolder  or  FileInfo  [16  Bytes] Finder  InformaMon   4 Group  ID  
52   4     Next  AllocaMon   28   4   Extent  2  –  Block  Count   1 Admin  Flags  
4 Text  Encoding  
56   4     rsrc  Clump  Size   32   4   Extent  3  –  Start  Block   Node  Descriptor  [14  bytes]   1 Owner  Flags  
4 Reserved  
60   4     Data  Clump  Size   36   4   Extent  3  –  Block  Count   Offset   Size   Field   2 File  Mode  
AddiMonal  Fields  for  File  Record  –  See  “File  Extents”  Table  
40   4   Extent  4  –  Start  Block   (in  bytes)   4   iNode  Number  or  
64   4     Next  Catalog  ID   HFSPlusForkData  [80  Bytes]     Data  Fork  
0   4   Forward  Link   Link  Count  or  
68   4     Write  Count   44   4   Extent  4  –  Block  Count  
HFSPlusForkData  [80  Bytes]     Resource  Fork   Raw  Device  
72   8     Encoding  Bitmap   48   4   Extent  5  –  Start  Block   4   4   Backward  Link  
8   1   Kind:  
80   4     Finder  Info  Array  [0]   52   4   Extent  5  –  Block  Count  
0xFF  –  Leaf  Node  (-­‐1)   AOributes  File  
84   4     Finder  Info  Array  [1]   56   4   Extent  6  –  Start  Block   0x00  –  Index  Node  (0)  
88   4     Finder  Info  Array  [2]   60   4   Extent  6  –  Block  Count   0x01  –  Header  Node  (1)  
0x02  –  Map  Node  (2)   A2ributes  Key   A2ributes  Record  
92   4     Finder  Info  Array  [3]   64   4   Extent  7  –  Start  Block  
96   4   Finder  Info  Array  [4]   68   4   Extent  7  –  Block  Count   9   1   Height   Size     Field   Size  
10   2   Number  of  Records   (in  bytes)   (in  bytes)   Field  
100   4     Finder  Info  Array  [5]   72   4   Extent  8  –  Start  Block  
12   2   Reserved   2   Key  Length   4 Record  Type    
104   4     Finder  Info  Array  [6]   76   4   Extent  8  –  Block  Count  
2   Pad   (0x00000010)  
108   4     Finder  Info  Array  [7]  
4   File  ID  (CNID)   Inline  Data  A2ribute  
112   80   AllocaMon  File  Size  &  LocaMon   Header  Record  [46  bytes]   4   Start  Block   8 Reserved  
192   80   Extents  File  Size  &  LocaMon   2   A2ribute  Name  Length   4 A2ribute  Size  
Header  Node   Offset   Size   Field  
272   80   Catalog  File    Size  &  LocaMon   Header  Record   (in  bytes)   Variable   A2ribute  Name   Variable   A2ribute  Data  
352   80   A2ributes  File  Size  &  LocaMon   User  Data  Record     0 2 Tree  Depth  
432   80   Startup  File  Size  &  LocaMon   Map  Record   2 4 Root  Node   Extents  Overflow  File  
6 4 Leaf  Records  
Map  Node   10 4 First  Leaf  Node  
Catalog  Node  ID  Reserva7ons   Map  Records*  
Extents  Overflow  Key  [12  bytes]   Extents  Overflow  Record  
14 4 Last  Leaf  Node  
*See  Alloca*on  Table  Format   18 2 Node  Size   Size     Field   Size   Field    
CNID   Reserva7on   HFS+  Special  File  Extrac7on  from     20 2 Max  Key  Length    (in  bytes)    (in  bytes)   (For  Each  Eight  
1   Root  Parent   Index  Node   22 4 Total  Nodes   2 Key  Length   Extents)  
Image  File  using  The  Sleuth  Kit   26 4 Free  Nodes   1 Fork  Type   4 Start  Block  
2   Root  Folder   Pointer  Records  
3   Extents  Overflow  File   icat -f hfs –o <partitionoffset> 30 2 Reserved   0x00  -­‐  Data   4 Block  Count  
4   Catalog  File   *.dd <inode> > special_file Size  (in   Field   32 4 Clump  Size   0xFF  -­‐  Resource  
5   Bad  Block  File   bytes)   36 1 B-­‐tree  Type:   1 Pad  
6   AllocaMon  File   2   Key  Length   0x00  –  HFS  B-­‐Tree  (0)   4 File  ID  (CNID)  
7   Startup  File   Variable Key  (For  Catalog  File:  Parent   0x80  –  User  B-­‐Tree  (128)   4 Start  Block  
8   A2ributes  File   CNID  +  HFSUniStr255)   0xFF  –  Reserved  (255)  
14   Repair  Catalog  File   4 Node  Number   37 1 Key  Compare  Type:   Alloca7on  File  (with  Examples)  
15   Bogus  Extent  File   0xCF  or  0xC7  -­‐  Case-­‐insensiMve  
16   First  User  Catalog  Node   Leaf  Node   0xBC  -­‐  Case-­‐sensiMve  
Data  Records   0x00  -­‐  Unknown   1  bit  per  allocaMon  block  (512  bytes),  
38 4 A2ributes:   8  blocks  per  byte  (4,096)  
HFS+  File  System  Format  References  &  Resources:   Size     Field   42 4 Reserved  [16]  (64  bytes)   Most  Significant  Bit  –  Status  of  block  with  lowest  number  
• Apple  Tech  Note  1150  –  Available  at  dubeiko.com/development/FileSystems/HFSPLUS/tn1150.html   (in  bytes)   Least  Significant  Bit  –  Status  of  block  with  highest  number  
• The  Sleuth  Kit  Source  –  Available  at  github.com/sleuthkit/sleuthkit/blob/master/tsk/fs/tsk_hfs.h   2   Key  Length  
Hex   Binary   Alloca7on  
HFS+  Data  is  Big  Endian  
• Mac  OS  X  Internals:  A  Systems  Approach  by  Amit  Singh  –  Chapter  12   4 Parent  CNID  
• Mac  OS  X  and  iOS  Internals:  To  the  Apple’s  Core  by  Jonathan  Levin  –  Chapter  16   Variable Data  Size  [2  bytes]  +  Data     0x00 00000000 No  Blocks  Allocated  
• Apple  Open  Source  -­‐  h2p://www.opensource.apple.com/source/xnu/xnu-­‐2050.18.24/bsd/hfs/hfs_format.h   (Empty  String  0x0000  in  thread   0xFF 11111111 All  Blocks  Allocated  
records)  
(+padding  byte  if  key  length  is  
odd)  
GPT  is  Li2le  Endian   0x1F
0x80
0x07
00011111
10000000
00000111
Lowest  three  blocks  are  unallocated  
Lowest  block  is  allocated  
Highest  three  blocks  are  allocated  
Updated 7/2016
0xF0 11110000 Highest  four  blocks  are  unallocated  
Live  Response   Image  Mount  &  Eject  
SANS  FOR518  Reference  Sheet   date
hostname
Local  System  Time  (-­‐u  for  UTC)  
System  Hostname  
Method  1  -­‐  xmount   $
$
mkdir /Volumes/dademurphy_image/ 
mkdir /Volumes/dademurphy_mounted/ 
By:  Sarah  Edwards  |  Twi2er:  @iamevltwin  |  Email:  oompa@csh.rit.edu     $ sudo xmount --in ewf --out dmg ~/FOR518/dademurphy.E01 /Volumes/dademurphy_image/ 
uname –a OS  &  Architecture  InformaMon  
$ hdiutil attach –nomount /Volumes/dademurphy_image/dademurphy.dmg
sw_vers OS  X  Version  &  Build   $ mount_hfs –j –o rdonly,noexec,noowners /dev/disk# /Volumes/dademurphy_mounted/
Directory  Commands   netstat –anf inet or netstat -an AcMve  Network  ConnecMons   Method  2  -­‐  mountewf   $ mkdir /Volumes/dademurphy_image/
cd .. Change  Directory…up  one  directory  (../..  –  two  directories  up)   lsof -i AcMve  Network  ConnecMons  (by  process)   $ mkdir /Volumes/dademurphy_mounted/
cd /var/log Change  Directory…to  /var/log   netstat -rn RouMng  Table   $ ewfmount ~/FOR518/dademurphy.E01 /Volumes/dademurphy_image/
cd ~ Change  Directory…to  your  home  directory   arp -an ARP  Table   $ ln –s /Volumes/dademurphy_image/ewf1 ~/FOR518/dadeimage.dmg
cd / Change  Directory…to  the  root  directory   ifconfig Network  Interface  ConfiguraMon  
$ hdiutil attach -nomount ~/FOR518/dadeimage.dmg
ls List  Directory  (Short  LisMng)   $ mount_hfs -j -o rdonly,noexec,noowners /dev/disk# /Volumes/dademurphy_mounted/
lsof List  Open  Files  
ls -l List  Directory  (Long  LisMng)   Eject  Disk   $ diskutil list
who –a, w List  Logged  On    Users   $ diskutil eject /dev/disk#
ls -a List  Directory  items…including  hidden  items  (files  beginning  with  “.”)   last List  user  logins   $ mount
ls -lh List  Directory  items…with  human  readable  sizes   ps aux List  Processes   $ umount /Volumes/dademurphy_image/
ls -R List  Directory  items…recursively     system_profiler -xml System  Profiler    (XML,  Full  Detail  Level)  
Timestamp  Formats  
open . Open  Current  Directory   -detaillevel full > file.spx
HFS+/MacOS   32-­‐bit  -­‐  Number  of  seconds  from  1/1/1904  00:00:00  UTC  
pwd Print  Working  Directory   Disk  &  Par77ons   UNIX  Epoch   32-­‐bit  -­‐  Number  of  seconds  from  1/1/1970  00:00:00  UTC  
mkdir Create  a  Directory   /dev/ Device  Directory   Mac  Epoch/Mac  Absolute/Cocoa/WebKit   32-­‐bit  -­‐  Number  of  seconds  from  1/1/2001  00:00:00  UTC  
rmdir Remove  a  Directory   diskutil list List  Connected  Disks   Property  List  Dates  in  Xcode   Local  Host  System  Time  
rmdir –R Remove  a  Directory  (and  its  contents)   diskutil info <disk> Disk  InformaMon  (use  Disks  /dev/disk#,  disk#,  or  parMMons  /dev/disk#s#)  
. Current  Directory   pdisk –l /dev/disk3 List  parMMons  using  Apple  ParMMon  Map  Format  
.. Parent  Directory   gpt –r show [-l] List  parMMons  using  GUID  ParMMon  Table  Format  (-­‐l  to  show  label  rather  than  
GUID)  
File  Commands   mmls <diskimage> Display  parMMons  using  The  Sleuth  Kit  
pico <filename> Open  a  file  in  a  simple  text  editor  (q  –  to   hdiutil imageinfo *.dmg Disk  Image  InformaMon    including  ParMMon  Data  
quit  editor)   hdiiutil fsid *.dmg Volume  Header  InformaMon  of  Disk  Image  
xxd <filename> Open  a  file  in  a  hex  editor  
User  Domain   Hostname   Directory   Command  
open <filename> Opens  a  file  in  the  default  program  
dscl . -read /Users/ Command-­‐line  version  of  Directory  UMlity,  read  user  informaMon  
open –a <programname> <filename> Opens  a  file  in  a  specified  program   <useraccount>
Concatenate  a  file  to  the  terminal  screen   Username  
cat <filename> strings *.keychain Show  the  strings  of  a  Keychain  file  
<command> | more Pipe  command  output  to  more  to  show   security list-keychains List  Keychains  on  a  system  for  a  logged  in  user  
contents  screen  by  screen   security dump-keychains Dump  contents  of  a  Keychain   Number  of   nibble:/ sledwards$ ls -la
<command> | less Pipe  command  output  to  less  to  show   512-­‐byte   total 1014190
Extended  AOributes  
<keychain>
contents  screen  by  screen  (and  be  able  to   Blocks  Used   drwxr-xr-x@ 41 root wheel 1462 Feb 16 21:14 .
xattr –xl <file> Show  Extended  A2ributes  of  a  file  
go  back  and  forth)  
xattr -p <attribute name> <file> | xxd -r -p Extract  embedded  binary  property  list   drwxr-xr-x@ 41 root wheel 1462 Feb 16 21:14 ..
rm <filename> Remove  File  
>output_file.plist from  extended  a2ribute.   d--x--x--x+ 8 root wheel 272 Nov 5 01:11 .DocumentRevisions-V100
cp <filename> <newfilename> Copy  File   istat /dev/disk# <CNID> Use  The  Sleuth  Kit  to  view  file  informaMon  
mv <filename> <newfilename> Move  File  
d-wx-wx-wt 2 root wheel 68 Nov 4 21:05 .Trashes
including  extended  a2ributes.  
-rw-r--r--+ 1 sledwards admin 312 Mar 9 2013 .apdisk
<command> > <filename> Redirect  command  output  to  a  file   icat /dev/disk# <CNID>-<TSK Attribute Number> View  a  specific  extended  a2ribute  using  
The  Sleuth  Kit  
srwxrwxrwx 1 root wheel 0 Feb 15 21:29 .dbfseventsd
<command> >> <filename> Append  command  output  to  a  file  
Log  Analysis   lrwxr-xr-x@ 1 root wheel 11 Sep 23 08:47 etc -> private/etc
touch <filename> Create  an  empty  file  
bzcat system.log.1.bz2 system.log.0.bz2 Create  a  “all-­‐in-­‐one”  system.log  file.   -rwxr-xr-x@ 1 root wheel 8393032 Sep 29 22:39 mach_kernel
head <filename> Show  first  10  lines  of  a  file  
>> system_all.log
tail <filename> Show  last  10  lines  of  a  file  (-f  to  watch  
$ cat system.log >> system_all.log
appended  input)  
syslog –f <file> View  ASL  File  
strings <filename> Show  the  strings  of  a  file  
syslog –d <directory> View  a  directory  of  ASL  Files  
exiftool <filename> Show  the  exif/metadata  of  the  file  
syslog –T utc –F raw –d /var/log/asl Output  ASL  files  the  /var/log/asl  directory  and  output  in  
plutil –p <propertylist> Print  the  contents  of  a  property  list  
raw  format  with  UTC  Mmestamps.  
file <filename> Show  a  file  signature  type   praudit –xn /var/audit/* View  audit  logs  in  XML  format  without  user/group  
grep –i <searchterm> <filename> Search  for  term  within  a  file  (case-­‐ resoluMon.  
insensiMve)   Time  Machine  
python <file>.py Execute  a  Python  program   tmutil uniquesize <machinedirectory_path>/* Show  the  unique  sizes  of  each  snapshot   GPT  Header  
Miscellaneous  Commands   tmutil calculatedrift Show  the  size  changes  (added/removed/changed)   Offset   Size     Field   GPT  Reference  
<machinedirectory_path> between  each  snapshot.   (bytes)  
sudo <command> Execute  program  as  another  user  (default  is  root  user)  
tmutil compare <snapshotdirectory1> Compare  the  file  changes  (added/removed/
sudo -s Open  a  privileged  shell   changed)  between  two  snapshots..   0   8   Signature  (EFI  PART)  
<snapshotdirectory2> GPT  Table  Entry  
su - SubsMtute  User  to  root   Encrypted  Containers   8   4   Revision  (1.0)  
Offset   Size  (bytes)   Field  
whoami Display  EffecMve  User  ID   hdiutil attach –readonly –nomount –stdinpass Mount  a  FileVault  volume  using  a   12   4   Size  of  Header  (bytes)  
history Command  History   filevault2image.dmg password   0   16   ParMMon  Type  GUID  
16   4   Header  CRC32  
man <command> Command  Manual  (q  –  to  exit  manual)   $ security unlock-keychain Access  and  mount  a  FileVault  volume   16   16   Unique  ParMMon  GUID  
FileVaultMaster.keychain using  a  master  password   20   4   Reserved  
32   8   StarMng  LBA  (Li2le  Endian)  
Terminal    Shortcuts   $ diskutil corestorage unlockvolume <UUID> - 24   8   LBA  of  GPT  Header  
Ctrl  +  A   Jump  to  beginning  of  line   recoverykeychain FileVaultMaster.keychain 32   8   LBA  of  Backup  GPT  Header   40   8   Ending  LBA  (Li2le  Endian)  
Ctrl  +  E   Jump  to  end  of  of  line   diskutil corestorage unlockvolume <UUID> - Mount  a  FileVault  volume  using  the   40   8   First  Usable  LBA   48   8   A2ributes  
passphrase <recovery key> Recovery  Key  
Tab   Tab  CompleMon   48   8   Last  Usable  LBA   56   72   ParMMon  Name  
hdiutil attach -readonly -nomount -stdinpass Mount  an  Encrypted  DMG  File  
Ctrl  +  C   Kill  Current  Command   sekretstuff_USB.dmg 56   16   Disk  GUID   128   Rest   Reserved  
Command  +  K  or  Ctrl  +  L   Clear  Screen  (or  clear  command)   Spotlight 72   8   StarMng  LBA  of  GUID  ParMMon  Table  
Command  +  T   New  Terminal  Tab   mdls <file> List  the  Spotlight  metadata  for  a  file   (Li2le  Endian)   Type   Common  GPT  Par77on  GUIDs  
Command  +  W   Close  Terminal  Tab   mdfind Find  files  based  on  a  specific  metadata  query   80   4   Number  of  ParMMon  Entries  Available   EFI  System  ParMMon   C12A7328-­‐F81F-­‐11D2-­‐BA4B-­‐00A0C93EC93B
Command  +/-­‐   Increase  or  Decrease  Terminal  Font  Size   mdimport -X Print  a  list  of  a2ributes  that  can  be  queried.   (Li2le  Endian)   HFS+  ParMMon   48465300-­‐0000-­‐11AA-­‐AA11-­‐00306543ECAC
84   4   Size  of  ParMMon  Entry   Apple  Boot  ParMMon   426F6F74-­‐0000-­‐11AA-­‐AA11-­‐00306543ECAC
Generic  Tool  Compila7on  and  Installa7on   Disk  Arbitra7on   88   4   ParMMon  Entry  Array  CRC32   Apple  Core  Storage     53746F72-­‐6167-­‐11AA-­‐AA11-­‐00306543ECAC
tar –xvf <archive>.tar.gz sudo launchctl load /System/Library/LaunchDaemons/com.apple.diskarbitrationd.plist Enable     (FileVault)  
92   Rest   Reserved   Basic  Data  ParMMon     EBD0A0A2-­‐B9E5-­‐4433-­‐87C0-­‐68B6B72699C7
./configure sudo launchctl unload /System/Library/LaunchDaemons/com.apple.diskarbitrationd.plist Disable    
make (Boot  Camp)  
ps auxw | grep diskarbitrationd Determine  Status  
sudo make install

You might also like