我正在用Python开发一款软件,它将分发给我雇主的客户。我的雇主想用一个有时间限制的许可证文件来限制软件的使用。
如果我们分发.py文件甚至.pyc文件,将很容易(反编译和)删除检查许可证文件的代码。
另一个方面是,我的雇主不希望我们的客户读到代码,担心代码可能被窃取,或者至少是“新颖的想法”。
有什么好办法来解决这个问题吗?
我正在用Python开发一款软件,它将分发给我雇主的客户。我的雇主想用一个有时间限制的许可证文件来限制软件的使用。
如果我们分发.py文件甚至.pyc文件,将很容易(反编译和)删除检查许可证文件的代码。
另一个方面是,我的雇主不希望我们的客户读到代码,担心代码可能被窃取,或者至少是“新颖的想法”。
有什么好办法来解决这个问题吗?
当前回答
我理解您希望客户使用python的强大功能,但又不想公开源代码。
以下是我的建议:
(a)以C或c++库的形式编写代码的关键部分,然后使用SIP或swig将C/ c++ api公开给Python名称空间。
(b)使用cython而不是Python
(c)在(a)和(b)中,应该可以将库作为带有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.
可以将py2exe字节码放在C启动器的加密资源中,在内存中加载并执行它。这里和这里有一些想法。
有些人还想到了一种自我修改程序,使逆向工程变得昂贵。
您还可以找到防止调试器、使反汇编程序失败、设置错误调试器断点和使用校验和保护代码的教程。搜索[" crypded code" execute "in memory"]以获得更多链接。
但正如其他人所说,如果你的代码值得,逆向工程师最终会成功。
有一个关于隐藏python源代码的全面答案,可以在这里找到。
讨论的可能技术有: -使用编译字节码(python -m compileall) -可执行文件创建者(或安装程序,如PyInstaller) 软件即服务(在我看来,这是隐藏代码的最佳解决方案) - python源代码混淆器
你应该看看getdropbox.com的人是如何为他们的客户端软件(包括Linux)做这件事的。这是相当棘手的破解,需要一些相当有创意的拆卸来通过保护机制。
另一种让代码更难被窃取的方法是使用jython,然后使用java混淆器。
这应该工作得很好,因为jythonc将python代码转换为java,然后将java编译为字节码。因此,如果混淆了类,就很难理解反编译后会发生什么,更不用说恢复实际的代码了。
jython的唯一问题是你不能使用用c编写的python模块。