Documentation
¶
Index ¶
- Constants
- type BLKXChunkEntry
- type DMGPartition
- type DMGReader
- func (r *DMGReader) Close() error
- func (r *DMGReader) ExtractAllPartitions(outputDir string) error
- func (r *DMGReader) ExtractFile(partitionIndex int, filePath, outputPath string) error
- func (r *DMGReader) ExtractPartition(partitionIndex int, outputPath string) error
- func (r *DMGReader) GetCompressedSize() uint64
- func (r *DMGReader) GetPartitions() []DMGPartition
- func (r *DMGReader) GetUncompressedSize() uint64
- func (r *DMGReader) ListPartitions()
- func (r *DMGReader) MountPartition(partitionIndex int) (string, error)
- func (r *DMGReader) PrintInfo()
- type DirectoryEntry
- type HFSPlusBTHeaderRecord
- type HFSPlusBTNodeDescriptor
- type HFSPlusCatalogFile
- type HFSPlusCatalogFolder
- type HFSPlusCatalogKey
- type HFSPlusExtentDescriptor
- type HFSPlusFileExtraInfo
- type HFSPlusFileInfo
- type HFSPlusFolderExtraInfo
- type HFSPlusFolderInfo
- type HFSPlusForkData
- type HFSPlusParser
- type HFSPlusPermissions
- type HFSPlusVolumeHeader
- type KolyTrailer
- type MishHeader
- type UUID
- type XMLPropertyList
Constants ¶
const ( // Magic signatures HFSPlusMagic = "H+" HFSXMagic = "HX" // Block sizes DefaultBlockSize = 4096 // File types HFSPlusFileType = 0x0000 // Regular file HFSPlusFolderType = 0x0001 // Directory HFSPlusAliasType = 0x0002 // Alias/Symbolic link HFSPlusHardLinkType = 0x0003 // Hard link // Special file IDs HFSRootFolderID = 2 HFSRootParentFolderID = 1 HFSExtentsFileID = 3 HFSCatalogFileID = 4 HFSBadBlockFileID = 5 HFSAllocationFileID = 6 HFSStartupFileID = 7 HFSAttributesFileID = 8 HFSRepairCatalogFileID = 14 HFSBogusExtentFileID = 15 HFSFirstUserCatalogID = 16 )
HFS+ file system constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BLKXChunkEntry ¶
type BLKXChunkEntry struct { EntryType uint32 Comment uint32 SectorNumber uint64 SectorCount uint64 CompressedOffset uint64 CompressedLength uint64 }
BLKXChunkEntry represents one chunk in a blkx table
type DMGPartition ¶
type DMGPartition struct { Name string ID string Attributes string BlkxData []byte MishHeader MishHeader Chunks []BLKXChunkEntry }
DMGPartition represents a partition in the DMG
type DMGReader ¶
type DMGReader struct {
// contains filtered or unexported fields
}
DMGReader represents a DMG file reader
func NewDMGReader ¶
NewDMGReader creates a new DMG reader
func (*DMGReader) ExtractAllPartitions ¶
ExtractAllPartitions extracts all partitions to the specified output directory
func (*DMGReader) ExtractFile ¶
ExtractFile extracts a specific file from an HFS+ partition Note: This is a placeholder as HFS+ parsing would require additional implementation
func (*DMGReader) ExtractPartition ¶
ExtractPartition extracts a partition to the specified output file
func (*DMGReader) GetCompressedSize ¶
GetCompressedSize returns the total compressed size of all partitions
func (*DMGReader) GetPartitions ¶
func (r *DMGReader) GetPartitions() []DMGPartition
GetPartitions returns the partitions in the DMG
func (*DMGReader) GetUncompressedSize ¶
GetUncompressedSize returns the total uncompressed size of all partitions
func (*DMGReader) ListPartitions ¶
func (r *DMGReader) ListPartitions()
ListPartitions lists all partitions in the DMG
func (*DMGReader) MountPartition ¶
MountPartition extracts a partition to a temporary location and returns the path This is useful for accessing the partition content without writing to disk permanently
type DirectoryEntry ¶
type DirectoryEntry struct { ID uint32 Name string IsDirectory bool DataLength uint64 ResourceLength uint64 CreateDate time.Time ModifyDate time.Time DataFork HFSPlusForkData ResourceFork HFSPlusForkData }
DirectoryEntry represents a file or directory in the HFS+ volume
type HFSPlusBTHeaderRecord ¶
type HFSPlusBTHeaderRecord struct { TreeDepth uint16 // Current depth of the tree RootNode uint32 // Node number of root node LeafRecords uint32 // Number of leaf records in the tree FirstLeafNode uint32 // Node number of first leaf node LastLeafNode uint32 // Node number of last leaf node NodeSize uint16 // Size of a node in bytes MaxKeyLength uint16 // Maximum length of a key TotalNodes uint32 // Total number of nodes in the tree FreeNodes uint32 // Number of free nodes Reserved1 uint16 // Reserved - initialized as zero ClumpSize uint32 // Clump size BTreeType uint8 // 0 for normal B-tree, 1 for index file Reserved2 uint8 // Reserved - initialized as zero Attributes uint32 // Attributes of the B-tree Reserved3 [16]uint32 // Reserved - initialized as zero }
HFSPlusBTHeaderRecord represents a B-tree header record
type HFSPlusBTNodeDescriptor ¶
type HFSPlusBTNodeDescriptor struct { ForwardLink uint32 // Node number of next node BackLink uint32 // Node number of previous node Kind int16 // Kind of node (leaf, index, header, or map) Height uint8 // Height from leaf (0 for leaf) NumRecords uint16 // Number of records in this node Reserved uint16 // Reserved - initialized as zero }
HFSPlusBTNodeDescriptor represents a B-tree node descriptor
type HFSPlusCatalogFile ¶
type HFSPlusCatalogFile struct { RecordType uint16 // Record type (file) Flags uint16 // File flags Reserved1 uint32 // Reserved - initialized as zero FileID uint32 // The unique file ID CreateDate uint32 // Date and time of creation ContentModDate uint32 // Date and time of last content modification AttributeModDate uint32 // Date and time of last attribute modification AccessDate uint32 // Date and time of last access BackupDate uint32 // Date and time of last backup Permissions HFSPlusPermissions // BSD permissions UserInfo HFSPlusFileInfo // Finder information FinderInfo HFSPlusFileExtraInfo // More Finder information TextEncoding uint32 // Text encoding hint Reserved2 uint32 // Reserved - initialized as zero DataFork HFSPlusForkData // Data fork ResourceFork HFSPlusForkData // Resource fork }
HFSPlusCatalogFile represents a file record in the catalog file
type HFSPlusCatalogFolder ¶
type HFSPlusCatalogFolder struct { RecordType uint16 // Record type (folder) Flags uint16 // Folder flags Valence uint32 // Number of files and folders in this folder FolderID uint32 // The unique folder ID CreateDate uint32 // Date and time of creation ContentModDate uint32 // Date and time of last content modification AttributeModDate uint32 // Date and time of last attribute modification AccessDate uint32 // Date and time of last access BackupDate uint32 // Date and time of last backup Permissions HFSPlusPermissions // BSD permissions UserInfo HFSPlusFolderInfo // Finder information FinderInfo HFSPlusFolderExtraInfo // More Finder information TextEncoding uint32 // Text encoding hint for filenames Reserved uint32 // Reserved - initialized as zero }
HFSPlusCatalogFolder represents a folder record in the catalog file
type HFSPlusCatalogKey ¶
type HFSPlusCatalogKey struct { KeyLength uint16 ParentID uint32 NodeNameLength uint16 NodeName []uint16 // Unicode string }
HFSPlusCatalogKey is the key for catalog B-tree nodes
type HFSPlusExtentDescriptor ¶
type HFSPlusExtentDescriptor struct { StartBlock uint32 // First allocation block BlockCount uint32 // Number of allocation blocks }
HFSPlusExtentDescriptor describes the physical location of a contiguous chunk of blocks
type HFSPlusFileExtraInfo ¶
type HFSPlusFileInfo ¶
type HFSPlusFolderExtraInfo ¶
type HFSPlusFolderInfo ¶
type HFSPlusFolderInfo struct { WindowBounds [8]byte Reserved1 uint16 Flags uint16 Location [4]byte Reserved2 uint16 }
Placeholder structs for Finder information
type HFSPlusForkData ¶
type HFSPlusForkData struct { LogicalSize uint64 // Fork's logical size in bytes ClumpSize uint32 // Fork's clump size in bytes TotalBlocks uint32 // Total blocks used by this fork Extents [8]HFSPlusExtentDescriptor // Initial set of extents }
HFSPlusForkData represents the on-disk location of a fork
type HFSPlusParser ¶
type HFSPlusParser struct {
// contains filtered or unexported fields
}
HFSPlusParser represents a parser for HFS+ file systems
func NewHFSPlusParser ¶
func NewHFSPlusParser(partitionPath string) (*HFSPlusParser, error)
NewHFSPlusParser creates a new HFS+ parser from an extracted partition
func (*HFSPlusParser) ExtractFile ¶
func (p *HFSPlusParser) ExtractFile(filePath string, outputPath string) error
ExtractFile extracts a file from the HFS+ volume
func (*HFSPlusParser) ExtractFileToReader ¶
func (p *HFSPlusParser) ExtractFileToReader(filePath string) (io.ReadCloser, error)
ExtractFileToReader extracts a file and returns a reader for its content
type HFSPlusPermissions ¶
type HFSPlusVolumeHeader ¶
type HFSPlusVolumeHeader struct { Signature [2]byte // "H+" for HFS+, "HX" for HFSX Version uint16 // Current version is 4 for HFS+ Attributes uint32 // Volume attributes LastMountedVersion uint32 // Implementation version that last mounted this volume JournalInfoBlock uint32 // Journal info block (0 if no journal) CreateDate uint32 // Date and time of volume creation (Mac OS format) ModifyDate uint32 // Date and time of last modification BackupDate uint32 // Date and time of last backup CheckedDate uint32 // Date and time of last consistency check FileCount uint32 // Number of files in the volume FolderCount uint32 // Number of folders in the volume BlockSize uint32 // Size of allocation blocks in bytes TotalBlocks uint32 // Total number of allocation blocks FreeBlocks uint32 // Number of unused allocation blocks NextAllocation uint32 // Block number to start next allocation search ResourceClumpSize uint32 // Default clump size for resource forks DataClumpSize uint32 // Default clump size for data forks NextCatalogID uint32 // Next unused catalog ID (for files and folders) WriteCount uint32 // Number of times volume has been written to EncodingsBitmap uint64 // Encoding bitmap (for text encoding conversions) FinderInfo [32]byte // Information used by the Finder // Special file locations AllocationFile HFSPlusForkData // Location of allocation bitmap file ExtentsFile HFSPlusForkData // Location of extents overflow file CatalogFile HFSPlusForkData // Location of catalog file AttributesFile HFSPlusForkData // Location of attributes file StartupFile HFSPlusForkData // Location of startup file }
HFSPlusVolumeHeader represents the volume header of an HFS+ file system
type KolyTrailer ¶
type KolyTrailer struct { Signature [4]byte Version uint32 HeaderSize uint32 Flags uint32 RunningDataForkOffset uint64 DataForkOffset uint64 DataForkLength uint64 RsrcForkOffset uint64 RsrcForkLength uint64 SegmentNumber uint32 SegmentCount uint32 SegmentID UUID DataChecksumType uint32 DataChecksumSize uint32 DataChecksum [32]uint32 XMLOffset uint64 XMLLength uint64 Reserved1 [120]byte ChecksumType uint32 ChecksumSize uint32 Checksum [32]uint32 ImageVariant uint32 SectorCount uint64 Reserved2 uint32 Reserved3 uint32 Reserved4 uint32 }
KolyTrailer represents the 512-byte trailer found at the end of DMG files
type MishHeader ¶
type MishHeader struct { Signature uint32 Version uint32 SectorNumber uint64 SectorCount uint64 DataOffset uint64 BuffersNeeded uint32 BlockDescriptors uint32 Reserved1 uint32 Reserved2 uint32 Reserved3 uint32 Reserved4 uint32 Reserved5 uint32 Reserved6 uint32 ChecksumType uint32 ChecksumSize uint32 Checksum [32]uint32 NumberOfBlockChunks uint32 }
MishHeader represents the block metadata for a partition
type XMLPropertyList ¶
type XMLPropertyList struct { Dict struct { ResourceFork struct { Blkx []struct { Attributes string `xml:"Attributes"` CFName string `xml:"CFName"` Data string `xml:"Data"` ID string `xml:"ID"` Name string `xml:"Name"` } `xml:"blkx>dict"` } `xml:"resource-fork>dict"` } `xml:"dict"` }
XMLPropertyList is a simplified structure to parse the XML plist in the DMG