最新的DLL防止反编译,是最有效且成本低的方法。

huangapple go评论127阅读模式
英文:

The latest dll prevents decompilation, the most effective and low-cost method

问题

我想加密主机计算机软件的一些重要dll文件,以防止竞争对手对其进行反编译。这主要涉及集成电路,对于更多信息,通知我可能会不方便。

我需要一些关于如何实现这种加密的建议。

英文:

At present, I want to encrypt some important dlls of the host computer software to prevent them from being decompiled by competitors. It mainly involves integrated circuits, and it is inconvenient to inform me of more information.

I need some advice to accomplish this encryption

答案1

得分: 1

正如John Wu所说,加密的dll在被引用时需要通过一些特殊的渠道。

您可以通过加密来混淆dll,然后通过反射调用它。这里有一个示例:

假设我们有一个项目,其输出类型是类库,项目的命名空间是TestDll,在该命名空间下有以下类:

namespace TestDll
{
    public static class ImportantClass
    {
        private static string password = "123456";

        public static string DoSomething()
        {
            return password + "zzz";
        }
    }
}

如果我们不使用加密混淆方法,点击生成,然后会生成TestDll.dll文件,我们创建一个新的控制台应用程序,命名空间为Test_Demo,添加dll引用,然后使用以下方法进行调用:

namespace Test_Demo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string str = ImportantClass.DoSomething();
            Console.WriteLine(str);//123456zzz
            Console.ReadKey();
        }
    }
}

但我们会发现在ImportantClass中的password和DoSomething都以明文可见,这显然是不可接受的。

为了避免暴露我们的dll实现细节,我们可以使用ConfuserEx来进行混淆和加密。

此时,dll的方法和细节都被隐藏起来。通过这种混淆和加密方法,Visual Studio项目无法添加引用,因此需要使用Assembly进行反射调用,并将加密后的dll复制到Confuser_Demo路径的应用程序中,然后修改主方法:

static void Main(string[] args)
{
    string dllPath = @"C:\Users\Administrator\source\repos\TestDll\TestDll\bin\Debug\TestDll.dll";
    Assembly dll = Assembly.LoadFrom(dllPath);
    Type[] types = dll.GetTypes();
    Type type = types.Where(arg => arg.Name.Equals("ImportantClass")).FirstOrDefault();//类名
    MethodInfo methodInfo = type.GetMethod("DoSomething");//方法名
    object value = methodInfo.Invoke(null, null);// 如果方法没有参数
                                                 // 如果方法有参数
                                                 //object value = methodInfo.Invoke(null, new object[]{param1,param2});
    Console.WriteLine(value);
    Console.ReadKey();
}

但正如PMF所说,归根结底,各种加密方法只会增加黑客解密的难度,总会有一种方法可以破解。

英文:

As John Wu said, encrypted dlls need to go through some special channels when they are referenced.

You can obfuscate the dll by encryption and call it through reflection. Here is an example:

Suppose we have a project whose output type is class library, and the namespace of the project is TestDll, and there is the following class under this namespace

namespace TestDll
{
     public static class ImportantClass
     {
         private static string password = "123456";

         public static string DoSomething()
         {
             return password + "zzz";
         }

     }
}

If we don’t use encryption obfuscation method, we click Generate, then the file TestDll.dll will be generated, we create a new console application, the namespace is Test_Demo, add the dll reference, and then use the following method to call

namespace Test_Demo
{
     internal class Program
     {
         static void Main(string[] args)
         {
             string str = ImportantClass. DoSomething();
             Console.WriteLine(str);//123456zzz
             Console. ReadKey();
         }
     }
}

But we will find that both password and DoSomething in ImportantClass are visible in plain text, which is obviously not acceptable

In order to avoid the exposure of our dll implementation details, we can use ConfuserEx for obfuscation and encryption

最新的DLL防止反编译,是最有效且成本低的方法。

最新的DLL防止反编译,是最有效且成本低的方法。

最新的DLL防止反编译,是最有效且成本低的方法。

At this time, the methods and details of the dll are all hidden. Through this method of obfuscation and encryption, the visual studio project cannot add references, so it is necessary to use Assembly to do reflection calls, and copy the encrypted dll to the application of Confuser_Demo path, and then modify the main method

     static void Main(string[] args)
     {
         string dllPath = @"C:\Users\Administrator\source\repos\TestDll\TestDll\bin\Debug\TestDll.dll";
         Assembly dll = Assembly. LoadFrom(dllPath);
         Type[] types = dll. GetTypes();
         Type type = types.Where(arg => arg.Name.Equals("ImportantClass")).FirstOrDefault();//class name
         MethodInfo methodInfo = type.GetMethod("DoSomething");//Method name
         object value = methodInfo.Invoke(null, null);// If the method has no parameters
                                                      // if the method has parameters
                                                      //object value = methodInfo.Invoke(null, new object[]{param1,param2});
         Console. WriteLine(value);
         Console. ReadKey();
     }

But as PMF said, in the final analysis, various encryption methods will only increase the difficulty of decryption for hackers, and there is always a way to crack

答案2

得分: 0

如果你怀疑竞争对手(来自国外)雇佣黑客来拆解你的代码,无论如何你都已经失败了。除了尽量让他们的操作变得困难之外,你无法采取任何行动。

然而,如果竞争对手是一家值得信赖的公司,他们不会这样做,因为他们有声誉要保持,而且在诉讼案件中也可能损失大笔资金。西方国家的科技公司非常渴望确保他们严格遵守许可合同,因为他们也期望他们的客户做同样的事情(并支付他们的服务和许可费用)。

英文:

If you suspect that the competitor (from a remote country) hires hackers to disassemble your code, you have lost anyway. There's nothing you can do about it, except making it as hard as possible for them.

If the competitor however is a trustworthy company, they will not do that, as they have a reputation to loose and also a lot of cash in case of a lawsuit. Tech companies in western countries are very eager to make sure they follow license contracts to the letter, as they also expect that their customers do the same (and pay for their services and licenses).

huangapple
  • 本文由 发表于 2023年8月10日 14:33:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76873133.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定