0

I have an email stored in plaintext (yes, headers, messages, attachments, everything in one plaintext file) and I'd like to extract a PDF document from it. I've copied the base64-encoded text, then ran it through base64 -d and catted it to a file. I then tried opening it up, which didn't work, and it doesn't appear like a PDF file.

Is there something I'm doing wrong here? I'm fairly certain that it is, indeed, encoded in base64 and that it's a PDF file.

Here is the email:

---------- MESSAGE FOLLOWS ----------
Date: Tue, 6 Mar 2012 12:24:24 -0800 (PST)
From: "Outer, Inc." <[email protected]>
To: Mike Young <[email protected]>
Message-ID: <[email protected]>
Subject: Your results are in, Mike!
MIME-Version: 1.0
Content-Type: multipart/mixed; 
    boundary="----=_Part_0_1998493940.1331065464916"
X-Peer: 127.0.0.1

------=_Part_0_1998493940.1331065464916
Content-Type: multipart/alternative; 
    boundary="----=_Part_1_1254200493.1331065464936"

------=_Part_1_1254200493.1331065464936
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Great job, Mike on your baby!
------=_Part_1_1254200493.1331065464936
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<html>
    <body>
        <h3>Great job, Mike on your baby!</h3>
    </body>
</html>
------=_Part_1_1254200493.1331065464936--

------=_Part_0_1998493940.1331065464916
Content-Type: application/pdf; name="Baby Results.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Baby Results.pdf"

JVBERi0xLjQKJeLjz9MKMyAwIG9iaiA8PC9UeXBlL1hPYmplY3QvQ29sb3JTcGFjZS9EZXZpY2VH
cmF5L1N1YnR5cGUvSW1hZ2UvQml0c1BlckNvbXBvbmVudCA4L1dpZHRoIDI1My9MZW5ndGggMTYx
...
HR5P9F0eg4+P8tWzo2bPl6eGcNwyLqqW+chQi7Fo/CTWPUI7Kud1ZYgpcnSg7do4SKpTy10jyggP
1dVbvqS63pYxNl1JGGcvD1P+VFdN2b7O3YBqXTuiRteun3nmUdcoObmr5qduv09
9
  • 1
    Does it look like plain text? What does file say about it?
    – Kevin
    Mar 6, 2012 at 20:47
  • Updated the question with the email. Mar 6, 2012 at 20:52
  • It decodes fine for me. Run file x.pdf and see what it says the file is.
    – Kevin
    Mar 6, 2012 at 21:01
  • Seems to be a valid PDF file, but I can't seem to view it with anything. Mar 6, 2012 at 21:26
  • 1
    If i decode the beginning of your base64 encoded attachment, I get: %PDF-1.4......, so that looks like a legit PDF file. In the other hand, if I decode the end, I don't see '%%EOF' which would mark the end of a legit PDF file. It seems that your attachment is truncated Mar 8, 2012 at 4:32

1 Answer 1

2

munpack seems like the tool you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .