Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ __pycache__/
*.py[cod]
*$py.class

# IDE
.vscode

# C extensions
*.so

Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

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

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

with open("images/floppy2.img", "rb") as f:
img = FAT12Reader(FileReader(f))
Expand Down Expand Up @@ -37,7 +46,8 @@ with open("images/floppy2.img", "rb") as f:

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

with open("images/fat16.img", "rb") as f:
img = FAT16Reader(FileReader(f))
Expand Down Expand Up @@ -66,7 +76,8 @@ with open("images/fat16.img", "rb") as f:

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

with open("images/fat32.img", "rb") as f:
img = FAT32Reader(FileReader(f))
Expand Down
9 changes: 0 additions & 9 deletions fat/__init__.py

This file was deleted.

13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from setuptools import setup, find_packages


setup(
name="disk_reader",
version="0.0.1",
description="Python low-level disk reader",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
packages=find_packages("src"),
package_dir={"": "src"},
python_requires=">=3.6.*"
)
9 changes: 9 additions & 0 deletions src/disk_reader/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from disk_reader.fat.fat12 import FAT12Reader
from disk_reader.fat.fat16 import FAT16Reader
from disk_reader.fat.fat32 import FAT32Reader

__all__ = [
'FAT12Reader',
'FAT16Reader',
'FAT32Reader'
]
4 changes: 2 additions & 2 deletions fat/fat.py → src/disk_reader/fat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from itertools import accumulate, takewhile, repeat
from struct import unpack

from reader import Reader
from utils import groupby, slice_len
from disk_reader.reader import Reader
from disk_reader.utils import groupby, slice_len


class FATException(Exception):
Expand Down
20 changes: 18 additions & 2 deletions fat/fat12.py → src/disk_reader/fat/fat12.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
from struct import unpack
from collections import namedtuple

from .fat import FATTable, FATEntryReader, FATReader, FATEntry, FATDir, FATBootSector
from .signatures import *
from disk_reader.fat import (
FATTable,
FATEntryReader,
FATReader,
FATEntry,
FATDir,
FATBootSector
)
from disk_reader.fat.signatures import (
FAT12_SIGN,
FAT12_ENTRY_PERMS,
FAT12_ENTRY,
FAT12_LFN,
FAT12_ENTRY_SIZE
)
from disk_reader.utils import slice_len


FAT12_STRUCT = namedtuple("FAT12", (it[2] for it in FAT12_SIGN))
FAT12_ENTRY_STRUCT = namedtuple("FAT12Directory", (it[2] for it in FAT12_ENTRY))
Expand Down
20 changes: 17 additions & 3 deletions fat/fat16.py → src/disk_reader/fat/fat16.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
from struct import unpack
from collections import namedtuple

from .fat import FATTable, FATEntryReader, FATReader, FATEntry, FATDir, FATBootSector
from .signatures import *
from disk_reader.fat import (
FATTable,
FATEntryReader,
FATReader,
FATEntry,
FATDir,
FATBootSector
)
from disk_reader.fat.signatures import (
FAT12_ENTRY_SIZE,
FAT16_SIGN,
FAT16_ENTRY_PERMS,
FAT16_ENTRY,
FAT16_LFN,
FAT16_ENTRY_SIZE
)

FAT16_STRUCT = namedtuple("FAT16", (it[2] for it in FAT16_SIGN))
FAT16_ENTRY_STRUCT = namedtuple("FAT16Directory", (it[2] for it in FAT16_ENTRY))
Expand Down
19 changes: 17 additions & 2 deletions fat/fat32.py → src/disk_reader/fat/fat32.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
from struct import unpack
from collections import namedtuple
from disk_reader.fat import (
FATTable,
FATEntryReader,
FATReader,
FATEntry,
FATDir,
FATBootSector
)
from disk_reader.fat.signatures import (
FAT32_SIGN,
FAT32_ENTRY_PERMS,
FAT32_ENTRY,
FAT32_LFN,
FAT32_ENTRY_SIZE
)
from disk_reader.utils import slice_len

from .fat import FATTable, FATEntryReader, FATReader, FATEntry, FATDir, FATBootSector
from .signatures import *

FAT32_STRUCT = namedtuple("FAT32", (it[2] for it in FAT32_SIGN))
FAT32_ENTRY_STRUCT = namedtuple("FAT32Directory", (it[2] for it in FAT32_ENTRY))
Expand Down
17 changes: 17 additions & 0 deletions fat/signatures.py → src/disk_reader/fat/signatures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
from collections import namedtuple

__all__ = [
'FAT12_SIGN',
'FAT12_ENTRY_PERMS',
'FAT12_ENTRY',
'FAT12_LFN',
'FAT16_SIGN',
'FAT16_ENTRY_PERMS',
'FAT16_ENTRY',
'FAT16_LFN',
'FAT32_SIGN',
'FAT32_ENTRY_PERMS',
'FAT32_ENTRY',
'FAT32_LFN'
]

FAT12_SIGN = (
# ( offset, size, name, unpack string)
(0x00, 3, 'JumpInstruction', '3s'),
Expand Down
File renamed without changes.
File renamed without changes.