If you want to ana­lyze an unknown file for it’s con­tent (like a Philips TV firmware image…) it may be use­ful to cre­ate an image out of the binary file. So you can search for pat­terns. Dan Kamin­sky released such a tool (also ref­er­enced in the 23C3-Fudging-with-firmware-analysis speech) — but I couldn’t find it any­more. So I wrote one myself.

Here is a sim­ple exam­ple of a text file (java source):


Now the same file gzipped:


On the first image you may see a pat­tern while on the sec­ond image only ran­dom garbage is vis­i­ble. And ran­dom garbage often means com­pressed or encrypted data.
Another exam­ple of /dev/disk0s1:


No ran­dom garbage but ordered data here…

Down­load fwimage-v0.5.zip here (java source and bina­ries). This is the com­mand line output:

1
2
3
4
5
6
7
8
9
10
11
12
13
bash-3.2$ ./fwimage.sh
fw image — binary visu­al­izer v0.5 — michu@neophob.com — http://www.neophob.com
Usage:
fwim­age if=IN_NAME of=OUT_FILE [x=SIZE] [mode=BW|RGB] [-nomarker] [-avg]
Para­me­ter:
if=INPUT_FILE
of=OUTPUT_FILE, file for­mat is .png
x=X_SIZE OF IMAGE, default is 1024
mode=BW|RGB, BW: 1:1 map­ping, RGB: 1:3 map­ping, default is BW
–nomarker, dis­able marker after 1mb of data
–avg, use aver­age of INPUT_FILE as base

Exam­ple: fwim­age if=myimage of=pic.png x=512 mode=RGB

The mode para­me­ter defines the out­put mode. The BW mode use 1 byte per pixel while the RGB mode use 3 bytes per pixel. So the RGB mode cre­ates smaller but more inac­cu­rate png images.

For a more advanced visual ana­lyzer, check out http://fantascienza.net/leonardo/ar/string_repetition_statistics/string_repetition_statistics.html

Some exam­ples of the Philips firmware 42pfl9703h_10_fus_eng…
42pfl9703h_10_fus_eng, off­set 25mb:

42pfl9703h_10_fus_eng, off­set 27mb:

Some fs exam­ples, jffs2:

squashfs4-lzma: