Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get line number of error in obfuscated .NET code?

With this code:

 Dim sf As New StackFrame(0, True)
 MessageBox.Show("Module: " & sf.GetFileName & " -Line: " & sf.GetFileLineNumber.ToString)

I can get Class and Line number where an Unhandled Exception occurred (in ApplicationEvents.vb, Sub MyApplication_UnhandledException(...) Handles Me.UnhandledException)

But if I obfuscate the code using EazFuscator (and maybe with any others) I lose the data: I get a NullString and 0 for line number.

Inserting the code:

<Assembly: Obfuscation(Feature:="encrypt symbol names with password XXXX", Exclude:=False)>

nothing changes. I can decompile the e.message, but the lines are lost. How can I get the line for an error in obfuscated code?

like image 602
ezio Avatar asked Oct 12 '25 14:10

ezio


1 Answers

No it is not possible, and this is intended. Unhandled exceptions are a source of information for a potential attacker. Normally you should only ever apply obfuscation on a production build, after the first round of tests have passed. Don't try to debug an obfuscated assembly, it's obfuscated specifically to prevent debugging, among other things.

I should add that the real reason why you cannot get the information is that the debug symbols have been stripped from the assembly by the obfuscation process. That information should be shown as long as you have a valid PDB file for your assembly.

like image 73
Drunken Code Monkey Avatar answered Oct 15 '25 21:10

Drunken Code Monkey