简体   繁体   English

在客户端加密文件

[英]Encrypt file on client side

I am going to create an application which will run in the client's computer. 我将创建一个将在客户端计算机上运行的应用程序。 The program will allow the client to use the software N times, and then for the client to be able to use the software again he/she will need to buy an X amount of times to use the software. 该程序将允许客户使用N次软件,然后,客户才能再次使用该软件,他/她将需要购买X次才能使用该软件。 It would be like buying a license or token (i don't know if they're the same or not, since my english isn't that good). 这就像购买许可证或令牌(我不知道它们是否相同,因为我的英语不太好)。

I was thinking about creating a .lic or .txt or anything else, which would be encrypted, and when updated with the new .lic or .txt, etc, it would change the number fo times the client would be able to use the software. 我正在考虑创建一个.lic或.txt或其他任何要加密的文件,并用新的.lic或.txt等进行更新时,它将更改客户端可以使用该软件的次数。 。

The thing is that I don't think that method is very reliable, since, even if encrypted, the client somehow could be able to crack and understand this file. 事实是,我认为该方法不是非常可靠,因为即使加密了,客户端也可能能够破解并理解该文件。

Could anybody help me in figurnig out a solution for this? 有人可以帮我解决这个问题吗?

PS: The software can't be validated via internet, the client must be able to use the software offline, if it wasn't I'd validate the software's usage via internet and wouldn't be having this problem. PS:无法通过互联网验证该软件,如果我不是通过互联网验证该软件的使用且不会出现此问题,则客户端必须能够脱机使用该软件。

First I must agree with the commentary that simply says, this will not be secure. 首先,我必须同意简单地说,这将是不安全的评论。 Even though they are correct, it will be easy for a developer to work around, there still may be a valid need/desire to prevent the other 99% of the population. 即使它们是正确的,对于开发人员来说也很容易解决,但仍然有防止/阻止其他99%人口的有效需求。 This is the same battle that DRM faces, there are always those 1%'ers that are willing to put in the time to decipher what you're doing and work around it. 这就是DRM面临的同样的战斗,总是有1%的人愿意花时间来解读您正在做的事情并解决它。 But let's move on to how you would achieve this... 但是,让我们继续前进,如何实现这一目标...

Step 1 - You need a 'counter' to know how many times your application has been run. 步骤1-您需要一个“计数器”来知道您的应用程序已运行了多少次。 This, unfortunately, will only be obfuscated from the user since your application must be able to read this value. 不幸的是,这只会使用户感到困惑,因为您的应用程序必须能够读取该值。 Often this obfuscation is achieved by hiding values in several places both in the registry and file system. 通常,通过在注册表和文件系统中的多个位置隐藏值来实现这种混淆。 Occasionally you will find this information is 'encrypted' (actually it's obfuscated by an encryption algorithm) using information available on host, the bios, cpu type, hdd id, etc. 有时,您会发现此信息是使用主机上可用的信息,BIOS,CPU类型,HDD ID等“加密的”(实际上是被加密算法模糊处理的)。

Ultimately this storage and obfuscation of the execution counter is your 'secret sauce', and the only thing that makes it difficult to reverse is by keeping what you are doing a closely guarded secret (as most forms of obfuscation rely on secrecy). 归根结底,执行计数器的这种存储和混淆是您的“秘密调味品”,而唯一难以逆转的事情是将您正在做的事情严格保密,(大多数混淆形式都依赖保密)。 Due to this there is not really a value I could provide in offering you a solution, once posted here it's no longer a secret :) 因此,在为您提供解决方案方面我没有真正的价值,一旦在此处发布,它就不再是秘密了:)

Step 2 - Once you've got this counter working you will need to provide a 'license' to the user. 第2步 -完成此计数器的工作后,您需要向用户提供“许可证”。 This is actually the easy part and where PKI cryptography can serve you well. 这实际上是最简单的部分, PKI加密可以很好地为您提供帮助。 What you want is a private key only you control, while your client software has the public key hard-coded somewhere. 您想要的是仅由您控制的私钥,而客户端软件的公钥则在某处进行了硬编码。 Then you use you're private key to ' digitally sign ' a license file for a client. 然后,您可以使用私钥对客户端的许可证文件进行“ 数字签名 ”。 When your client loads the license file it verifies the signature to ensure that this license file was signed by the related private key, which in theory since only you have access to this key, means that you authorized this license. 当您的客户端加载许可证文件时,它将验证签名以确保此许可证文件已由相关的私钥签名,从理论上讲,由于只有您可以访问此密钥,因此意味着您已授权此许可证。

Step 3 - Now you need to provide a way to verify that this counter has not exceeded the licensed number of uses. 步骤3-现在,您需要提供一种方法来验证此计数器未超过许可的使用次数。 This should be straight forward. 这应该很简单。

Problems and Solutions 问题与解决方案

  1. The most obvious attack on such a solution will be reverse engineering the code. 这种解决方案最明显的攻击是对代码进行反向工程。 You will need to address this with a .NET obfuscation library or by writing unmanaged code. 您将需要使用.NET模糊处理库或编写非托管代码来解决此问题。

  2. The next most likely attack is using a debugger to skip past this verification. 下一个最可能的攻击是使用调试器跳过此验证。 There are lots of anti-debugging articles out there. 那里有很多反调试文章。 The most complete I've found is titled " An Anti-Reverse Engineering Guide ". 我找到的最完整的标题为“ 反逆向工程指南 ”。

  3. Another attack that should be considered is modification of you're executable. 应该考虑的另一种攻击是对可执行文件的修改。 Sign you're executable and verify it's signature just as you will for the license to prevent the code from being directly edited. 像执行许可证一样对可执行文件签名并验证其签名,以防止直接编辑代码。

  4. Your storage of the execution counter will be an obvious target, make sure you store it in multiple places and if any of them have been tampered with you can take an appropriate action. 执行计数器的存储将是显而易见的目标,请确保将其存储在多个位置,并且如果其中任何一个被篡改,则可以采取适当的措施。

Lastly , All of this will be insufficient to prevent a determined individual from successfully defeating you're licensing strategy. 最后 ,所有这些都不足以阻止坚定的个人成功击败您的许可策略。 Accept that now and implement only as much as you feel is required based on both the level of computer competency of your average user and the amount of lost revenue versus the cost of implementation. 立即接受,并根据普通用户的计算机能力水平以及收入损失与实施成本之间的关系,仅执行您认为需要的程度。 In other words say you implement something really silly and basic and expect that 20% of your users could figure it out. 换句话说,您实施了一些非常愚蠢且基本的操作,并期望20%的用户可以解决。 Based on your clients you believe that of that 20% of your users less than a quarter of those would actually circumvent you're DRM rather than paying for the license. 根据您的客户,您认为在20%的用户中,不到四分之一的用户实际上会绕过您的DRM,而不是支付许可证费用。 So you expect to loose out on 5% of your possible revenue, say you make 1 million a year, that mean you loose 50k in revenue. 因此,您希望损失5%的可能收入,例如您每年赚100万,这意味着您损失了5万美元的收入。 Now ask yourself if I spend X dollars of my time making this harder for someone to circumvent, at what point does it become a negative return? 现在问问自己,我是否花了X美元的时间使某人难以规避,这在什么时候变成负收益? Certainly at an expected loss of 50k you wouldn't want to spend a year working on DRM. 当然,在预期损失5万的情况下,您不想花一年的时间进行DRM工作。

Honestly speaking I think most applications that employ a DRM could do with a great deal less effort. 坦白地说,我认为大多数采用DRM的应用程序都可以减少很多工作。 If you're application is priced right people will pay for it. 如果您的应用程序定价合理,那么人们会为此付费。 For the people that will circumvent your DRM, they probably wouldn't buy your application anyway so you haven't really lost anything. 对于那些会规避您的DRM的人们来说,他们可能还是不会购买您的应用程序,因此您并没有真正失去任何东西。 If I where you I'd set aside a fixed amount of time to spend on this problem, (a week?) and do only what you can within that time limit. 如果我在您的位置,我会在此问题上留出固定的时间(一周?),然后在该期限内尽您所能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用C#加密CSV文件-在客户端解密 - Encrypt a CSV file with C# - Decrypt On the Client Side 在SQL Server和客户端读取/解密中加密 - Encrypt in SQL server and read/decrpyt client-side 在统一和节点 js 上对客户端/服务器端使用 RSA 加密/解密 - use RSA encrypt/decrypt for client/server side on unity and node js 如何从服务器端加密数据并将其传递给客户端(javascript)并解密和使用 - How to encrypt data from server side and pass it to client side(javascript) and decrypt and use it 在服务器端实施MD5halsh盐腌算法时,如何在客户端加密密码 - how to encrypt password at client side when implemented MD5halsh salted algorithm on server side 在客户端打印pdf文件 - Print a pdf file at client side 读取csv文件客户端 - Read csv file client side 如何在客户端(DataServiceContext)加密OData请求有效负载并在ServerSide解密请求? - How could I Encrypt OData Request Payload at Client Side(DataServiceContext) and Decrypting Request at ServerSide? 如何使用C#SDK使用AWS KMS加密客户端 - How to encrypt client-side with AWS KMS using the C# SDK 从服务器加密,在客户端解密(但不在客户端加密)? - Encrypt from server, decrypt on client (but not encrypt on client)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM