Wednesday, August 11, 2004

Who UUEd it?

This notification has been sent to inform you that a message has been deleted by the XXXXXXXXX mail gateway (@@@##@#@#@#@).
Rule: "Incoming Policy"
sender: xx dot uu /a t/ pp dot qq
Recipients: uu dot xx /a t/ pp dot qq
Subject: "Results for the month of May"
Incident time: Mon Jul 12 21:57:16 2004

Great! So my email has been deleted because it contained a zip file as an attachment! And, that's the case with all the attachments! From DOC to ZIP!
O great master! I seek thy blessings. Pray tell me how do I send email without my mail server deleting the attachments?
Your mail server deletes the attachments?
Yes master, my mail server deletes all the attachments from my mails!
All the attachments?
Yes master!
Are you sure, are all the attachments deleted without discrimination?
Actually, lemme dot txt files are not deleted. And, images also go through!
What do you mean txt files and images are not deleted?
You see master, there was this virus which spread itself by sending out emails with zipped attachments. And, that too encrypted with a password which was part of the email body. Since some antivirus makers couldn't add the intelligence in their products to understand the mail content, and figure out the password from the mail and then use it to decrypt the zip and then clean the zip, they suggested system administrators of mail servers to delete all mails with zip attachments. Now, it doesn't take much time for the word to spread and one network admin to other the *best practice* spread and they all decided that it was a wise suggestion to prevent all emails with zip attachments. I won't blame their paranoia though, since it is very possible to have another virus attack based on the zip file attachment, now that zip files have become integrated with the Windows Shell since Windows XP(If Phil Katz were around, he would have been very proud! Made the software world so much smaller!). Anyway, so master, since txt files and images do not have executable code, most email servers still allow them to pass through as attachments.
So why don't you send your attachments as either txt or images?
Hahahaha, you surely know how to crack a joke, eh Master! Everyone knows that even if I rename my zip or exe to txt and send it across, the antivirus program has the intelligence to see that and still delete the attachment. C'mon master, you can do better than that!
Are you sure renaming is the only option to convert a binary file to txt files?
I am not aware of any other way.
Are you sure you aren't aware? Now, tell me something, what makes a txt file a txt file, as in what is the reason for the ubiquity of the text file?
Text files have been around since the BIG-BANG days. The ubiquity of those files comes from the fact that it is just the first 127 characters of the ASCII set. In fact, most text files are limited to the characters that can be typed from the key board. And, since its so easy to work with ASCII, its so popular and lovable. But alas, we miss out on all the formatting and the great animation and charts that can be done with say a doc file or an xl file.
I always thought email passed only ASCII through. Then how do doc and xl files go through?
C'mon now master, you ought to know that. Its converted into ASCII before it is sent. And, the recipient reconverts it back. Its called encoding. Mostly email is sent using Multipurpose Internet Mail Extension a.k.a MIME which encodes the content into base-64 and sends it across. Then there is UUEncode. An acronym for Unix to Unix Encoding that was originally developed for moving binary files using Internet/E-mail between two computers running Unix.
Master you are amazing! I just remembered that UUEncode converts my binary stuff to 7-bit ascii! Heck with Winzip I can just convert a zip file to UUE and paste the UUE file as a message. The user can save the text of the message as a UUE file and it can be opened with Winzip again!
Thank you Master, that was enlightening!
< click >

More on UUEncode and UUE files.
Email (and usenet news) had its genesis when ASCII was hot and if your system could do 8-bit ASCII, you were Elvis (or maybe Swami Rama)! So, these systems were designed for 7bit ASCII. And, even today they are very much based on the same. So then the question begs itself to be asked, how does the system work with today's systems that use Unicode or MBCS or DBCS or something else? Moreover, how does 7-bit ASCII mask the complexity of an Excel Worksheet with pictures and Charts and send it across so well, that the recipient who is using Outlook (Outlook is a MUA - a mail user agent, i.e. a client program that you use to read emails) or Mozilla Thunderbird gets it without any changes?
The solution as devised in those days, used encoding. All binary data before sending is encoded into 7 bits. So, all the 8 bits and 16 bits and 32 bits etc. are converted into 7 bit representation.
How is it done? Check out

Where does UUEncode fit in?
UUEncode is also an encoding scheme that converts 8 bit files (any file type) to 7-bit ASCII. Uuencode (Unix to Unix Encode) comes from the Unix world and was used to encode files transmitted from one Unix computer to another. Uuencode was common in Usenet (i.e. news) than in email (Email uses MIME), but most email systems will pass Uuencode without problems. UUEncoding a file makes it considerably larger than the original file. After encoding, the file consists of just the printable ASCII characters (i.e. the first 127 ASCII characters or 2 raised to 7.) So all the binary information that may have been there is now encoded using the printable ASCII characters.

Why does it work?
UUEncoded files are plain ASCII files, and the MUAs (i.e. Outlook and the like) don't try to interpret the encoded content. Although its very much possible for Outlook to verify the content as 7 bit UUEncoded file and display its contents, I doubt if that would be a really useful feature, since the usage of UUE is not part of the main stream.

How to put it to use?
There are umpteen number of tools available which will UUEncode/Decode files.
As the popular Winzip also supports working with UUE files (it has UUEncode on its actions menu), I am outlining the steps needed to creating a UUE file using Winzip

Create/Open the zip file with Winzip and choose Actions -> UUEncode. Alternately, you can press Shift+U (Winzip 9.0) and a new file with the same name and UUE extension will be created (in the same folder.)
You can try attaching the UUE file to the email or Insert the contents of the UUE file as plain text in the message and instruct the recipient to paste the same into another file and rename it to UUE. If Winzip is installed, this file can be opened with the same. With Winzip UUE files work exactly like ZIP files. In case, the recipient doesn't have Winzip, the file can be decoded using any of the freely available UUEncode/Decode .

The advantage of using this technique are:
1. UUE files are 7 Bit ASCII and not yet an accomplice in any infecting mechanisms used by virii. So they are happily sent across by mail servers.
2. Since the character set used by UUE files are limited to printable ASCII, the file can be pasted in the body of the email and sent if needed.
The disadvantages would be:
1. The size of the email is increased considerably (sometimes upto 50% or even more)
2. If UUE is pasted in the email body and sent, the recipient has an additional step of pasting the text back into notepad and saving it with the UUE extension.

Additional links:
MIME Encoding Mail Primer

1 comment:

  1. great presentation manner. Must appreciate how the story unfolds to reveal that Unix tricks still work on Windows platform. :)