Obfuscation of an application is a great thing because it protects the intellectual property code, it gives you a competitive advantage and against anyone who is interested in the reverse engineering of your code. Hiding the code involves some additional issue when it comes to error reporting. In fact, a very important aspect to take into account is that the obfuscation can make application crash analisys harder to perform.

All programmers of .NET Framework knows that if the application crashes, they can analyze the stack trace to determine the cause of the error. But when the application is obfuscated most of the time the stack trace become a jumble of unreadable symbols and coming to the source of the error can be really annoying.

With Babel Obfuscator you can easily decode the obfuscated stack trace. To deobfuscate the stack trace you have to generate the mapping file of renamed symbols when the application is obfuscated. Then you can load the obfuscated stack trace in the Babel Obfuscator user interface with the generated mapping files and produce a readable stack trace.


Sometimes our users need to perform this task from the command line instead of the user interface so we wanted to provide a simple console application that is able deobfuscate the stack trace.

The code is very simple because all the decode engine is already available int the Babel.Ux.dll deployed with Babel Obfuscator:

static int Main(string[] args)

{

    if (args.Length < 2)

    {

        Console.WriteLine("Usage: stackdecode.exe <filename> <xmlmapfile1> [xmlmapfile2 ...]");

        return 1;

    }

 

    StackTraceDeobfuscator stk = new StackTraceDeobfuscator();

 

    foreach (var xmlMapFile in args.Skip(1))

    {

        try

        {

            stk.AddMapFile(xmlMapFile);

        }

        catch (Exception ex)

        {

            Console.WriteLine(String.Format("Error reading XML map file '{0}':\n{1}", xmlMapFile, ex.Message));

            return 1;

        }

    }

 

    try

    {

        StreamReader sr = new StreamReader(args[0]);

 

        Console.WriteLine("Deobfuscated Stack Trace:");

        Console.WriteLine(stk.DeobfuscateStack(sr));

    }

    catch (Exception ex)

    {

        Console.WriteLine(String.Format("Could not decode stack trace file '{0}':\n{1}", args[0], ex.Message));

        return 1;

    }

 

    return 0;

}



If you want you can download the Visual Studio solution of the StackDecode application attached to this article.

Back to List