开发者

how to obfuscate single string into .net assembly

I wonder if it's possible obfuscate only some strings from your source code into generated assembly file. My goal is create a checksum using salt string and I'd like hardcode salt string into my assembly avoiding that string will be visible开发者_StackOverflow中文版 in case somebody will disassembly mys ddl. I'm not interested into a full assembly obfuscation, only some strings


Does it matter? The deobfuscator would have to be built into your assembly as well, otherwise you couldn't get the string back. Someone looking at your assembly would only need run the deobfuscator to get your salt string. If you really want to hide a string, put it into a native assembly.


You can generate a "native assembly" in C++ which will contain set of hidden strings and then use the "native assembly" from your C# project. Skater .NET obfuscator helps to accomplish that.

Strings are vital code parts. It makes sense to create them in native code. Skater generates a C++ written DLL with the protected Strings. This Skater’s option protects algorithms by coding Strings in native code and store them in a separate machine-code DLL. Native code can be reverse engineered but it is a very tough job. Plus, Strings are encrypt-protected in the DLL.

To learn how it works let’s start a small .NET project. We will be creating a simple .NET Console application that includes a single “Hello World!” string that we want to protect.

using System;

struct Module1

{

private string str = "Hello World!";

void Main()

{
  Console.WriteLine(str);
}

}

Take a look what we got after the ConsoleApplication1.exe decompilation:

how to obfuscate single string into .net assembly

We can see the non-obfuscated "Hello World!" string in the decompiler's interface. When you run the Skater-obfuscated ConsoleApplication1.exe it produces the same result. Take a look what changed inside the simple program. We need to run the decompiler again against the new obfuscated executable and it will give us the following decompilation result:

how to obfuscate single string into .net assembly

The “Hello World!” string has been allocated by Skater into a public variable then it was encrypted.

Read 'Protect .NET String values by hiding them into machine code DLL' GitHub tutorial. It will describe how the "Hello World!" string can be located in a separate dll library file. That library is an unmanaged binary machine code COM file. It is not accessible/openable by .NET assembly browsers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜