Extracting images from text mail archives

When you back up or save emails, one format of doing so is in plain text. The attachment to emails are then stored as base64 encoded data in the file. I wrote this script to find known signatures of emails in base64 attachments and write the images out to the disk.

Simply pass it in the file name you want to read from, or it will read from stdin. This just goes to show Ruby still has very high performance, on my system it was processing a test file at 50+ MB/sec. Full code after the break.


How to recover data from .7z files

Suppose you have a .7z file, and the archive is “corrupt”. If it is not corrupt, but missing the end of the archive you will get an error. Here is how you can recover at least some of the data from that.

First step is to take the bad file and see how long the archive is supposed to be. The header has a pointer to the end header in it. At offset 0x0C in the start header is the offset of the end header, stored in 8 bytes.  The next 8 bytes is the length of the end header, which means the end of the file.

Now that you know how big the file was supposed to be, you can recover all of the data that you have but all of the files will be concatenated together. You don’t know the length of any of them, or even how many separate files there are. The important thing though is that you can extract the data.

Windows 10 IoT

I myself am not much of a Windows developer. I have messed around with winapi code a while ago, and some VB.net course in college, but otherwise have developed in other environments. This may change shortly with this new Windows 10 IoT that has been released. Especially seeing that it has Python and Node.js support, I am excited to see if I can try it out.