Squashfs image parser
Project description
PySquashfsImage is a lightweight library for reading squashfs image files in Python. It provides a way to read squashfs images header and to retrieve encapsulated binaries. It is compatible with Python 2.6, 2.7 and Python 3.1+.
Installation
pip install PySquashfsImage
If you are using Python <= 3.2 and need LZMA decompression, install backports.lzma.
For LZ4 decompression, install lz4 (Python 3.7+).
For Zstandard decompression install zstandard (Python 3.7+).
Use as a library
List all elements in the image:
from PySquashfsImage import SquashFsImage
image = SquashFsImage('/path/to/my/image.img')
for item in image.root.find_all():
print(item.name)
image.close()
Print all files and folder with human readable path:
from PySquashfsImage import SquashFsImage
image = SquashFsImage('/path/to/my/image.img')
for path in image.root.find_all_paths():
print(path)
image.close()
Print only files:
from PySquashfsImage import SquashFsImage
image = SquashFsImage('/path/to/my/image.img')
for item in image.root.find_all():
if not item.is_dir:
print(item.path)
image.close()
Save the content of a file:
from PySquashfsImage import SquashFsImage
image = SquashFsImage('/path/to/my/image.img')
for item in image.root.find_all():
if item.name == 'myfilename':
with open('/tmp/' + item.name, 'wb') as f:
print('Saving original ' + item.path + ' in /tmp/' + item.name)
f.write(item.read_bytes())
image.close()
Use as a command
$ pysquashfsimage -h
usage: pysquashfsimage [-h] [-V] file paths [paths ...]
positional arguments:
file squashfs filesystem
paths directories or files to print information about
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
For each path, if it is a directory it will print the mode and name of each contained file, with sizes and symlinks.
If a path is a file, print its content.
Example command:
$ pysquashfsimage myimage.img /bin /etc/passwd
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
PySquashfsImage-0.8.0-py3.10.egg
(25.0 kB
view hashes)
Close
Hashes for PySquashfsImage-0.8.0.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11ea98f54383905a31d3561b43843a5e6dd4a6e0fdf45cda668e8d20cbd27e90 |
|
MD5 | 5605d60b16ea3a12f54d7906c61edbdb |
|
BLAKE2b-256 | 7f0d5f1a6b44c13029d7e6d7fc4f76709f69476e91c194e76c4ae1de34656558 |
Close
Hashes for PySquashfsImage-0.8.0-py3.10.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38eb86e3be72e02fdbbafdd3400af0f4f5ce3950bb79bd41b499e4d5ab341ba1 |
|
MD5 | 9ed0255d7a43f3dcb6b7795aa2f78c7d |
|
BLAKE2b-256 | 6a1379efa2e75c275cebc9b9d715551db8dfcd988336d3e5ee285fc001fa708f |
Close
Hashes for PySquashfsImage-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 499c75ab18a398f160e624bef80040f3b4accdafd896ad3b77fc04eac202a2f0 |
|
MD5 | 441562912c247e45121ea7038306c1f4 |
|
BLAKE2b-256 | e01a3a41172a536b2de9adf4193a083e929e2d75df9c9a5a35254e7ed8807611 |
Close
Hashes for PySquashfsImage-0.8.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49720c79bbc25e57ef79961963babf138feca1510fd89b708557358930b9d7e4 |
|
MD5 | 314885d8efc5fd5bc295fc027071c85b |
|
BLAKE2b-256 | 1759bff4f87be6e32c2070f1d6ec9075b41c93cc6c5b664c0c9f9d3a9a66a9da |