Obfuscate Assembly and Reflection

前端 未结 4 1977
抹茶落季
抹茶落季 2021-02-15 23:55

I want to obfuscate my assembly files (*.dll, *.exe) by Dotfuscator. my question is if I do this, can I still use classes and types that are in those assemblies

4条回答
  •  日久生厌
    2021-02-16 00:33

    You can create your own private map to get new names from old ones. Mapper must write table of a sort to disk/db with following structure: Module(executable),Index,OriginalType,ObfuscatedType

    Create "Mapper" console application that operates on two modes based on an argument: The application will receive as argument executable path

    1. Load Assembly
    2. GetTypes from loadedAssembly
    3. PreObfuscation deletes all entries and writes anew the indexes and OriginalType values . PostObfuscation updates ObfuscatedType by index. The post build events must be as follows:
      1. Mapper.exe "target.exe" "Pre"
      2. [Obfuscate]
      3. Mapper.exe "target.exe" "Post"

    Now you need a function to getObfuscatedName from OriginalName and you're done.

    Note that this solution will not work with pruning as the number of types will change and indexes will no longer match between

    OriginalAssembly.GetTypes()
    

    and

    ObfuscatedAssembly.GetTypes()
    

提交回复
热议问题