File format issue (plaintext)
-
16-06-2021 - |
Question
I have had an email sent with an attachment which was a zip file. For some reason the email client has not attached it as a seperate file, and simply rendered it as text in the email. There is no other copy of the zip file. I am trying to recover it but do not know if it is possible. The email shows the file like this in text;
>Content-Type: application/x-zip-compressed; name="me.zip";
>
>Content-Disposition: attachment; filename="me.zip"
>
>Content-Transfer-Encoding: base64
>
>
>
>UEsDBBQAAQAIANeV9y5y6d5oG..... etc.
It just continues with random letters for ages. Does anyone know if it is at all possible to recover such a file?
Thanks for any pointers.
Solution 2
I used the code located here to fix this. The online base64 decoders were not working but it worked via this code snippet. Just a copy and paste with no modifications needed;
http://msdn.microsoft.com/en-us/library/system.convert.frombase64string%28v=vs.110%29.aspx
public void DecodeWithString() {
System.IO.StreamReader inFile;
string base64String;
try {
char[] base64CharArray;
inFile = new System.IO.StreamReader(inputFileName,
System.Text.Encoding.ASCII);
base64CharArray = new char[inFile.BaseStream.Length];
inFile.Read(base64CharArray, 0, (int)inFile.BaseStream.Length);
base64String = new string(base64CharArray);
}
catch (System.Exception exp) {
// Error creating stream or reading from it.
System.Console.WriteLine("{0}", exp.Message);
return;
}
// Convert the Base64 UUEncoded input into binary output.
byte[] binaryData;
try {
binaryData =
System.Convert.FromBase64String(base64String);
}
catch (System.ArgumentNullException) {
System.Console.WriteLine("Base 64 string is null.");
return;
}
catch (System.FormatException) {
System.Console.WriteLine("Base 64 string length is not " +
"4 or is not an even multiple of 4." );
return;
}
// Write out the decoded data.
System.IO.FileStream outFile;
try {
outFile = new System.IO.FileStream(outputFileName,
System.IO.FileMode.Create,
System.IO.FileAccess.Write);
outFile.Write(binaryData, 0, binaryData.Length);
outFile.Close();
}
catch (System.Exception exp) {
// Error creating stream or writing to it.
System.Console.WriteLine("{0}", exp.Message);
}
}
OTHER TIPS
It is a base64 encoded file, you can simply decode the base64-encoded characters and output the result to a file (which will be binary data since it's encrypted, so will look even more weird).
The clue is in the Content-Transfer-Encoding
header.