Skip to content

Python library to read Squashfs image files.

License

GPL-3.0, LGPL-2.1 licenses found

Licenses found

GPL-3.0
LICENSE.GPL3
LGPL-2.1
LICENSE.LGPL
Notifications You must be signed in to change notification settings

darktemplarbasealt/PySquashfsImage

 
 

Repository files navigation

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 Python2 and Python3.

Examples:

List all elements in the image:

from PySquashfsImage import SquashFsImage

image = SquashFsImage('/path/to/my/image.img')
for i in image.root.findAll():
    print(i.getName())
image.close()

Print all files and folder with human readable path:

from PySquashfsImage import SquashFsImage

image = SquashFsImage('/path/to/my/image.img')
for i in image.root.findAllPaths():
    print(i)
image.close()

Print only files:

from PySquashfsImage import SquashFsImage

image = SquashFsImage('/path/to/my/image.img')
for i in image.root.findAll():
    if not i.isFolder():
        print(i.getPath())
image.close()

Save the content of a file:

from PySquashfsImage import SquashFsImage

image = SquashFsImage('/path/to/my/image.img')
for i in image.root.findAll():
    if i.getName() == b'myfilename':
        with open(b'/tmp/'+i.getName(),'wb') as f:
            print(b'Saving original '+i.getPath().encode()+b' in /tmp/'+i.getName())
            f.write(i.getContent())
image.close()

About

Python library to read Squashfs image files.

Resources

License

GPL-3.0, LGPL-2.1 licenses found

Licenses found

GPL-3.0
LICENSE.GPL3
LGPL-2.1
LICENSE.LGPL

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.7%
  • Shell 0.3%