uudecode: Decode ‘.doc’ files embedded into your mail

by Amit


Context: I recieved a mail, supposedly containing a ‘.doc’ attachment. However, instead of a ‘separate’ file, I see that for some unknown reason the file contents have been appended to the mail body and appeared something like this:

begin 644 60.doc
MT,\1X*&Q&N$``````````````````
```/@`#`/[_"0`&```````````````!
M````(@``````````$```)`````$```#^____`````"$```#_____________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M_______________________LI<$`(V`)!```\!*_````````$```````!@``
MF@D```X`8FIB:J$5H14````````````````````````)!!8`+A```,-_``##

.
.
.

What you see above is the binary encoded data of the ‘.doc’ attachment. So how do you get back the proper human readable’.doc’ file?

‘uudecode’ to the rescue

A description of the command is reproduced from here:

The uudecode utility shall read a file, or standard input if no file is specified, that includes data created by the uuencode utility. The uudecode utility shall scan the input file, searching for data compatible with one of the formats specified in uuencode, and attempt to create or overwrite the file described by the data (or overridden by the -o option). The pathname shall be contained in the data or specified by the -o option. The file access permission bits and contents for the file to be produced shall be contained in that data. The mode bits of the created file (other than standard output) shall be set from the file access permission bits contained in the data; that is, other attributes of the mode, including the file mode creation mask (see umask() ), shall not affect the file being produced. If either of the op characters ‘+’ and ‘-‘ (see chmod) are specified in symbolic mode, the initial mode on which those operations are based is unspecified.

If the pathname of the file to be produced exists, and the user does not have write permission on that file, uudecode shall terminate with an error. If the pathname of the file to be produced exists, and the user has write permission on that file, the existing file shall be overwritten.

If the input data was produced by uuencode on a system with a different number of bits per byte than on the target system, the results of uudecode are unspecified.

Installing ‘uudecode’

On my Ubuntu 7.04 system, I installed ‘uudecode’ by using:

amit@ubuntu-laptop:~$ sudo apt-get install sharutils

Decoding your files

To decode your files, copy the encoded text into a file, say demo.doc and use the following command


amit@ubuntu-laptop:/media/sda5$ uudecode demo.doc

Subsequently you will see that a new file by the name as originally desired is created. The original file name may be found out by looking at beginning of the encoded file. Here, it is ’60.doc’.

Then you can view the contents using OpenOffice.org or M$ Word

More Information:

Advertisements