Since optical drives have terrible seek times and low bandwidth most assets are stored compressed on disc.
Wouldn't this be a trivial and somewhat useful thing to see structure in binary files?
from PIL import Image
def getSize(len, width):
h = int(math.ceil(float(len) / width))
return (width, h)
def getImage(file, width=256):
d = file.read()
s = getSize(len(d), width)
im = Image.new('L', s)
if len(sys.argv) < 2:
print 'Usage: file2img.py <file> <output> [width]'
with open(sys.argv, 'rb') as f:
if len(sys.argv) > 3:
width = int(sys.argv)
img = getImage(f, width)
img = getImage(f)
if __name__ == "__main__":
and related: http://corte.si/posts/visualisation/entropy/index.html (visualizing entropy in binary files)
I used his software on an unknown format from the 1988 game Circuit's Edge to find out if/where the file was encrypted or compressed. It works well and was able to give me a (very) general idea of where in the file I needed to look further.
Edit: Nope, I remembered incorrectly. I used it on the game's .exe to tell me if I was dealing with a compressed executable. It turned out that it was compressed and so I went on a search for an ancient unpacker.
See before and after:
edge.exe packed: http://imgur.com/PlHGl
edge.exe unpacked: http://imgur.com/jeFLb
With the entropy and ASCII printable filters setup, it makes repeating patterns and TEXT sections pretty clear.
echo P4 > file
echo "640 480" >> file
echo 255 >> file
cat binaryBlob >> file