2

I want to try the following:

I have a C# program which takes a file as input and calculate MD5 algorithm for these five MD5. My algorithm has a unique value for each file; this value is a 128 bit value, so I want to use this technique to protect my programs by saving the output value of md5 algorithm into a my PE file (let's say the value is X). The PE will calculate the MD5 value again (for itself) (let's say the value is Y) and then compare X with Y. If it's the same value it's ok and run; else, it'll exit.

My Question is: how do I write my Value into the PE file? Important notice : my algorithm has been written with C# so I want a way to write into PE file using C# language.

4

3 回答 3

4

创建一个嵌入并位于代码/数据段末尾的空字符串资源数据,计算出将值写入资源位置所在的空位置的偏移量。

但是话又说回来,自己保护程序有什么意义……?

我不会走这条路,而是对 PE 文件(本机 C/C++ 代码/库和 .NET)采用商业保护方案……例如,.NET 可执行文件也是 PE 文件,它们很容易逆向工程(想想反射器)......看看很多这些所谓的warez,其中保护方案被破解并使用序列号......你怎么看?如果您仍然坚持自己做,那么我回答中的第一段应该对您有所帮助。

我的 2 美分在这里想到了......最好的问候和祝你保护计划好运,汤姆。

于 2009-11-22T23:08:15.823 回答
4

一种选择是简单地将您的值附加到文件的末尾。Windows 非常乐意将任意数据附加到可执行文件中——例如,自解压 zip 文件就是这样工作的。

编辑以回应 Hany 的评论:它适用于我,以 cmd.exe 为例:

C:\WINDOWS\system32>copy con rjh
This is a test!
^Z
        1 file(s) copied.

C:\WINDOWS\system32>copy /b cmd.exe + rjh cmdrjh.exe
cmd.exe
rjh
        1 file(s) copied.

C:\WINDOWS\system32>od -cv cmdrjh.exe | tail -4
1367760  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
1370000   T   h   i   s       i   s       a       t   e   s   t   !  \r
1370020  \n
1370021

C:\WINDOWS\system32>cmdrjh
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\WINDOWS\system32>

(您确实以二进制模式进行了文件操作,不是吗?)

于 2009-11-22T22:43:50.570 回答
0

您可以使用备用数据流。. . 您可以在其中打开并写入文件名,例如 filename.exe:md5sig,以便 md5sig 是签名的命名空间。原始文件(位于未命名的默认命名空间中)及其数据被单独保留。博学的穴居人

于 2009-12-17T03:46:12.787 回答