|
using System;
using System.IO;
namespace Md5Extractor
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Extractor
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
if (args.Length == 0)
Usage();
ExtractFile(args[0], args[1]);
}
private static void ExtractFile (string sfilename, string soutputfile)
{
using (BinaryReader reader = new BinaryReader(File.OpenRead (sfilename)))
{
byte[] vec = reader.ReadBytes (128);
int goodSize = reader.ReadInt32 ();
int evilSize = reader.ReadInt32 ();
/// open evil file
if (vec[123] == 0xab)
{
reader.ReadBytes (goodSize);
byte[] evil = reader.ReadBytes (evilSize);
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite (soutputfile)))
{
writer.Write (evil);
writer.Close ();
}
}
else
{
byte[] good = reader.ReadBytes (goodSize);
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite (soutputfile)))
{
writer.Write (good);
writer.Close ();
}
}
Console.WriteLine ("File written on {0}", soutputfile);
}
}
private static void Usage ()
{
Console.WriteLine("Usage: md5extract file.bin output_file.exe");
Environment.Exit (-1);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here