I have an assignment, and it has (amongst others) two demands:
我有一个任务,它有(其中包括)两个要求:
- make an installer
- make it so that if it is installed on one computer, anyone trying to run the same files on another computer will fail.
制作安装程序
如果它安装在一台计算机上,任何试图在另一台计算机上运行相同文件的人都将失败。
I'm using VS9 (2008) express, I think I can do the installer part, but I'm not sure how to do the "security" part. I don't need any hard to crack safety, just a dumb condition that will stop most users from copying the files to another computer. (Like checking the MAC address).
我正在使用VS9(2008)快递,我想我可以做安装程序部分,但我不知道如何做“安全”部分。我不需要任何难以破解的安全性,只是一个愚蠢的条件,将阻止大多数用户将文件复制到另一台计算机。 (比如检查MAC地址)。
Any ideas?
EDIT:
I would like to check the MAC address but I want the program finalized during installation. Meaning that after I install I can't move the program to another machine. It also does not have to be a very smart or difficult condition, just bare minimum. I just don't know how to do it in the installation.
编辑:我想检查MAC地址,但我希望程序在安装过程中完成。这意味着我安装后无法将程序移动到另一台机器。它也不一定非常聪明或困难,只是最低限度。我只是不知道如何在安装中做到这一点。
EDIT:
It's sad I don't have the complete VS then I would be able to do it easily.
编辑:很遗憾我没有完整的VS然后我可以轻松地完成它。
9 个解决方案
#1
If you're looking for some way to mark the first computer as the "authorized" computer, then you need some external service you can ask for permission to launch.
如果您正在寻找某种方法将第一台计算机标记为“授权”计算机,那么您需要一些外部服务,您可以请求启动权限。
The first person to ask permission would be allowed, the rest would be prevented.
第一个获得许可的人将被允许,其余的将被阻止。
You'll also need to come up with some way of identifying a particular instance of your application that's different for every install.
您还需要提出一些方法来识别每个安装的不同应用程序的特定实例。
If your app needs to be authorized for the machine, then you will need to calculate some fingerprint for the machine it can use each time (eg across installs).
如果您的应用需要获得机器授权,那么您需要为每次可以使用的机器计算一些指纹(例如,跨安装)。
[Edit] This approach is useful when you're worried about copies of the installer being distributed as well. You did specify that its ok to install on multiple machines, so in that case MasterMind's approach is superior. It will work, and does not requires a 3rd party server
[编辑]当您担心分发的安装程序副本时,此方法很有用。您确实指定可以在多台计算机上安装,因此在这种情况下,MasterMind的方法更优越。它可以工作,不需要第三方服务器
[Edit 2] If you're looking for info on how to build a custom installer, try here
[编辑2]如果您正在寻找有关如何构建自定义安装程序的信息,请尝试此处
#2
First of all, come up with some function to generate a unique PC signature, like Windows does for activation.
首先,提出一些功能来生成一个独特的PC签名,就像Windows一样用于激活。
Your installer will be creating this signature and writing it to a local file (better encrypted). You can create a simple console executable to generate this file and include that executable into your installer package, setting it up to run silently after the successful installation.
您的安装程序将创建此签名并将其写入本地文件(更好地加密)。您可以创建一个简单的控制台可执行文件来生成此文件,并将该可执行文件包含在安装程序包中,并将其设置为在成功安装后以静默方式运行。
Your program when starting will be creating the signature again using the same algorithm and comparing it to the one created during installation. If the new signature is different from the original one or the signature file is missing, then exit without loading the UI.
启动时,您的程序将使用相同的算法再次创建签名,并将其与安装期间创建的算法进行比较。如果新签名与原始签名不同或签名文件丢失,则退出而不加载UI。
ADDED: If you don't need it very complex, you can just choose a few unique values like the MAC address you suggested, maybe the hard drive serial number, mainboard serial number, concatenate them into a single string and generate the hash out of it.
增加:如果您不需要它非常复杂,您可以选择一些独特的值,例如您建议的MAC地址,可能是硬盘驱动器序列号,主板序列号,将它们连接成一个字符串并生成哈希值它。
This approach will allow for an unlimited number of copies to run (but each installation will only be workable on one single machine where it was installed). If you stick to the identification by hardware (or OS product key as well), then the application can run on various OS installations on the same machine.
这种方法允许运行无限数量的副本(但每个安装只能在安装它的一台机器上运行)。如果您坚持使用硬件(或OS产品密钥)进行识别,则应用程序可以在同一台计算机上的各种OS安装上运行。
This strategy, however, implies that you control all installations (or perform them yourself) or absolutely trust your client not to install additional copies elsewhere or distribute your installer. If you need that kind of protection as well, then you should consider product activation. It can be quite complicated if you do it yourself. There are however third party products to help you. Some offer product activation services: Google: activation service
但是,此策略意味着您可以控制所有安装(或自行执行)或绝对信任您的客户端,不要在其他位置安装其他副本或分发安装程序。如果您还需要这种保护,那么您应该考虑产品激活。如果你自己做的话可能会很复杂。然而,有第三方产品可以帮助您。有些提*品激活服务:Google:激活服务
#3
Once you have a decent fingerprint, the rest is easy. Personally I'd take something like the MAC address and the windows product ID (at HKLM\Software\Microsoft\Windows\CurrentVersion\ProductId) and use a hashing algorithm to get something reasonably obscure.
一旦你有一个像样的指纹,其余的很容易。就个人而言,我会采取类似MAC地址和Windows产品ID(在HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ ProductId)并使用散列算法来获得合理模糊的东西。
edit:
Here's a question that shows you how to get your MAC address as a string: Read MAC Address from network adapter in .NET
这是一个问题,向您展示如何将您的MAC地址作为字符串:从.NET中的网络适配器读取MAC地址
Then grab your windows product ID (in case they don't have a network adapter) from the above registry key. Concatenate both strings and do a GetHashCode() (or use your favorite hashing algorithm) on the result. This is a simple way to get a UID for a computer.
然后从上面的注册表项中获取您的Windows产品ID(如果它们没有网络适配器)。连接两个字符串并对结果执行GetHashCode()(或使用您最喜欢的散列算法)。这是获取计算机UID的简单方法。
Write the hash to a file or to a registry entry when your installer is executing and check it when your program starts up.
在安装程序执行时将散列写入文件或注册表项,并在程序启动时进行检查。
#4
Consider using two or more values that potentially identify the machine, e.g.
考虑使用两个或多个可能识别机器的值,例如:
- Windows product code
- Volume serial number of the C: drive
- MAC address of an ethernet interface
Windows产品代码
C:驱动器的卷序列号
以太网接口的MAC地址
And if just one of these changes but the others match, update that one value in the registry and continue running normally. Hard drives get replaced (regularly), Windows gets upgraded (occasionally), Ethernet adapters get replaced (rarely but it does happen.) It can be very frustrating when old software stops working because of this.
如果只是其中一个更改但其他更改匹配,请更新注册表中的一个值并继续正常运行。硬盘驱动器被更换(定期),Windows升级(偶尔),以太网适配器被替换(很少但确实发生了。)当旧软件因此而停止工作时,这可能非常令人沮丧。
#5
Bare minimum answer, assuming the only requirement here is that the software should run if installed through the installer, and won't run if copied to another computer:
只有最低限度的答案,假设这里唯一的要求是如果通过安装程序安装软件应运行,如果复制到另一台计算机则不会运行:
Write a simple key to the registry. Most likely your product's version number, incase they copy a newer version to the computer, it has a different number to check for.
写一个简单的密钥到注册表。很可能是您产品的版本号,如果他们将较新版本复制到计算机,则需要检查不同的编号。
In your software, just make sure this registry value exists.
在您的软件中,只需确保此注册表值存在。
For packaging installations, I enjoy using NSIS which has simple methods for writing to the registry.
对于包装安装,我喜欢使用NSIS,它有简单的方法写入注册表。
#6
I like the idea of checking the MAC address.
我喜欢检查MAC地址的想法。
I have also seen product key/online activation combinations where you enter the product key and the software contacts a web service that logs the product key and # of installs.
我还看到了产品密钥/在线激活组合,您可以在其中输入产品密钥,软件会联系记录产品密钥和安装数量的Web服务。
#7
This isn't the most secure option or anything but you did say it didn't have to be smart...
这不是最安全的选择或任何东西,但你确实说它不一定要聪明......
On install, you could set a program variable to be the machine name (or a hash of it if you like).
在安装时,您可以将程序变量设置为计算机名称(如果您愿意,还可以设置其哈希值)。
Like:
myProgram.Properties.Settings.Default.Machine = System.Environment.MachineName;
myProgram.Properties.Settings.Default.Save();
then check that on startup:
然后在启动时检查:
if (System.Environment.MachineName != myProgram.Properties.Settings.Default.Machine)
{
MessageBox.Show("Can't run on this computer");
this.Close();
}
#8
To get the installer to only work for one machine, you'd pretty much have to build it for the target machine. I dont think it would be possible to make an installer that assumes the first machine it sees is it's mommy and is attached for life.
要使安装程序仅适用于一台计算机,您几乎必须为目标计算机构建它。我不认为有可能制作一个安装程序,假设它看到的第一台机器是它的妈妈,并且终生使用。
#9
-1 for clinging to an antiquated license-restriction policy that is a poor practice in general. Hardware dongles and "device detection" are SO 1990.
-1坚持过时的许可证限制政策,这种做法一般来说都很糟糕。硬件加密狗和“设备检测”是SO 1990。
People own more than one computer. They buy new computers. They upgrade their computers. Computers break, resulting in replacement of motherboards or network cards.
人们拥有多台计算机。他们买新电脑。他们升级他们的电脑。计算机坏了,导致更换主板或网卡。
All of these, given your design, will result in honest, paying customers being locked out of what they've paid for and will have to call you for support to "reset" their activation.
所有这些,根据您的设计,将导致诚实,付费的客户被锁定他们已付款,并将不得不打电话给您支持“重置”他们的激活。
And each time you do so, your overhead will increase by, very likely, more than the actual cost of a license.
每次执行此操作时,您的开销将增加,很可能会超过许可的实际成本。
I'm not suggesting you give up and just send your app off to the torrentverse, but you should think more creatively about how to allow customers the freedom to use what they paid for, keep your support costs low, and discourage pirates.
我并不是建议你放弃,只是将你的应用程序发送到torrent,但你应该更有创意地考虑如何让客户*使用他们支付的费用,保持低支持成本,并阻止盗版。
One creative solution would be to cache the user's settings on your server, keyed by their serial number, and synchronize them every time the application starts and is connected to the Net.
一个创造性的解决方案是在服务器上缓存用户的设置,按其序列号键入,并在每次应用程序启动并连接到网络时同步它们。
This will allow a user to install the app on, say, both a laptop and desktop, and will actually be a value-add for customers because their settings are synchronized between devices.
这将允许用户在笔记本电脑和台式机上安装应用程序,并且实际上将为客户增值,因为他们的设置在设备之间同步。
But it actively discourages users from sharing their license key, since doing so would mean they would be sharing their settings with every pirate user, or that they would have to remember to stay disconnected from the Interwebs when they open or close the app.
但它主动阻止用户共享他们的许可证密钥,因为这样做意味着他们将与每个盗版用户共享他们的设置,或者他们必须记住在他们打开或关闭应用程序时保持与Interwebs断开连接。
#1
If you're looking for some way to mark the first computer as the "authorized" computer, then you need some external service you can ask for permission to launch.
如果您正在寻找某种方法将第一台计算机标记为“授权”计算机,那么您需要一些外部服务,您可以请求启动权限。
The first person to ask permission would be allowed, the rest would be prevented.
第一个获得许可的人将被允许,其余的将被阻止。
You'll also need to come up with some way of identifying a particular instance of your application that's different for every install.
您还需要提出一些方法来识别每个安装的不同应用程序的特定实例。
If your app needs to be authorized for the machine, then you will need to calculate some fingerprint for the machine it can use each time (eg across installs).
如果您的应用需要获得机器授权,那么您需要为每次可以使用的机器计算一些指纹(例如,跨安装)。
[Edit] This approach is useful when you're worried about copies of the installer being distributed as well. You did specify that its ok to install on multiple machines, so in that case MasterMind's approach is superior. It will work, and does not requires a 3rd party server
[编辑]当您担心分发的安装程序副本时,此方法很有用。您确实指定可以在多台计算机上安装,因此在这种情况下,MasterMind的方法更优越。它可以工作,不需要第三方服务器
[Edit 2] If you're looking for info on how to build a custom installer, try here
[编辑2]如果您正在寻找有关如何构建自定义安装程序的信息,请尝试此处
#2
First of all, come up with some function to generate a unique PC signature, like Windows does for activation.
首先,提出一些功能来生成一个独特的PC签名,就像Windows一样用于激活。
Your installer will be creating this signature and writing it to a local file (better encrypted). You can create a simple console executable to generate this file and include that executable into your installer package, setting it up to run silently after the successful installation.
您的安装程序将创建此签名并将其写入本地文件(更好地加密)。您可以创建一个简单的控制台可执行文件来生成此文件,并将该可执行文件包含在安装程序包中,并将其设置为在成功安装后以静默方式运行。
Your program when starting will be creating the signature again using the same algorithm and comparing it to the one created during installation. If the new signature is different from the original one or the signature file is missing, then exit without loading the UI.
启动时,您的程序将使用相同的算法再次创建签名,并将其与安装期间创建的算法进行比较。如果新签名与原始签名不同或签名文件丢失,则退出而不加载UI。
ADDED: If you don't need it very complex, you can just choose a few unique values like the MAC address you suggested, maybe the hard drive serial number, mainboard serial number, concatenate them into a single string and generate the hash out of it.
增加:如果您不需要它非常复杂,您可以选择一些独特的值,例如您建议的MAC地址,可能是硬盘驱动器序列号,主板序列号,将它们连接成一个字符串并生成哈希值它。
This approach will allow for an unlimited number of copies to run (but each installation will only be workable on one single machine where it was installed). If you stick to the identification by hardware (or OS product key as well), then the application can run on various OS installations on the same machine.
这种方法允许运行无限数量的副本(但每个安装只能在安装它的一台机器上运行)。如果您坚持使用硬件(或OS产品密钥)进行识别,则应用程序可以在同一台计算机上的各种OS安装上运行。
This strategy, however, implies that you control all installations (or perform them yourself) or absolutely trust your client not to install additional copies elsewhere or distribute your installer. If you need that kind of protection as well, then you should consider product activation. It can be quite complicated if you do it yourself. There are however third party products to help you. Some offer product activation services: Google: activation service
但是,此策略意味着您可以控制所有安装(或自行执行)或绝对信任您的客户端,不要在其他位置安装其他副本或分发安装程序。如果您还需要这种保护,那么您应该考虑产品激活。如果你自己做的话可能会很复杂。然而,有第三方产品可以帮助您。有些提*品激活服务:Google:激活服务
#3
Once you have a decent fingerprint, the rest is easy. Personally I'd take something like the MAC address and the windows product ID (at HKLM\Software\Microsoft\Windows\CurrentVersion\ProductId) and use a hashing algorithm to get something reasonably obscure.
一旦你有一个像样的指纹,其余的很容易。就个人而言,我会采取类似MAC地址和Windows产品ID(在HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ ProductId)并使用散列算法来获得合理模糊的东西。
edit:
Here's a question that shows you how to get your MAC address as a string: Read MAC Address from network adapter in .NET
这是一个问题,向您展示如何将您的MAC地址作为字符串:从.NET中的网络适配器读取MAC地址
Then grab your windows product ID (in case they don't have a network adapter) from the above registry key. Concatenate both strings and do a GetHashCode() (or use your favorite hashing algorithm) on the result. This is a simple way to get a UID for a computer.
然后从上面的注册表项中获取您的Windows产品ID(如果它们没有网络适配器)。连接两个字符串并对结果执行GetHashCode()(或使用您最喜欢的散列算法)。这是获取计算机UID的简单方法。
Write the hash to a file or to a registry entry when your installer is executing and check it when your program starts up.
在安装程序执行时将散列写入文件或注册表项,并在程序启动时进行检查。
#4
Consider using two or more values that potentially identify the machine, e.g.
考虑使用两个或多个可能识别机器的值,例如:
- Windows product code
- Volume serial number of the C: drive
- MAC address of an ethernet interface
Windows产品代码
C:驱动器的卷序列号
以太网接口的MAC地址
And if just one of these changes but the others match, update that one value in the registry and continue running normally. Hard drives get replaced (regularly), Windows gets upgraded (occasionally), Ethernet adapters get replaced (rarely but it does happen.) It can be very frustrating when old software stops working because of this.
如果只是其中一个更改但其他更改匹配,请更新注册表中的一个值并继续正常运行。硬盘驱动器被更换(定期),Windows升级(偶尔),以太网适配器被替换(很少但确实发生了。)当旧软件因此而停止工作时,这可能非常令人沮丧。
#5
Bare minimum answer, assuming the only requirement here is that the software should run if installed through the installer, and won't run if copied to another computer:
只有最低限度的答案,假设这里唯一的要求是如果通过安装程序安装软件应运行,如果复制到另一台计算机则不会运行:
Write a simple key to the registry. Most likely your product's version number, incase they copy a newer version to the computer, it has a different number to check for.
写一个简单的密钥到注册表。很可能是您产品的版本号,如果他们将较新版本复制到计算机,则需要检查不同的编号。
In your software, just make sure this registry value exists.
在您的软件中,只需确保此注册表值存在。
For packaging installations, I enjoy using NSIS which has simple methods for writing to the registry.
对于包装安装,我喜欢使用NSIS,它有简单的方法写入注册表。
#6
I like the idea of checking the MAC address.
我喜欢检查MAC地址的想法。
I have also seen product key/online activation combinations where you enter the product key and the software contacts a web service that logs the product key and # of installs.
我还看到了产品密钥/在线激活组合,您可以在其中输入产品密钥,软件会联系记录产品密钥和安装数量的Web服务。
#7
This isn't the most secure option or anything but you did say it didn't have to be smart...
这不是最安全的选择或任何东西,但你确实说它不一定要聪明......
On install, you could set a program variable to be the machine name (or a hash of it if you like).
在安装时,您可以将程序变量设置为计算机名称(如果您愿意,还可以设置其哈希值)。
Like:
myProgram.Properties.Settings.Default.Machine = System.Environment.MachineName;
myProgram.Properties.Settings.Default.Save();
then check that on startup:
然后在启动时检查:
if (System.Environment.MachineName != myProgram.Properties.Settings.Default.Machine)
{
MessageBox.Show("Can't run on this computer");
this.Close();
}
#8
To get the installer to only work for one machine, you'd pretty much have to build it for the target machine. I dont think it would be possible to make an installer that assumes the first machine it sees is it's mommy and is attached for life.
要使安装程序仅适用于一台计算机,您几乎必须为目标计算机构建它。我不认为有可能制作一个安装程序,假设它看到的第一台机器是它的妈妈,并且终生使用。
#9
-1 for clinging to an antiquated license-restriction policy that is a poor practice in general. Hardware dongles and "device detection" are SO 1990.
-1坚持过时的许可证限制政策,这种做法一般来说都很糟糕。硬件加密狗和“设备检测”是SO 1990。
People own more than one computer. They buy new computers. They upgrade their computers. Computers break, resulting in replacement of motherboards or network cards.
人们拥有多台计算机。他们买新电脑。他们升级他们的电脑。计算机坏了,导致更换主板或网卡。
All of these, given your design, will result in honest, paying customers being locked out of what they've paid for and will have to call you for support to "reset" their activation.
所有这些,根据您的设计,将导致诚实,付费的客户被锁定他们已付款,并将不得不打电话给您支持“重置”他们的激活。
And each time you do so, your overhead will increase by, very likely, more than the actual cost of a license.
每次执行此操作时,您的开销将增加,很可能会超过许可的实际成本。
I'm not suggesting you give up and just send your app off to the torrentverse, but you should think more creatively about how to allow customers the freedom to use what they paid for, keep your support costs low, and discourage pirates.
我并不是建议你放弃,只是将你的应用程序发送到torrent,但你应该更有创意地考虑如何让客户*使用他们支付的费用,保持低支持成本,并阻止盗版。
One creative solution would be to cache the user's settings on your server, keyed by their serial number, and synchronize them every time the application starts and is connected to the Net.
一个创造性的解决方案是在服务器上缓存用户的设置,按其序列号键入,并在每次应用程序启动并连接到网络时同步它们。
This will allow a user to install the app on, say, both a laptop and desktop, and will actually be a value-add for customers because their settings are synchronized between devices.
这将允许用户在笔记本电脑和台式机上安装应用程序,并且实际上将为客户增值,因为他们的设置在设备之间同步。
But it actively discourages users from sharing their license key, since doing so would mean they would be sharing their settings with every pirate user, or that they would have to remember to stay disconnected from the Interwebs when they open or close the app.
但它主动阻止用户共享他们的许可证密钥,因为这样做意味着他们将与每个盗版用户共享他们的设置,或者他们必须记住在他们打开或关闭应用程序时保持与Interwebs断开连接。