#!/usr/bin/python # This is a simple Python script that will # get metadata from an ext2/3/4 filesystem inside # of an image file. # # Developed for PentesterAcademy by Dr. Phil Polstra import sys import os.path import subprocess import struct import time # these are simple functions to make conversions easier def getU32(data, offset=0): return struct.unpack(' \nReads superblock from an image file") exit(1) def main(): if len(sys.argv) < 3: usage() # read first sector if not os.path.isfile(sys.argv[1]): print("File " + sys.argv[1] + " cannot be openned for reading") exit(1) with open(sys.argv[1], 'rb') as f: f.seek(1024 + int(sys.argv[2]) * 512) sbRaw = str(f.read(1024)) sb = Superblock(sbRaw) sb.prettyPrint() if __name__ == "__main__": main()