Skip to content

NewGlad/py-disk-reader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python low-level disk reader

TL;DR: Python implementation for low-level disk (and disk images) reading, parse MBR, file systems, etc.

Installation

py-disk-reader is temporarily unavailable on PyPI.

Use github link to install:

pip install git+https://github.com/bashkirtsevich/py-disk-reader

Examples

FAT12

from hashlib import sha1
from disk_reader import FAT12Reader
from disk_reader.reader import FileReader

with open("images/floppy2.img", "rb") as f:
    img = FAT12Reader(FileReader(f))

    files = list(img.root_dir)

    for i, n in enumerate(files):
        print(i, n.name)

    bar = files[1]
    baz = bar.read()
    print(bar.name, sha1(baz).hexdigest(), baz)

    print("----")

    bar = list(files[6])
    for i, n in enumerate(bar):
        print(i, n.name)

    baz = bar[7].read()
    print(bar[7].name, sha1(baz).hexdigest(), baz)

FAT16

from hashlib import sha1
from disk_reader import FAT16Reader
from disk_reader.reader import FileReader

with open("images/fat16.img", "rb") as f:
    img = FAT16Reader(FileReader(f))

    files = list(img.root_dir)

    for i, n in enumerate(files):
        print(i, n.name)

    bar = files[15]
    baz = bar.read()
    print(bar.name, sha1(baz).hexdigest(), baz)

    print("----")

    bar = list(files[0])
    for i, n in enumerate(bar):
        print(i, n.name)

    baz = bar[3].read()
    print(bar[3].name, sha1(baz).hexdigest(), baz)

FAT32

from hashlib import sha1
from disk_reader import FAT32Reader
from disk_reader.reader import FileReader

with open("images/fat32.img", "rb") as f:
    img = FAT32Reader(FileReader(f))

    files = list(img.root_dir)

    for i, n in enumerate(files):
        print(i, n.name)

    bar = files[3]
    baz = bar.read()
    print(bar.name, sha1(baz).hexdigest(), baz)

    bar = list(files[1])
    for i, n in enumerate(bar):
        print(i, n.name)

    baz = bar[3].read()
    print(bar[3].name, sha1(baz).hexdigest(), baz)

About

Low-level disk reader on Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%