我正在用Python开发一款软件,它将分发给我雇主的客户。我的雇主想用一个有时间限制的许可证文件来限制软件的使用。

如果我们分发.py文件甚至.pyc文件,将很容易(反编译和)删除检查许可证文件的代码。

另一个方面是,我的雇主不希望我们的客户读到代码,担心代码可能被窃取,或者至少是“新颖的想法”。

有什么好办法来解决这个问题吗?


当前回答

另一种让代码更难被窃取的方法是使用jython,然后使用java混淆器。

这应该工作得很好,因为jythonc将python代码转换为java,然后将java编译为字节码。因此,如果混淆了类,就很难理解反编译后会发生什么,更不用说恢复实际的代码了。

jython的唯一问题是你不能使用用c编写的python模块。

其他回答

“有没有解决这个问题的好办法?”不。没有什么可以防止逆向工程。甚至DVD机器上的固件也被逆向工程,AACS加密密钥被暴露。这还是不顾DMCA规定的刑事犯罪。

由于没有任何技术方法可以阻止客户阅读您的代码,所以您必须应用普通的商业方法。

Licenses. Contracts. Terms and Conditions. This still works even when people can read the code. Note that some of your Python-based components may require that you pay fees before you sell software using those components. Also, some open-source licenses prohibit you from concealing the source or origins of that component. Offer significant value. If your stuff is so good -- at a price that is hard to refuse -- there's no incentive to waste time and money reverse engineering anything. Reverse engineering is expensive. Make your product slightly less expensive. Offer upgrades and enhancements that make any reverse engineering a bad idea. When the next release breaks their reverse engineering, there's no point. This can be carried to absurd extremes, but you should offer new features that make the next release more valuable than reverse engineering. Offer customization at rates so attractive that they'd rather pay you to build and support the enhancements. Use a license key which expires. This is cruel, and will give you a bad reputation, but it certainly makes your software stop working. Offer it as a web service. SaaS involves no downloads to customers.

取决于客户是谁,一个简单的保护机制,结合合理的许可协议将比任何复杂的许可/加密/混淆系统更有效。

最好的解决方案是将代码作为服务出售,比如托管服务,或者提供支持——尽管这并不总是可行的。

以.pyc文件的形式发布代码可以防止你的保护被一些#所破坏,但这几乎不是有效的反盗版保护(就像有这样的技术一样),而且归根结底,它不应该达到任何与公司签订像样的许可协议所能达到的效果。

专注于让你的代码尽可能好用——拥有满意的客户会让你的公司赚更多的钱,而不是防止一些理论上的盗版。

虽然没有完美的解决方案,但可以做到以下几点:

将一些关键的启动代码移到本地库中。 在本机库中执行许可证检查。

如果要删除对本机代码的调用,程序无论如何都不会启动。如果它没有被删除,那么许可证将被强制执行。

虽然这不是一个跨平台的或纯python的解决方案,但它可以工作。

你的雇主是否意识到他可以“偷”回其他人从你的代码中得到的任何想法?如果他们能读懂你的作品,你也能读懂他们的。也许看看你如何能从这种情况中受益,会比担心你可能会失去多少,获得更好的投资回报。

[编辑]回答尼克的评论:

没有得到也没有失去。客户得到了他想要的东西(因为他自己进行了更改,所以已经为此付费了)。因为他没有发布变更,就好像它没有发生在其他人身上一样。

现在如果客户出售软件,他们必须更改版权声明(这是非法的,所以你可以起诉并且会赢->简单的案件)。

如果他们不更改版权声明,第二级客户就会注意到软件来自您的原创,并想知道发生了什么。很有可能他们会联系你,这样你就会了解到你的作品被转售的情况。

同样,我们有两种情况:原来的客户只卖了几份。这意味着他们并没有赚到多少钱,所以为什么要麻烦呢。或者是销量。这意味着你有更好的机会了解他们的工作,并为此做些什么。

But in the end, most companies try to comply to the law (once their reputation is ruined, it's much harder to do business). So they will not steal your work but work with you to improve it. So if you include the source (with a license that protects you from simple reselling), chances are that they will simply push back changes they made since that will make sure the change is in the next version and they don't have to maintain it. That's win-win: You get changes and they can make the change themselves if they really, desperately need it even if you're unwilling to include it in the official release.

使用cxfreeze (Linux的py2exe)可以完成这项工作。

http://cx-freeze.sourceforge.net/

它可以在ubuntu存储库中找到