facedancer.devices.umass.disk_image module

class facedancer.devices.umass.disk_image.DiskImage[source]

Bases: object

Class representing an arbitrary disk image, which can be procedurally generated, or which can be rendered from e.g. a file.

Currently limited to representing disk with 512-byte sectors.

close()[source]

Closes and cleans up any resources held by the disk image.

get_data(address, length)[source]
get_sector_count()[source]

Returns the disk’s sector count.

get_sector_data(address)[source]

Returns the raw binary data for a given sector.

get_sector_size()[source]
put_data(address, data)[source]
put_sector_data(address, data)[source]

Sets the raw binary data for a given disk sector.

class facedancer.devices.umass.disk_image.FAT32DiskImage(size=268435456, verbose=0)[source]

Bases: DiskImage

Class for manufacturing synthetic FAT32 disk images.

BPB_SECTOR = 2048
CLUSTER_SIZE = 512
DATA_SECTION_START = 10146
FAT_END = 6113
FAT_START = 2080
FSINFO_SECTOR = 2049
MBR_SECTOR = 0
ROOT_DIR_ENTRY = 10146
get_partition_sectors()[source]

Get the amount of sectors available for use by our main FAT partition.

get_sector_count()[source]

Returns the total number of sectors present on the disk.

get_sector_data(address)[source]

Fetches the data at the given sector of our emulated disk.

handle_bpb_read(address)[source]

Returns a valid Boot Parameter Block, which tells the device how to interpret our FAT filesystem.

handle_fat_read(address)[source]

Handles an access to the device’s file allocation table.

handle_fsinfo_read(address)[source]

Returns a valid filesystem info block, which is used to cache information about free sectors on the filesystem. We don’t actually sport writing, so we return a valid-but-useless block.

handle_mbr_read(address)[source]

Returns a master boot record directing the target device to our emulated FAT32 partition.

handle_root_dir_read(address)[source]

Returns a valid entry describing the root directory of our FAT filesystem.

handle_unhandled_sector(address)[source]

Handles unsupported sector reads.

class facedancer.devices.umass.disk_image.RawDiskImage(filename, block_size, verbose=0)[source]

Bases: DiskImage

Raw disk image backed by a file.

close()[source]

Closes and cleans up any resources held by the disk image.

get_sector_count()[source]

Returns the disk’s sector count.

get_sector_data(address)[source]

Returns the raw binary data for a given sector.

put_data(address, data)[source]
put_sector_data(address, data)[source]

Sets the raw binary data for a given disk sector.