.net reactor - obfuscate error messages

820 views
Skip to first unread message

keith

unread,
May 4, 2011, 9:51:10 AM5/4/11
to .Net Reactor Support
I know there's a way to scramble error messages I log and then using
the deobfuscator I can read them when they come in. But I'm not clear
on how this is done. I'm not finding anything descriptive enough in
the help file on this. Can anyone explain the process to me or point
me to some good examples?

Glen Harvy

unread,
May 4, 2011, 10:11:13 AM5/4/11
to net-react...@googlegroups.com
Hi Keith,

When you obfuscate strings then any error messages etc generating a
trace message will obviously display obfuscated data.

You need to de-obfuscate the message by using the mapping file that is
generated when you obfuscated the assembly. I wrote my own program to do
this and I think there is an example in the documentation somewhere.

Here's my cs project file that should help you on the way:

sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Eziriz;
using System.IO;
using DevExpress.XtraEditors;

namespace DeObfuscate
{
public partial class MainForm : DevExpress.XtraEditors.XtraForm
{
string nrmapFile = "";

public MainForm()
{
InitializeComponent();
}

/*** Deobfuscate an obfuscated text/stack strace ***/

public string deObfuscateText(string obfuscated_text, string
mapping_filename)
{
StackTraceDeobfuscator STD = new
StackTraceDeobfuscator(mapping_filename);
return STD.DeobfuscateText(obfuscated_text);
}

private void simpleButtonGo_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(nrmapFile))
{
XtraMessageBox.Show("Select the nrmap file first");
return;
}
this.memoEditOutPut.EditValue = "";
this.memoEditOutPut.EditValue =
deObfuscateText(this.memoEditInPut.EditValue.ToString(), nrmapFile);
}

private void buttonEdit1_ButtonClick(object sender,
DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();

if (!String.IsNullOrEmpty(this.buttonEdit1.Text))
{
ofd.InitialDirectory =
Path.GetFullPath(buttonEdit1.Text.ToString());
}
else
{
ofd.InitialDirectory = @"D:\DeObfuscate";
}
ofd.Filter = "nrmap files (*.nrmap)|*.nrmap|All files (*.*)|*.*";
ofd.Title = "Select a nrmap file";

if (ofd.ShowDialog() == DialogResult.OK)
{
buttonEdit1.EditValue = ofd.FileName;
nrmapFile = ofd.FileName;
//path = System.IO.Path.GetDirectoryName(ofd.FileName.FileName);
}
}

private void btnClearText_Click(object sender, EventArgs e)
{
this.memoEditInPut.Text = string.Empty;

keith

unread,
May 4, 2011, 11:27:15 AM5/4/11
to .Net Reactor Support
Thanks for both replies Glen. I did purchase the software several
weeks ago. I'm happy with it so far. I like the fact that I can embed
3rd party dll's into the main assembly.

I did just discover that if I use string encryption I have a problem.
One of the features of the program I'm working on reads a few XML
files. It compares data in some scanned files to the data in the XML
files in order to pull out some codes. That part of my program has
been running just fine. But when I did string encryption I got this
error: Operator '=' is not defined for type 'DBNull' and string
"TestCode". The code that runs there runs exactly right without string
encryption. I'm wondering if since my XML files are not string
encrypted there's a conflict of some kind. Any idea on what's going on
and how I would handle it? Do I need to implement something like what
you showed me in your previous post?

Keith

Glen Harvy

unread,
May 4, 2011, 4:59:50 PM5/4/11
to net-react...@googlegroups.com
Hi Keith,

I think it may be a coding issue as obfuscating will obfuscate your
code, not variables. Your description of your code indicates that you
read one file into a variable, another file into a variable and then
compare parts of the two variables. Whether they are xml files or not
doesn't matter. If however you have defined some strings as constants
and are comparing variables with those constants then it is possible
those constants you have defined have been obfuscated as you have
written them into your code. In your case the '=' sign may be just part
of an obfuscated string but it is being interpreted as a instruction by
the CLR.

I suppose you have enabled every obfuscation option there is. Without
examining the code segment causing you grief and not knowing what .Net
Reactor settings you have enabled it is not possible to be more helpful.

There is an option that I have never used myself and that is the ability
to exclude an item from obfuscation. You need to decorate your code with
a flag - do a google search for general instructions on how to do this.

What I showed you in my previous post was the code I use to read a log
file containing obfuscated strings and replace the obfuscated text with
the original. It has nothing to do with the problem you are now describing.

Glen.

keith

unread,
May 4, 2011, 9:19:05 PM5/4/11
to .Net Reactor Support
Thanks Glen,

I think I know what's going on now after your description. I read node
values from the XML file into a DataTable (dt1 for example). This is
user editable data. In code, I also set up another DataTable (dt2)
from hard coded values, <b>not</b> from an external file (it's an
array of strings that's hard coded and then read into the DataTable).
I'm then comparing those values to the values read in from the XML
file (comparing between dt1 and dt2). I'm wondering if the value
that's hard coded into my program is being obfuscated and compared to
the non-obfuscated value from the XML file and giving me an error. I
think that's what you are describing. I'll check into the ability to
keep some parts of my code from being obfuscated and maybe that will
solve the problem.

Keith

keith

unread,
May 4, 2011, 9:55:21 PM5/4/11
to .Net Reactor Support
Well now it's working. I didn't change anything. I started to add code
for ObfuscationAttribute but had a lot to learn. While I was learning
I ran my app again and turned on all the protection switches that I'd
turned off before and now it's working. Not sure what happened. Those
types of things make me nervous. Hopefully it will continue to
behave!
Reply all
Reply to author
Forward
0 new messages