Giter Site home page Giter Site logo

py-disk-reader's Introduction

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)

py-disk-reader's People

Contributors

bashkirtsevich avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.