How to use ConfuserEx?

后端 未结 4 1013
情话喂你
情话喂你 2021-01-30 03:22

I\'d like to have a try on this program but I couldn\'t figure out how to use it.

I\'ve search on the author\'s site https://github.com/yck1509/ConfuserEx but the examp

相关标签:
4条回答
  • 2021-01-30 03:58

    Get the lastest binaries version from here : https://github.com/yck1509/ConfuserEx/releases

    For use in command line (Confuser.CLI.exe) :

    Confuser.CLI.exe  myProjectFile.crproj
    

    Project file example :

    <?xml version="1.0" encoding="utf-8"?>
    <project baseDir="c:\" outputDir="c:\Confused" xmlns="http://confuser.codeplex.com">
        <rule preset="none" pattern="true">
            <protection id="anti debug" />
            <protection id="anti dump" />
            <protection id="anti ildasm" />
            <protection id="anti tamper" />
            <protection id="constants" />
            <protection id="ctrl flow" />
            <protection id="invalid metadata" />
            <protection id="ref proxy" />
            <protection id="rename" />
            <protection id="resources" />
        </rule>
        <module path="ICSharpCode.AvalonEdit.dll" />
        <module path="ICSharpCode.Decompiler.dll" />
        <module path="ICSharpCode.NRefactory.dll" />
        <module path="ICSharpCode.NRefactory.CSharp.dll" />
        <module path="ICSharpCode.NRefactory.VB.dll" />
        <module path="ICSharpCode.TreeView.dll" />
        <module path="ILSpy.BamlDecompiler.Plugin.dll" />
        <module path="ILSpy.exe" />
        <module path="ILSpy.SharpDevelop.LGPL.dll" />
        <module path="Mono.Cecil.dll" />
        <module path="Mono.Cecil.Pdb.dll" />
    </project>
    

    cmd line

    Config file format : https://github.com/yck1509/ConfuserEx/blob/master/docs/ProjectFormat.md

    For use with the GUI (ConfuserEx.exe) :

    gui

    1. In the Project tab
      1. Choose a base directory
      2. Click on the + button to add DLLs (modules)
    2. In the Settings tab
      1. Click on < Global settings >
      2. Click on the + button. A new rule is added. When the pattern matches, the rule is executed, so "True" mean the rule will always be executed.
      3. Click on Edit button.
      4. Choose the preset "Maximum" then close
    3. In the Protect tab
      1. Click Protect!
    0 讨论(0)
  • 2021-01-30 04:04

    This answer cover the cases when you have a solution with (A) multiple projects that may reference each other, and (B) you're looking to automate obfuscation in a Visual Studio Setup project.

    1) Add on each of your projects a Confuser.crproj text file, in the project's folder directly. In this folder you should see inside the "bin", "ob", "resources", etc. folders. There is no need to attach these files to your solution in visual studio. The text file should look like this:

    <?xml version="1.0" encoding="utf-8"?>
    <project baseDir="obj\Release" outputDir="..\Release" xmlns="http://confuser.codeplex.com">
        <rule preset="none" pattern="true">
            <protection id="anti debug" />
            <protection id="anti dump" />
            <protection id="anti ildasm" />
            <protection id="anti tamper" />
            <protection id="constants" />
            <protection id="ctrl flow" />
            <protection id="invalid metadata" />
            <protection id="ref proxy" />
            <protection id="resources" />
        </rule>
        <module path="MyLibrary.dll" />
        <probePath>..\..\bin\Release</probePath>
    </project>
    

    Replace MyLibrary.dll for the output of your project. (And replace .dll for .exe if it's an executable.)

    ConfuserEX chooses different starting points for relative paths so that's why the paths look weird in the file.

    The key element of this step is to obfuscate the "obj" output of each of your projects. This is to help your Windows Setup project to pick up the obfuscated versions.

    2) In the post-build event of each of your projects, add a post-build event like the following:

    if "$(ConfigurationName)" == "Release" $(SolutionDir)..\ConfuserEX\Confuser.CLI.exe $(ProjectDir)Confuser.crproj
    

    The first condition is to obfuscate only when building in Release. Here you will need to adjust the paths to match the path of your Confuser.CLI.exe. I have my ConfuserEX folder alongside the solution's root folder.

    3) In your Setup project, the issue we need to address is to make sure that packaging picks up your obfuscated versions. Setup has some obscure logic to decide from which folder each assembly is picked up. We will force it to pick up the right ones. For this, you have to:

    (3a) add all your projects as "Project Output", this makes sure the obfuscated files in your "obj" folders make it to the package.

    (3b) check the "detected dependencies" section of your Setup project. Whenever you see a dependency that is generated by one of your projects, go to its Properties and mark it as Exclude=True. This makes sure your obfuscated versions in the package aren't replaced by non-obfuscated versions due to the inference process.

    0 讨论(0)
  • 2021-01-30 04:05

    For anyone else struggling with problems: I downloaded it and the master is missing the dnlib. You can separately download the dnlib copy it into the dnlib folder and then would compile.

    That should work for most, however for me against my exe it gave a "improper dos format" error on any exe. Thought maybe since I had updated to vs2015 and 4.5.3 (.net 5 or 6 or whatever they want to call it now). I figured maybe that was it. but it wasn't (Highest compile was 4.5).

    Looking on google my assumption was it couldn't update the files so spent 1 hour + converting the tuples from your class to .net 4 tuples. and updating all the projects to 4.5.

    If you can, you guys need to check your github fork and hit download then then compile.. it should compile from the site and does not. I am sure this is a great product. Just a bit rough since it isn't made for Juniors to use. Maybe you could just have a link to an EXE? That may help so people aren't dealing with the compile issues.

    Btw really good stuff, looks like this does a lot of stuff even the paid ones don't just a bit of a curve on learning.

    Another note it looks like you have a RuntimeEnvironment.GetSystemVersion()[1] == 4 in there it should probably be (with some parsing) RuntimeEnvironment.GetSystemVersion()[1] > 3.9 so you get 4 and 4.5

    **update. Updated to 4.5 and drag and drop stopped working, still works as you described above. was going with 4.5.3 but you aren't using any of the new functionality.

    What I ended up with, I will edit later to state if it's working. https://onedrive.live.com/redir?resid=88D92E4D40C0593C%21105

    Going with above.

    0 讨论(0)
  • 2021-01-30 04:10

    For me, this method works the best:

    define a crproj:

    <?xml version="1.0" encoding="utf-8"?>
    <project baseDir="c:\program files\confuserex" outputDir="c:\program files\confuserex\Confused" xmlns="http://confuser.codeplex.com">
        <rule preset="none" pattern="true">
            <protection id="anti debug" />
            <protection id="anti dump" />
            <protection id="anti ildasm" />
            <protection id="anti tamper" />
            <protection id="constants" />
            <protection id="ctrl flow" />
            <protection id="invalid metadata" />
            <protection id="ref proxy" />
            <protection id="rename" />
            <protection id="resources" />
        </rule>
        <module path="C:\Temp\dlhsoft\DlhSoft.HierarchicalData.LightWPF.Controls.dll" />
        <module path="C:\Temp\dlhsoft\DlhSoft.ProjectData.GanttChart.LightWPF.Controls.dll" />
        <module path="C:\Temp\dlhsoft\DlhSoft.ProjectData.PertChart.LightWPF.Controls.dll" />
    </project>
    

    and call this file from the commandline using this:

    "c:\program files\confuserex\confuserex.exe" "c:\program files\confuserex\myprojectfile.crproj"
    
    0 讨论(0)
提交回复
热议问题