Closed derekbartram closed 9 years ago
Yes indeed it's a documentation issue. Currently declarative obfuscation is only supported in CLI. i.e. you have to use Confuser.CLI.exe if you want to use declarative obfuscation.
I just tried using Confuser.CLI.exe instead of the GUI application and got the same output result. I used the project configuration file I generated from the GUI tool, which I suspect is the problem.
My config file has:
<project outputDir="c:\output" baseDir="c:\code directory\bin\Release" xmlns="http://confuser.codeplex.com"> <module path="###DLL NAME HERE###" /> </project>
I've modified to <project outputDir="c:\output" baseDir="c:\code directory\bin\Release" xmlns="http://confuser.codeplex.com"> <rule inherit="true" pattern="###NEED HELP###" preset="maximum"> <protection action="add" id="constants" /> </rule> <module path="###DLL NAME HERE###" /> </project>
I cannot figure out what the pattern setting should be. *I've deliberately changed path names to hide what project I'm working on, sorry!
I'll admit the documentation wasn't very clear on it. Basically:
Confuser.CLI -o=<output directory> <DLL/EXEs>
Thanks for the support, much appreciated!
I'm trying to use declarative obfuscation, so I used the comment Confuser.CLI -o=c:\Output c:\CodeDirectory\bin\Release\test.dll
However that generates logging to
[INFO] Loading 'c:\CodeDirectory\bin\Release\test.dll'...
[ERROR] Unknown error occurred.
Exception: System.NullReferenceException: Object reference not set to an instanc
e of an object.
at Confuser.CLI.ObfAttrParser.ReadId(StringBuilder sb) in e:\Source\Public\Co
nfuser2\Confuser.CLI\ObfAttrParser.cs:line 31
at Confuser.CLI.ObfAttrParser.ParseProtectionString(ProtectionSettings settin
gs, String str) in e:\Source\Public\Confuser2\Confuser.CLI\ObfAttrParser.cs:line
82
at Confuser.CLI.ObfAttrMarker.ApplySettings(ConfuserContext context, IDnlibDe
f def, IEnumerable1 infos) in e:\Source\Public\Confuser2\Confuser.CLI\ObfAttrMa rker.cs:line 166 at Confuser.CLI.ObfAttrMarker.ProcessModule(ModuleDefMD module, ConfuserConte xt context, String snKeyPath, String snKeyPass, List
1 settingAttrs, Dictionary 2 namespaceAttrs) in e:\Source\Public\Confuser2\Confuser.CLI\ObfAttrMarker.cs:li ne 255 at Confuser.CLI.ObfAttrMarker.MarkModule(ConfuserProject proj, ConfuserContex t context, ModuleDefMD module, Boolean isMain, Tuple
2& packerInfo) in e:\Source
\Public\Confuser2\Confuser.CLI\ObfAttrMarker.cs:line 232
at Confuser.CLI.ObfAttrMarker.MarkProject(ConfuserProject proj, ConfuserConte
xt context) in e:\Source\Public\Confuser2\Confuser.CLI\ObfAttrMarker.cs:line 33
at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, Ca
ncellationToken token) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngin
e.cs:line 123
Failed at 19:40, 0:00 elapsed.
Would I be right in thinking this is now likely to be some structure I've used in the code that's causing the issue?
The assembly I'm loading is .Net 3.5 C#, with no GUI elements, some use of LINQ, some use of SQL Database connections, nothing else of particular note.
This discussion helped me a lot. I was trying to use the CLI against the assembly that has no markup, thinking that it would obfuscate it "automatically". Now I get it.
Problem, though, if I don't use declarative markup is there a way to (assuming not) to specify the proeject, but override the source and output folders? I can't hard-code those values in the project file because they aren't always the same. For instance, on a build server with multiple agents the source folder varies. Also, the output folder is always in a new spot for that build number.
I might have to switch to declarative.
Thank you.
This is likely user error, so the issue could well just be with documentation.
I have an existing .net 3.5 library, and included the code from below as per the wiki. I used ConfuserEx.exe to protect the library, however my decompiler tool showed the code had not been changed in any way. I set the base directory to the bin\Release folder where the assembly was, then added the assembly below (all inside the project tab). I did not modify anything in the Settings tab.
using System.Reflection; using System;
[assembly: Obfuscation(Exclude = false, Feature = "preset(minimum);+ctrl flow;-anti debug;+rename(mode=letters,flatten=false);")] [assembly: Obfuscation(Exclude = false, Feature = "random seed: Hello!")] [assembly: Obfuscation(Exclude = false, Feature = "namespace 'Test':-rename")] namespace Test { [Obfuscation(Exclude = false, Feature = "constants")] class Program { public static void Main() { Console.WriteLine("Hi"); } } }