Recovering data from ext2 (and ext3)

Translation of the original in Catalan. Read it in: CatalàCastellano

Reading through linuxsecurity I've come across a very interesting article with links to even more interesting articles about the number of little things that our beloved and obsolete ext2 has, but which ext3 keeps...

tb we can find things as itneresting as the following in the article:

Let us start with the classic method to hide material on UNIX filesystems (not even ext2 specific). Run a process that keeps the file open and then remove the file. The file contents are still on disk and the space will not be reclaimed by other programs. It is worthwhile to note that if an executable erases itself, its contents can be retrieved from /proc memory image: command "cp /proc/$PID/exe /tmp/file" creates a copy of a file in /tmp.

You'll tell me you haven't been gobsmacked after reading this, who hasn't ever deleted a daemon by mistake with the process running and then had to reinstall the whole package. Well you can see how easy it is to recover it from RAM and put it back on our HD.

In the article tb it's commented how to recover files deleted with /bin/rm, as long as they haven't been overwritten, of course. In fact, there's a mini-HOWTO that talks about the subject:

-Linux Ext2fs Undeletion mini-HOWTO

and if what we want is a little program that does the work for us:

-e2undel

-recover

In fact the article in question what it really raises for us is:

On a 4GB Linux partition, the block size is typically 4K (chosen automatically when the mke2fs utility is run to create a filesystem). Thus one can reliably hide up to 4KB of data per file if using a small file. The data will be invulnerable to disk usage, invisible from the filesystem, and, which is more exciting for some people, undetectable by file integrity checkers using file checksumming algorithms and MAC times. Ext2 floppy (with a block size of 1KB) allows hiding data as well, albeit in smaller chunks.

Something we all knew, but which we had surely never considered taking advantage of this space. So if we want to do it now we already have a tool to do it:

-bmap

well now I've already whetted your appetite, in other words, if you want more info the article is this one:

-Linux Data Hiding and Recovery