dmg

package
v1.0.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2025 License: Apache-2.0 Imports: 28 Imported by: 1

README

Documentation

Index

Constants

View Source
const (
	NONE_TYPE  udifChecksumType = 0
	CRC32_TYPE udifChecksumType = 2
)
View Source
const (
	Flattened       udifResourceFileFlag = 0x00000001
	InternetEnabled udifResourceFileFlag = 0x00000004
)
View Source
const (
	ZERO_FILL       udifBlockChunkType = 0x00000000
	UNCOMPRESSED    udifBlockChunkType = 0x00000001
	IGNORED         udifBlockChunkType = 0x00000002 // Sparse (used for Apple_Free)
	COMPRESS_ADC    udifBlockChunkType = 0x80000004
	COMPRESS_ZLIB   udifBlockChunkType = 0x80000005
	COMPRESSS_BZ2   udifBlockChunkType = 0x80000006
	COMPRESSS_LZFSE udifBlockChunkType = 0x80000007
	COMPRESSS_LZMA  udifBlockChunkType = 0x80000008
	COMMENT         udifBlockChunkType = 0x7ffffffe
	LAST_BLOCK      udifBlockChunkType = 0xffffffff
)
View Source
const (
	EncryptedMagic = "encrcdsa"
)

Variables

View Source
var ErrEncrypted = errors.New("DMG is encrypted")
View Source
var ErrNotEncrypted = fmt.Errorf("not an encrypted DMG")

Functions

func DecryptDMGWithKey added in v1.0.26

func DecryptDMGWithKey(path string, keyString string) (string, error)

DecryptDMGWithKey decrypts a DMG file using a hex-encoded key string. The key string should be 72 characters: 32 for AES key (16 bytes) + 40 for HMAC key (20 bytes).

func DecryptDMGWithPassword added in v1.0.26

func DecryptDMGWithPassword(path string, password string) (string, error)

DecryptDMGWithPassword decrypts a DMG file using a password.

Types

type Config added in v1.0.6

type Config struct {
	Password     string
	Key          string
	DisableCache bool
}

Config is the DMG config

type DMG

type DMG struct {
	Footer     UDIFResourceFile
	Plist      resourceFork
	Nsiz       nsiz
	Partitions []Partition
	// contains filtered or unexported fields
}

DMG apple disk image object

func NewDMG

func NewDMG(sr *io.SectionReader) (*DMG, error)

NewDMG creates a new DMG for accessing a dmg in an underlying reader. The dmg is expected to start at position 0 in the ReaderAt.

func Open

func Open(name string, c *Config) (*DMG, error)

Open opens the named file using os.Open and prepares it for use as a dmg.

func (*DMG) Close

func (d *DMG) Close() error

Close closes the DMG. If the DMG was created using NewFile directly instead of Open, Close has no effect.

func (*DMG) DecryptedTemp added in v1.0.26

func (d *DMG) DecryptedTemp() string

func (*DMG) GetSize

func (d *DMG) GetSize() uint64

GetSize returns the size of the DMG data

func (*DMG) Load

func (d *DMG) Load() error

Load parses and verifies the GPT

func (*DMG) Partition added in v1.0.20

func (d *DMG) Partition(name string) (*Partition, error)

Partition returns a partition by name

func (*DMG) ReadAt

func (d *DMG) ReadAt(buf []byte, off int64) (n int, err error)

ReadAt impliments the io.ReadAt interface requirement of the Device interface

func (*DMG) ReadFile added in v1.0.6

func (d *DMG) ReadFile(w *bufio.Writer, off, length int64) (err error)

ReadFile extracts a file from the DMG

type EncryptionHeader added in v1.0.25

type EncryptionHeader struct {
	Magic                [8]byte // "encrcdsa"
	Version              uint32  // 2
	EncIvSize            uint32
	Unknown1             uint32
	Unknown2             uint32
	DataEncKeyBits       uint32
	Unknown3             uint32
	HmacKeyBits          uint32
	UUID                 [16]byte
	Blocksize            uint32
	Datasize             uint64
	Dataoffset           uint64
	Unknown4             [24]byte
	KdfAlgorithm         uint32
	KdfPrngAlgorithm     uint32
	KdfIterationCount    uint32
	KdfSaltLen           uint32
	KdfSalt              [32]byte
	BlobEncIvSize        uint32
	BlobEncIv            [32]byte
	BlobEncKeyBits       uint32
	BlobEncAlgorithm     uint32 // 17
	BlobEncPadding       uint32 // 7
	BlobEncMode          uint32 // 6
	EncryptedKeyblobSize uint32
	EncryptedKeyblob1    [32]byte
	EncryptedKeyblob2    [32]byte
}

type Partition added in v1.0.20

type Partition struct {
	Name   string
	Chunks []udifBlockChunk
	// contains filtered or unexported fields
}

Partition object

func (*Partition) Read added in v1.0.20

func (b *Partition) Read(p []byte) (n int, err error)

func (*Partition) ReadAt added in v1.0.20

func (b *Partition) ReadAt(p []byte, off int64) (n int, err error)

func (*Partition) Write added in v1.0.20

func (b *Partition) Write(w *bufio.Writer, bar ...*mpb.Bar) error

Write decompresses the chunks for a given block and writes them to supplied bufio.Writer

func (*Partition) WriteWithProgress added in v1.0.20

func (b *Partition) WriteWithProgress(w *bufio.Writer) error

type UDIFChecksum

type UDIFChecksum struct {
	Type udifChecksumType
	Size uint32
	Data [32]uint32
}

UDIFChecksum object

type UDIFResourceFile

type UDIFResourceFile struct {
	Signature             udifSignature // magic 'koly'
	Version               uint32        // 4 (as of 2013)
	HeaderSize            uint32        // sizeof(this) =  512 (as of 2013)
	Flags                 udifResourceFileFlag
	RunningDataForkOffset uint64
	DataForkOffset        uint64 // usually 0, beginning of file
	DataForkLength        uint64
	RsrcForkOffset        uint64 // resource fork offset and length
	RsrcForkLength        uint64
	SegmentNumber         uint32 // Usually 1, can be 0
	SegmentCount          uint32 // Usually 1, can be 0
	SegmentID             types.UUID

	DataChecksum UDIFChecksum

	PlistOffset uint64 // Offset and length of the blkx plist.
	PlistLength uint64

	Reserved1 [64]byte

	CodeSignatureOffset uint64
	CodeSignatureLength uint64

	Reserved2 [40]byte

	MasterChecksum UDIFChecksum

	ImageVariant uint32 // Unknown, commonly 1
	SectorCount  uint64

	Reserved3 uint32
	Reserved4 uint32
	Reserved5 uint32
}

UDIFResourceFile - Universal Disk Image Format (UDIF) DMG Footer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL