Utility for extracting MIME attachments

26

8

I am looking for a command-line tool for Unix (ideally, available in a Debian / Ubuntu package) for extracting all MIME parts from a multipart email message (or the body from a singlepart with an interesting content-type, for that matter).

I have been using the mimeexplode tool which ships with the Perl MIME::Tools package, but it's not really production quality (the script is included as an example only, and has issues with what it regards as "evil" character sets) and I could certainly roll my own script based on that, but if this particular wheel has already been innovated, perhaps I shouldn't.

tripleee

Posted 2012-03-29T10:26:06.517

Reputation: 2 480

Question was closed 2015-07-31T02:20:33.203

Via another question I came across http://www.pldaniels.com/ripmime/ which looks very nice, but it's not available as an Ubuntu package as far as I can tell.

– tripleee – 2012-06-11T05:52:15.140

Answers

32

munpack from mpack worked for me

In Debian/Ubuntu:

sudo apt-get install mpack
munpack -f mime-attachments-file

DmitrySandalov

Posted 2012-03-29T10:26:06.517

Reputation: 506

Overall a nice solution. Still, as of version 1.6, it does not cope correctly with =<cr><lf> sequences in quoted-printable text (I get a spurious 0xFF byte for each escaped line break in the input). This seems to have been reported in 2011, but still not fixed: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=647180

– tripleee – 2014-10-23T05:35:23.953

18

The mu project seems to include a mu-extract command that looks as if it might do what you want. And it appears to be available as an Ubuntu package already.

NB: I haven't actually used this tool myself.

larsks

Posted 2012-03-29T10:26:06.517

Reputation: 3 245

mu: error: init_mime_msg: cannot construct mime message for noname.eml – Nicolas Raoul – 2014-10-27T06:43:51.493

3If that's a question, you probably want to post an actual question. This answer is over two years old. – larsks – 2014-10-28T00:48:18.633

1sudo apt-get install maildir-utils && mu extract -a <file> – Richard Hansen – 2013-09-20T20:35:58.133

1

I needed to unpack a chrome dmp file in order to extract the minidump for analysis on Ubuntu 12.04.4. I found that the mime file had been written in DOS format despite being in a Linux environment, so neither mpack or maildir-utils worked out of the box. The following steps worked for me:

sudo apt-get install dos2unix mpack
cp chromium-renderer-minidump-c3303784f176fb58.dmp backup
dos2unix -f chromium-renderer-minidump-c3303784f176fb58.dmp
munpack chromium-renderer-minidump-c3303784f176fb58.dmp

The -f on dos2unix is required to force the conversion on a binary file. The maildir-utils mu program crashed trying to read the dmp file even after dos2unix conversion.

fuzzyBSc

Posted 2012-03-29T10:26:06.517

Reputation: 216

-3

  • mpack tools, and munpack
  • GNU base64 decoder
  • mimedecode
  • mha-decode
  • UUDeview
  • OpenSSL

Lazy Badger

Posted 2012-03-29T10:26:06.517

Reputation: 3 557

1-1 I am familiar with all of these except mha-decode and mimedecode, and at least none of the others accept an email message as input, and produces its attachments as output. I will take a look at mha-decode and mimedecode, still. – tripleee – 2012-03-29T17:35:48.197