How do I protect Python code?











up vote
546
down vote

favorite
332












I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time restricted license file.



If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.



Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".



Is there a good way to handle this problem? Preferably with an off-the-shelf solution.



The software will run on Linux systems (so I don't think py2exe will do the trick).










share|improve this question




















  • 21




    py2exe just stores the .pyc byte code files in a .zip archive, so this is definitely not a solution. Still, that can be useful when combined with a suitable starup script to make it run unter Linux
    – Ber
    Nov 4 '08 at 12:35






  • 13




    like this: stackoverflow.com/questions/15955948/…
    – Dog
    Apr 25 '13 at 23:43















up vote
546
down vote

favorite
332












I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time restricted license file.



If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.



Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".



Is there a good way to handle this problem? Preferably with an off-the-shelf solution.



The software will run on Linux systems (so I don't think py2exe will do the trick).










share|improve this question




















  • 21




    py2exe just stores the .pyc byte code files in a .zip archive, so this is definitely not a solution. Still, that can be useful when combined with a suitable starup script to make it run unter Linux
    – Ber
    Nov 4 '08 at 12:35






  • 13




    like this: stackoverflow.com/questions/15955948/…
    – Dog
    Apr 25 '13 at 23:43













up vote
546
down vote

favorite
332









up vote
546
down vote

favorite
332






332





I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time restricted license file.



If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.



Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".



Is there a good way to handle this problem? Preferably with an off-the-shelf solution.



The software will run on Linux systems (so I don't think py2exe will do the trick).










share|improve this question















I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time restricted license file.



If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file.



Another aspect is that my employer does not want the code to be read by our customers, fearing that the code may be stolen or at least the "novel ideas".



Is there a good way to handle this problem? Preferably with an off-the-shelf solution.



The software will run on Linux systems (so I don't think py2exe will do the trick).







python licensing obfuscation copy-protection






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 22 '14 at 13:23









igaurav

2,02912035




2,02912035










asked Nov 4 '08 at 11:57









Jordfräs

3,45732227




3,45732227








  • 21




    py2exe just stores the .pyc byte code files in a .zip archive, so this is definitely not a solution. Still, that can be useful when combined with a suitable starup script to make it run unter Linux
    – Ber
    Nov 4 '08 at 12:35






  • 13




    like this: stackoverflow.com/questions/15955948/…
    – Dog
    Apr 25 '13 at 23:43














  • 21




    py2exe just stores the .pyc byte code files in a .zip archive, so this is definitely not a solution. Still, that can be useful when combined with a suitable starup script to make it run unter Linux
    – Ber
    Nov 4 '08 at 12:35






  • 13




    like this: stackoverflow.com/questions/15955948/…
    – Dog
    Apr 25 '13 at 23:43








21




21




py2exe just stores the .pyc byte code files in a .zip archive, so this is definitely not a solution. Still, that can be useful when combined with a suitable starup script to make it run unter Linux
– Ber
Nov 4 '08 at 12:35




py2exe just stores the .pyc byte code files in a .zip archive, so this is definitely not a solution. Still, that can be useful when combined with a suitable starup script to make it run unter Linux
– Ber
Nov 4 '08 at 12:35




13




13




like this: stackoverflow.com/questions/15955948/…
– Dog
Apr 25 '13 at 23:43




like this: stackoverflow.com/questions/15955948/…
– Dog
Apr 25 '13 at 23:43












26 Answers
26






active

oldest

votes

















up vote
329
down vote



accepted










Python, being a byte-code-compiled interpreted language, is very difficult to lock down. Even if you use a exe-packager like py2exe, the layout of the executable is well-known, and the Python byte-codes are well understood.



Usually in cases like this, you have to make a tradeoff. How important is it really to protect the code? Are there real secrets in there (such as a key for symmetric encryption of bank transfers), or are you just being paranoid? Choose the language that lets you develop the best product quickest, and be realistic about how valuable your novel ideas are.



If you decide you really need to enforce the license check securely, write it as a small C extension so that the license check code can be extra-hard (but not impossible!) to reverse engineer, and leave the bulk of your code in Python.






share|improve this answer

















  • 141




    Even if the license-checking code were hard to reverse engineer because it's written in C, wouldn't it still be relatively easy to remove the calls to the license-checking code?
    – Blair Conrad
    Nov 4 '08 at 12:04






  • 55




    Yes it would, depending on where the license check is performed. If there are many calls to the extension, it could be difficult to eradicate. Or you can move some other crucial part of the application into the license check as well so that removing the call to the extension cripples the app.
    – Ned Batchelder
    Nov 4 '08 at 12:10






  • 95




    Really, all of this work is not about preventing modification, but about increasing its difficulty so that it's no longer worth it. Anything can be reverse-engineered and modified if there's enough benefit.
    – Ned Batchelder
    Nov 4 '08 at 12:11






  • 11




    @Blair Conrad: Not if the license-checking code hides functionality, too. E.g. mylicensedfunction(licenseblob liblob, int foo, int bar, std::string bash)
    – Brian
    Aug 9 '10 at 14:26






  • 5




    I think the clever way is implementing critical parts in C and implement all license checking stuff in there. (I use hardware dongle which can implement some calculation inside it. So it's almost impossible to reverse it back.)
    – Dasun
    Oct 17 '11 at 9:22




















up vote
425
down vote













"Is there a good way to handle this problem?" No. Nothing can be protected against reverse engineering. Even the firmware on DVD machines has been reverse engineered and AACS Encryption key exposed. And that's in spite of the DMCA making that a criminal offense.



Since no technical method can stop your customers from reading your code, you have to apply ordinary commercial methods.




  1. 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.


  2. 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.


  3. 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.


  4. Offer customization at rates so attractive that they'd rather pay you do build and support the enhancements.


  5. Use a license key which expires. This is cruel, and will give you a bad reputation, but it certainly makes your software stop working.


  6. Offer it as a web service. SaaS involves no downloads to customers.







share|improve this answer



















  • 4




    Point 2 is even more important. If it's cheaper buy than reverse engineering, plus yearly updates, no one will try and even if it does, no one will pay a hacker instead the provider of the software.
    – erm3nda
    Sep 1 '15 at 20:42










  • That's true. Reverse engineering is doable but expensive in most situations. @S.Lott, I believe point 6 holds more importance based on the question. If the source code really needs to be protected then it should be remote from the end user.
    – assetCorp
    Oct 10 '17 at 11:56


















up vote
302
down vote













Python is not the tool you need



You must use the right tool to do the right thing, and Python was not designed to be obfuscated. It's the contrary; everything is open or easy to reveal or modify in Python because that's the language's philosophy.



If you want something you can't see through, look for another tool. This is not a bad thing, it is important that several different tools exist for different usages.



Obfuscation is really hard



Even compiled programs can be reverse-engineered so don't think that you can fully protect any code. You can analyze obfuscated PHP, break the flash encryption key, etc. Newer versions of Windows are cracked every time.



Having a legal requirement is a good way to go



You cannot prevent somebody from misusing your code, but you can easily discover if someone does. Therefore, it's just a casual legal issue.



Code protection is overrated



Nowadays, business models tend to go for selling services instead of products. You cannot copy a service, pirate nor steal it. Maybe it's time to consider to go with the flow...






share|improve this answer



















  • 13




    Python is not the tool you need. Malbolge is. :)
    – johndodo
    Aug 4 '11 at 14:00






  • 27




    How does one "easily discover" if someone misuses my code?
    – Macke
    Sep 8 '11 at 10:49






  • 5




    Good answer, but "casual legal issue"? Really? Where do you live that you have any legal issues that are casual?
    – Mark E. Haase
    Sep 16 '13 at 13:40






  • 1




    So what programming language?
    – daniel__
    Jan 16 '14 at 17:10






  • 1




    I think, if we have a frequency - how often expensive obfuscated code is hacked - we could say about practicability of using Python and obfuscated code.
    – sergzach
    Feb 18 '15 at 10:28


















up vote
128
down vote













Compile python and distribute binaries!



Sensible idea:



Use Cython, Nuitka, Shed Skin or something similar to compile python to C code, then distribute your app as python binary libraries (pyd) instead.



That way, no Python (byte) code is left and you've done any reasonable amount of obscurification anyone (i.e. your employer) could expect from regular Code, I think. (.NET or Java less safe than this case, as that bytecode is not obfuscated and can relatively easily be decompiled into reasonable source.)



Cython is getting more and more compatible with CPython, so I think it should work. (I'm actually considering this for our product.. We're already building some thirdparty libs as pyd/dlls, so shipping our own python code as binaries is not a overly big step for us.)



See This Blog Post (not by me) for a tutorial on how to do it. (thx @hithwen)



Crazy idea:



You could probably get Cython to store the C-files separately for each module, then just concatenate them all and build them with heavy inlining. That way, your Python module is pretty monolithic and difficult to chip at with common tools.



Beyond crazy:



You might be able to build a single executable if you can link to (and optimize with) the python runtime and all libraries (dlls) statically. That way, it'd sure be difficult to intercept calls to/from python and whatever framework libraries you use. This cannot be done if you're using LGPL code though.






share|improve this answer



















  • 7




    @Macke, consider citing nuitka
    – gg349
    Dec 11 '14 at 17:24












  • Would compiling with cython work with a python 3.4 Django app, or could it be made to work without a huge amount of effort?
    – Daniel
    Sep 15 '15 at 4:35






  • 1




    stackoverflow.com/questions/32577864/…
    – Daniel
    Nov 4 '15 at 18:08






  • 3




    @mlvljr FWIW, IMHO compiling to binaries is a nice tradeoff between selling all your secrets and trying to protect against NSA-class reverse engineering. Esp if you have a big python code base and reasons to be paranoid. ;)
    – Macke
    Jan 8 '16 at 8:18








  • 2




    hithwen's POST is invalid now.
    – qg_java_17137
    Jun 5 at 12:45


















up vote
57
down vote













I understand that you want your customers to use the power of python but do not want expose the source code.



Here are my suggestions:



(a) Write the critical pieces of the code as C or C++ libraries and then use SIP or swig to expose the C/C++ APIs to Python namespace.



(b) Use cython instead of Python



(c) In both (a) and (b), it should be possible to distribute the libraries as licensed binary with a Python interface.






share|improve this answer

















  • 1




    Other possibilities in the same vein: Shed Skin code.google.com/p/shedskin and Nuitka kayhayen24x7.homelinux.org/blog/nuitka-a-python-compiler
    – TryPyPy
    Jan 14 '11 at 4:03










  • I just gave a look on Shed Skin as suggested by TyPyPy and it appears to be really good stuff!
    – Filipe
    Jan 29 '13 at 11:47


















up vote
32
down vote













Is your employer aware that he can "steal" back any ideas that other people get from your code? I mean, if they can read your work, so can you theirs. Maybe looking at how you can benefit from the situation would yield a better return of your investment than fearing how much you could lose.



[EDIT] Answer to Nick's comment:



Nothing gained and nothing lost. The customer has what he wants (and paid for it since he did the change himself). Since he doesn't release the change, it's as if it didn't happen for everyone else.



Now if the customer sells the software, they have to change the copyright notice (which is illegal, so you can sue and will win -> simple case).



If they don't change the copyright notice, the 2nd level customers will notice that the software comes from you original and wonder what is going on. Chances are that they will contact you and so you will learn about the reselling of your work.



Again we have two cases: The original customer sold only a few copies. That means they didn't make much money anyway, so why bother. Or they sold in volume. That means better chances for you to learn about what they do and do something about it.



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.






share|improve this answer























  • What if they release software to customers, and the customer modifies it internally without re-releasing it?
    – Nick T
    Aug 9 '10 at 13:36










  • @Nick: Doesn't change the situation in any way. See my edits.
    – Aaron Digulla
    Aug 9 '10 at 14:14






  • 4




    +1 for stealing ideas back. Why limit your client-serving power to your in-house solutions, when you could see how others improve on your solution and accordingly improve your own product? "If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas."
    – Jordan
    Apr 30 '13 at 5:04










  • What, if one of your customers re-releases your code or the ideas for free and anonymously? You can't tell who did it and sue them and because they didn't get benifit from it, you won't as well. This will ruine your work while one of you customers only paid the basic price for it. (obviously only works if you have more than one customer for your solution)
    – Skandix
    Apr 27 at 11:05








  • 1




    @Skandix How exactly would that work? Uploading your work on the Internet doesn't harm you. It would start to harm you if a lot of people would find it AND those people would be paying customers instead. Code theft is a myth. "My knowledge is for free, my time is expensive" (not sure who said that).
    – Aaron Digulla
    May 17 at 7:33


















up vote
25
down vote













Do not rely on obfuscation. As You have correctly concluded, it offers very limited protection.
UPDATE: Here is a link to paper which reverse engineered obfuscated python code in Dropbox. The approach - opcode remapping is a good barrier, but clearly it can be defeated.



Instead, as many posters have mentioned make it:




  • Not worth reverse engineering time (Your software is so good, it makes sense to pay)

  • Make them sign a contract and do a license audit if feasible.


Alternatively, as the kick-ass Python IDE WingIDE does: Give away the code. That's right, give the code away and have people come back for upgrades and support.






share|improve this answer



















  • 1




    Like this extreme idea. Gets it out there in a huge way and massive market share, then you have a very big customer base for support and addons. I have also been grappling with this question and all the "licensing" answers are basically bull because it doesn't protect against widespread copying, yet doesn't give you any market share advantage.
    – Thomas Browne
    Apr 16 '13 at 14:43




















up vote
23
down vote













Have you had a look at pyminifier? It does Minify, obfuscate, and compress Python code. The example code looks pretty nasty for casual reverse engineering.



$ pyminifier --nonlatin --replacement-length=50 /tmp/tumult.py
#!/usr/bin/env python3
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ=ImportError
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱=print
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡=False
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨=object
try:
import demiurgic
except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: You're not demiurgic. Actually, I think that's normal.")
try:
import mystificate
except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: Dark voodoo may be unreliable.")
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺬ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡
class ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨):
def __init__(self,*args,**kwargs):
pass
def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ클(self,dactyl):
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐=demiurgic.palpitation(dactyl)
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲=mystificate.dark_voodoo(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐)
return ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲
def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯(self,whatever):
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱(whatever)
if __name__=="__main__":
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Forming...")
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚("epicaricacy","perseverate")
ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ.ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯("Codswallop")
# Created by pyminifier (https://github.com/liftoff/pyminifier)





share|improve this answer

















  • 5




    The good point on this, is to demoralize anyone who try to decode functionallity. Combine that with Cython and some extra crypt over modules or internet calls, and you probably got prize.
    – erm3nda
    Sep 1 '15 at 20:28




















up vote
16
down vote













In some circumstances, it may be possible to move (all, or at least a key part) of the software into a web service that your organization hosts.



That way, the license checks can be performed in the safety of your own server room.






share|improve this answer





















  • +1 (back to 0): it seems the only true solution to the problem, assuming such an approach to be practical for the setting.
    – intuited
    Jul 21 '10 at 17:41






  • 9




    Beaware that if your licensing webserver goes down or the customers internet access is down your customer will not be happy that they can't run thier business because of loss of access to licensing checks.
    – DevPlayer
    Jul 3 '12 at 16:45






  • 1




    @DevPlayer There are solutions to this. You could implement a local key mechanism that allows temporary access when the software cannot reach the remote licensing server.
    – Jeffrey
    Mar 2 '14 at 17:49






  • 1




    @Jeffrey: That gets you right back to where you started - how to you protect that code. To be safer, you need to put some of the key functionality on your own server, so replacing it would involve substantially effort (at which point, why not just start an open-source competitor?)
    – Oddthinking
    Apr 10 '15 at 14:31


















up vote
16
down vote













Shipping .pyc files has its problems - they are not compatible with any other python version than the python version they were created with, which means you must know which python version is running on the systems the product will run on. That's a very limiting factor.






share|improve this answer




























    up vote
    14
    down vote













    Though there's no perfect solution, the following can be done:




    1. Move some critical piece of startup code into a native library.

    2. Enforce the license check in the native library.


    If the call to the native code were to be removed, the program wouldn't start anyway. If it's not removed then the license will be enforced.



    Though this is not a cross-platform or a pure-Python solution, it will work.






    share|improve this answer



















    • 3




      The native library approach makes it much easier for someone to programmatically brute force your license key system as they can use your own code and API to validate their licenses.
      – Tom Leys
      Nov 24 '08 at 1:15






    • 7




      So? Use RSA to sign your licence and let them brute force your private key, say consisting of 1024 bits. It is possible, but takes a lot of time... and thus - money.
      – Abgan
      Dec 29 '08 at 2:18


















    up vote
    9
    down vote













    Depending in who the client is, a simple protection mechanism, combined with a sensible license agreement will be far more effective than any complex licensing/encryption/obfuscation system.



    The best solution would be selling the code as a service, say by hosting the service, or offering support - although that isn't always practical.



    Shipping the code as .pyc files will prevent your protection being foiled by a few #s, but it's hardly effective anti-piracy protection (as if there is such a technology), and at the end of the day, it shouldn't achieve anything that a decent license agreement with the company will.



    Concentrate on making your code as nice to use as possible - having happy customers will make your company far more money than preventing some theoretical piracy..






    share|improve this answer




























      up vote
      9
      down vote













      The reliable only way to protect code is to run it on a server you control and provide your clients with a client which interfaces with that server.






      share|improve this answer




























        up vote
        9
        down vote













        I think there is one more method to protect your Python code; part of the Obfuscation method. I beleive there was a game like Mount and Blade or something that changed and recompiled their own python interpreter (the original interpreter which i believe is open source) and just changed the OP codes in the OP code table to be different then the standard python OP codes.



        So the python source is unmodified but the file extentions of the pyc files are different and the op codes don't match to the public python.exe interpreter. If you checked the games data files all the data was in Python source format.



        All sorts of nasty tricks can be done to mess with amature hackers this way. Stopping a bunch of noob hackers is easy. It's the pro hackers that you will not likely beat. But most companies don't keep pro hackers on staff long I imagine (likely because things get hacked). But amature hackers are all over the place (read as curious IT staff).



        You could for example, in a modified interpreter, allow it to check for certain comments or docstrings in your source. You could have special OP codes for such lines of code. For example:



        OP 234 is for source line "# Copyright I wrote this"
        or compile that line into op codes that are equivelent to "if False:" if "# Copyright" is missing. Basically disabling a whole block of code for what appears to be some obsure reason.



        One use case where recompiling a modified interpreter may be feasable is where you didn't write the app, the app is big, but you are paid to protect it, such as when you're a dedicated server admin for a financial app.



        I find it a little contradictory to leave the source or opcodes open for eyeballs, but use SSL for network traffic. SSL is not 100% safe either. But it's used to stop MOST eyes from reading it. A wee bit precaution is sensible.



        Also, if enough people deem that Python source and opcodes are too visible, it's likely someone will eventually develope at least a simple protection tool for it. So the more people asking "how to protect Python app" only promotes that development.






        share|improve this answer




























          up vote
          8
          down vote













          Another attempt to make your code harder to steal is to use jython and then use java obfuscator.



          This should work pretty well as jythonc translate python code to java and then java is compiled to bytecode. So ounce you obfuscate the classes it will be really hard to understand what is going on after decompilation, not to mention recovering the actual code.



          The only problem with jython is that you can't use python modules written in c.






          share|improve this answer




























            up vote
            6
            down vote













            What about signing your code with standard encryption schemes by hashing and signing important files and checking it with public key methods?



            In this way you can issue license file with a public key for each customer.



            Additional you can use an python obfuscator like this one (just googled it).






            share|improve this answer





















            • +1 For the signing; -1 for the obfuscator You can at least prevent the code from being changed.
              – Ali Afshar
              Nov 4 '08 at 13:07






            • 2




              Signing does not work in this context. It's always possible to bypass the signature-checking loader. The first thing you need for useful software protection is an opaque bootstrap mechanism. Not something that Python makes easy.
              – ddaa
              Nov 4 '08 at 13:41










            • Yes, bootstrap in non-python.
              – Ali Afshar
              Nov 4 '08 at 16:27










            • Or validate the licence not only on startup but in several other places. Can be easily implemented, and can severely increase the time to bypass.
              – Abgan
              Dec 29 '08 at 2:21


















            up vote
            6
            down vote













            You should take a look at how the guys at getdropbox.com do it for their client software, including Linux. It's quite tricky to crack and requires some quite creative disassembly to get past the protection mechanisms.






            share|improve this answer

















            • 8




              but the fact that it was gotten past meant that they failed - the bottom line is just don't try, but go for legal protection.
              – Chii
              Nov 17 '08 at 9:52










            • Is there any information published on how to get pass this protection mechanisms?
              – Mitar
              Nov 20 '12 at 2:33


















            up vote
            5
            down vote













            The best you can do with Python is to obscure things.




            • Strip out all docstrings

            • Distribute only the .pyc compiled files.

            • freeze it

            • Obscure your constants inside a class/module so that help(config) doesn't show everything


            You may be able to add some additional obscurity by encrypting part of it and decrypting it on the fly and passing it to eval(). But no matter what you do someone can break it.



            None of this will stop a determined attacker from disassembling the bytecode or digging through your api with help, dir, etc.






            share|improve this answer




























              up vote
              5
              down vote













              Idea of having time restricted license and check for it in locally installed program will not work. Even with perfect obfuscation, license check can be removed. However if you check license on remote system and run significant part of the program on your closed remote system, you will be able to protect your IP.



              Preventing competitors from using the source code as their own or write their inspired version of the same code, one way to protect is to add signatures to your program logic (some secrets to be able to prove that code was stolen from you) and obfuscate the python source code so, it's hard to read and utilize.



              Good obfuscation adds basically the same protection to your code, that compiling it to executable (and stripping binary) does. Figuring out how obfuscated complex code works might be even harder than actually writing your own implementation.



              This will not help preventing hacking of your program. Even with obfuscation code license stuff will be cracked and program may be modified to have slightly different behaviour (in the same way that compiling code to binary does not help protection of native programs).



              In addition to symbol obfuscation might be good idea to unrefactor the code, which makes everything even more confusing if e.g. call graphs points to many different places even if actually those different places does eventually the same thing.



              Logical signature inside obfuscated code (e.g. you may create table of values which are used by program logic, but also used as signature), which can be used to determine that code is originated from you. If someone decides to use your obfuscated code module as part of their own product (even after reobfuscating it to make it seem different) you can show, that code is stolen with your secret signature.






              share|improve this answer






























                up vote
                5
                down vote













                Use Cython. It will compile your modules to high-performant C files, which can then be compiled to native binary libraries. This is basically un-reversable, comparing to .pyc bytecode!



                I've written a detailed article on how to set up Cython for a Python project, check it out:



                Protecting Python Sources With Cython






                share|improve this answer






























                  up vote
                  4
                  down vote













                  I have looked at software protection in general for my own projects and the general philosophy is that complete protection is impossible. The only thing that you can hope to achieve is to add protection to a level that would cost your customer more to bypass than it would to purchase another license.



                  With that said I was just checking google for python obsfucation and not turning up a lot of anything. In a .Net solution, obsfucation would be a first approach to your problem on a windows platform, but I am not sure if anyone has solutions on Linux that work with Mono.



                  The next thing would be to write your code in a compiled language, or if you really want to go all the way, then in assembler. A stripped out executable would be a lot harder to decompile than an interpreted language.



                  It all comes down to tradeoffs. On one end you have ease of software development in python, in which it is also very hard to hide secrets. On the other end you have software written in assembler which is much harder to write, but is much easier to hide secrets.



                  Your boss has to choose a point somewhere along that continuum that supports his requirements. And then he has to give you the tools and time so you can build what he wants. However my bet is that he will object to real development costs versus potential monetary losses.






                  share|improve this answer




























                    up vote
                    4
                    down vote













                    I was surprised in not seeing pyconcrete in any answer. Maybe because it's newer than the question?



                    It could be exactly what you need(ed).



                    Instead of obfuscating the code, it encrypts it and decrypts at load time.



                    From pypi page:




                    Protect python script work flow




                    • your_script.py import pyconcrete

                    • pyconcrete will hook import module

                    • when your script do import MODULE,
                      pyconcrete import hook will try to find MODULE.pye first and then
                      decrypt MODULE.pye via _pyconcrete.pyd and execute decrypted data (as
                      .pyc content)

                    • encrypt & decrypt secret key record in _pyconcrete.pyd
                      (like DLL or SO) the secret key would be hide in binary code, can’t
                      see it directly in HEX view







                    share|improve this answer




























                      up vote
                      3
                      down vote













                      It is possible to have the py2exe byte-code in a crypted resource for a C launcher that loads and executes it in memory. Some ideas here and here.



                      Some have also thought of a self modifying program to make reverse engineering expensive.



                      You can also find tutorials for preventing debuggers, make the disassembler fail, set false debugger breakpoints and protect your code with checksums. Search for ["crypted code" execute "in memory"] for more links.



                      But as others already said, if your code is worth it, reverse engineers will succeed in the end.






                      share|improve this answer






























                        up vote
                        2
                        down vote













                        Long story short:




                        1. Encrypt your source code

                        2. Write your own python module loader to decrypt your code when importing

                        3. Implement the module loader in C/C++

                        4. You can add more features to the module loader, for example anti-debugger, license control, hardware fingerprint binding, etc.


                        For more detail, look this answer.



                        If you are interested in the topic, this project will help you - pyprotect.






                        share|improve this answer




























                          up vote
                          1
                          down vote













                          using cxfreeze ( py2exe for linux ) will do the job.



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



                          it is available in ubuntu repositories






                          share|improve this answer

















                          • 5




                            I think that simply bundles the .pyc files. Cython, Shed Skin, and PyPy go beyond bytecode.
                            – Cees Timmerman
                            Aug 3 '12 at 11:47


















                          up vote
                          0
                          down vote













                          Use the same way to protect binary file of c/c++, that is, obfuscate each function body in executable or library binary file, insert an instruction "jump" at the begin of each function entry, jump to special function to restore obfuscated code. Byte-code is binary code of Python script, so




                          • First compile python script to code object

                          • Then iterate each code object, obfuscate co_code of each code object as the following



                          0 JUMP_ABSOLUTE n = 3 + len(bytecode)

                          3
                          ...
                          ... Here it's obfuscated bytecode
                          ...

                          n LOAD_GLOBAL ? (__pyarmor__)
                          n+3 CALL_FUNCTION 0
                          n+6 POP_TOP
                          n+7 JUMP_ABSOLUTE 0



                          • Save obfuscated code object as .pyc or .pyo file


                          Those obfuscated file (.pyc or .pyo) can be used by normal python interpreter, when those code object is called first time




                          • First op is JUMP_ABSOLUTE, it will jump to offset n



                          • At offset n, the instruction is to call a PyCFunction. This function will restore those obfuscated bytecode between offset 3 and n, and put the original byte-code at offset 0. The obfuscated code can be got by the following code




                            char *obfucated_bytecode;
                            Py_ssize_t len;
                            PyFrameObject* frame = PyEval_GetFrame();
                            PyCodeObject *f_code = frame->f_code;
                            PyObject *co_code = f_code->co_code;
                            PyBytes_AsStringAndSize(co_code, &obfucated_bytecode, &len)


                          • After this function returns, the last instruction is to jump to
                            offset 0. The really byte-code now is executed.



                          There is a tool Pyarmor to obfuscate python scripts by this way.






                          share|improve this answer




















                            protected by Ashwini Chaudhary Mar 27 '14 at 22:40



                            Thank you for your interest in this question.
                            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                            Would you like to answer one of these unanswered questions instead?














                            26 Answers
                            26






                            active

                            oldest

                            votes








                            26 Answers
                            26






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes








                            up vote
                            329
                            down vote



                            accepted










                            Python, being a byte-code-compiled interpreted language, is very difficult to lock down. Even if you use a exe-packager like py2exe, the layout of the executable is well-known, and the Python byte-codes are well understood.



                            Usually in cases like this, you have to make a tradeoff. How important is it really to protect the code? Are there real secrets in there (such as a key for symmetric encryption of bank transfers), or are you just being paranoid? Choose the language that lets you develop the best product quickest, and be realistic about how valuable your novel ideas are.



                            If you decide you really need to enforce the license check securely, write it as a small C extension so that the license check code can be extra-hard (but not impossible!) to reverse engineer, and leave the bulk of your code in Python.






                            share|improve this answer

















                            • 141




                              Even if the license-checking code were hard to reverse engineer because it's written in C, wouldn't it still be relatively easy to remove the calls to the license-checking code?
                              – Blair Conrad
                              Nov 4 '08 at 12:04






                            • 55




                              Yes it would, depending on where the license check is performed. If there are many calls to the extension, it could be difficult to eradicate. Or you can move some other crucial part of the application into the license check as well so that removing the call to the extension cripples the app.
                              – Ned Batchelder
                              Nov 4 '08 at 12:10






                            • 95




                              Really, all of this work is not about preventing modification, but about increasing its difficulty so that it's no longer worth it. Anything can be reverse-engineered and modified if there's enough benefit.
                              – Ned Batchelder
                              Nov 4 '08 at 12:11






                            • 11




                              @Blair Conrad: Not if the license-checking code hides functionality, too. E.g. mylicensedfunction(licenseblob liblob, int foo, int bar, std::string bash)
                              – Brian
                              Aug 9 '10 at 14:26






                            • 5




                              I think the clever way is implementing critical parts in C and implement all license checking stuff in there. (I use hardware dongle which can implement some calculation inside it. So it's almost impossible to reverse it back.)
                              – Dasun
                              Oct 17 '11 at 9:22

















                            up vote
                            329
                            down vote



                            accepted










                            Python, being a byte-code-compiled interpreted language, is very difficult to lock down. Even if you use a exe-packager like py2exe, the layout of the executable is well-known, and the Python byte-codes are well understood.



                            Usually in cases like this, you have to make a tradeoff. How important is it really to protect the code? Are there real secrets in there (such as a key for symmetric encryption of bank transfers), or are you just being paranoid? Choose the language that lets you develop the best product quickest, and be realistic about how valuable your novel ideas are.



                            If you decide you really need to enforce the license check securely, write it as a small C extension so that the license check code can be extra-hard (but not impossible!) to reverse engineer, and leave the bulk of your code in Python.






                            share|improve this answer

















                            • 141




                              Even if the license-checking code were hard to reverse engineer because it's written in C, wouldn't it still be relatively easy to remove the calls to the license-checking code?
                              – Blair Conrad
                              Nov 4 '08 at 12:04






                            • 55




                              Yes it would, depending on where the license check is performed. If there are many calls to the extension, it could be difficult to eradicate. Or you can move some other crucial part of the application into the license check as well so that removing the call to the extension cripples the app.
                              – Ned Batchelder
                              Nov 4 '08 at 12:10






                            • 95




                              Really, all of this work is not about preventing modification, but about increasing its difficulty so that it's no longer worth it. Anything can be reverse-engineered and modified if there's enough benefit.
                              – Ned Batchelder
                              Nov 4 '08 at 12:11






                            • 11




                              @Blair Conrad: Not if the license-checking code hides functionality, too. E.g. mylicensedfunction(licenseblob liblob, int foo, int bar, std::string bash)
                              – Brian
                              Aug 9 '10 at 14:26






                            • 5




                              I think the clever way is implementing critical parts in C and implement all license checking stuff in there. (I use hardware dongle which can implement some calculation inside it. So it's almost impossible to reverse it back.)
                              – Dasun
                              Oct 17 '11 at 9:22















                            up vote
                            329
                            down vote



                            accepted







                            up vote
                            329
                            down vote



                            accepted






                            Python, being a byte-code-compiled interpreted language, is very difficult to lock down. Even if you use a exe-packager like py2exe, the layout of the executable is well-known, and the Python byte-codes are well understood.



                            Usually in cases like this, you have to make a tradeoff. How important is it really to protect the code? Are there real secrets in there (such as a key for symmetric encryption of bank transfers), or are you just being paranoid? Choose the language that lets you develop the best product quickest, and be realistic about how valuable your novel ideas are.



                            If you decide you really need to enforce the license check securely, write it as a small C extension so that the license check code can be extra-hard (but not impossible!) to reverse engineer, and leave the bulk of your code in Python.






                            share|improve this answer












                            Python, being a byte-code-compiled interpreted language, is very difficult to lock down. Even if you use a exe-packager like py2exe, the layout of the executable is well-known, and the Python byte-codes are well understood.



                            Usually in cases like this, you have to make a tradeoff. How important is it really to protect the code? Are there real secrets in there (such as a key for symmetric encryption of bank transfers), or are you just being paranoid? Choose the language that lets you develop the best product quickest, and be realistic about how valuable your novel ideas are.



                            If you decide you really need to enforce the license check securely, write it as a small C extension so that the license check code can be extra-hard (but not impossible!) to reverse engineer, and leave the bulk of your code in Python.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 4 '08 at 12:00









                            Ned Batchelder

                            251k50438565




                            251k50438565








                            • 141




                              Even if the license-checking code were hard to reverse engineer because it's written in C, wouldn't it still be relatively easy to remove the calls to the license-checking code?
                              – Blair Conrad
                              Nov 4 '08 at 12:04






                            • 55




                              Yes it would, depending on where the license check is performed. If there are many calls to the extension, it could be difficult to eradicate. Or you can move some other crucial part of the application into the license check as well so that removing the call to the extension cripples the app.
                              – Ned Batchelder
                              Nov 4 '08 at 12:10






                            • 95




                              Really, all of this work is not about preventing modification, but about increasing its difficulty so that it's no longer worth it. Anything can be reverse-engineered and modified if there's enough benefit.
                              – Ned Batchelder
                              Nov 4 '08 at 12:11






                            • 11




                              @Blair Conrad: Not if the license-checking code hides functionality, too. E.g. mylicensedfunction(licenseblob liblob, int foo, int bar, std::string bash)
                              – Brian
                              Aug 9 '10 at 14:26






                            • 5




                              I think the clever way is implementing critical parts in C and implement all license checking stuff in there. (I use hardware dongle which can implement some calculation inside it. So it's almost impossible to reverse it back.)
                              – Dasun
                              Oct 17 '11 at 9:22
















                            • 141




                              Even if the license-checking code were hard to reverse engineer because it's written in C, wouldn't it still be relatively easy to remove the calls to the license-checking code?
                              – Blair Conrad
                              Nov 4 '08 at 12:04






                            • 55




                              Yes it would, depending on where the license check is performed. If there are many calls to the extension, it could be difficult to eradicate. Or you can move some other crucial part of the application into the license check as well so that removing the call to the extension cripples the app.
                              – Ned Batchelder
                              Nov 4 '08 at 12:10






                            • 95




                              Really, all of this work is not about preventing modification, but about increasing its difficulty so that it's no longer worth it. Anything can be reverse-engineered and modified if there's enough benefit.
                              – Ned Batchelder
                              Nov 4 '08 at 12:11






                            • 11




                              @Blair Conrad: Not if the license-checking code hides functionality, too. E.g. mylicensedfunction(licenseblob liblob, int foo, int bar, std::string bash)
                              – Brian
                              Aug 9 '10 at 14:26






                            • 5




                              I think the clever way is implementing critical parts in C and implement all license checking stuff in there. (I use hardware dongle which can implement some calculation inside it. So it's almost impossible to reverse it back.)
                              – Dasun
                              Oct 17 '11 at 9:22










                            141




                            141




                            Even if the license-checking code were hard to reverse engineer because it's written in C, wouldn't it still be relatively easy to remove the calls to the license-checking code?
                            – Blair Conrad
                            Nov 4 '08 at 12:04




                            Even if the license-checking code were hard to reverse engineer because it's written in C, wouldn't it still be relatively easy to remove the calls to the license-checking code?
                            – Blair Conrad
                            Nov 4 '08 at 12:04




                            55




                            55




                            Yes it would, depending on where the license check is performed. If there are many calls to the extension, it could be difficult to eradicate. Or you can move some other crucial part of the application into the license check as well so that removing the call to the extension cripples the app.
                            – Ned Batchelder
                            Nov 4 '08 at 12:10




                            Yes it would, depending on where the license check is performed. If there are many calls to the extension, it could be difficult to eradicate. Or you can move some other crucial part of the application into the license check as well so that removing the call to the extension cripples the app.
                            – Ned Batchelder
                            Nov 4 '08 at 12:10




                            95




                            95




                            Really, all of this work is not about preventing modification, but about increasing its difficulty so that it's no longer worth it. Anything can be reverse-engineered and modified if there's enough benefit.
                            – Ned Batchelder
                            Nov 4 '08 at 12:11




                            Really, all of this work is not about preventing modification, but about increasing its difficulty so that it's no longer worth it. Anything can be reverse-engineered and modified if there's enough benefit.
                            – Ned Batchelder
                            Nov 4 '08 at 12:11




                            11




                            11




                            @Blair Conrad: Not if the license-checking code hides functionality, too. E.g. mylicensedfunction(licenseblob liblob, int foo, int bar, std::string bash)
                            – Brian
                            Aug 9 '10 at 14:26




                            @Blair Conrad: Not if the license-checking code hides functionality, too. E.g. mylicensedfunction(licenseblob liblob, int foo, int bar, std::string bash)
                            – Brian
                            Aug 9 '10 at 14:26




                            5




                            5




                            I think the clever way is implementing critical parts in C and implement all license checking stuff in there. (I use hardware dongle which can implement some calculation inside it. So it's almost impossible to reverse it back.)
                            – Dasun
                            Oct 17 '11 at 9:22






                            I think the clever way is implementing critical parts in C and implement all license checking stuff in there. (I use hardware dongle which can implement some calculation inside it. So it's almost impossible to reverse it back.)
                            – Dasun
                            Oct 17 '11 at 9:22














                            up vote
                            425
                            down vote













                            "Is there a good way to handle this problem?" No. Nothing can be protected against reverse engineering. Even the firmware on DVD machines has been reverse engineered and AACS Encryption key exposed. And that's in spite of the DMCA making that a criminal offense.



                            Since no technical method can stop your customers from reading your code, you have to apply ordinary commercial methods.




                            1. 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.


                            2. 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.


                            3. 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.


                            4. Offer customization at rates so attractive that they'd rather pay you do build and support the enhancements.


                            5. Use a license key which expires. This is cruel, and will give you a bad reputation, but it certainly makes your software stop working.


                            6. Offer it as a web service. SaaS involves no downloads to customers.







                            share|improve this answer



















                            • 4




                              Point 2 is even more important. If it's cheaper buy than reverse engineering, plus yearly updates, no one will try and even if it does, no one will pay a hacker instead the provider of the software.
                              – erm3nda
                              Sep 1 '15 at 20:42










                            • That's true. Reverse engineering is doable but expensive in most situations. @S.Lott, I believe point 6 holds more importance based on the question. If the source code really needs to be protected then it should be remote from the end user.
                              – assetCorp
                              Oct 10 '17 at 11:56















                            up vote
                            425
                            down vote













                            "Is there a good way to handle this problem?" No. Nothing can be protected against reverse engineering. Even the firmware on DVD machines has been reverse engineered and AACS Encryption key exposed. And that's in spite of the DMCA making that a criminal offense.



                            Since no technical method can stop your customers from reading your code, you have to apply ordinary commercial methods.




                            1. 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.


                            2. 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.


                            3. 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.


                            4. Offer customization at rates so attractive that they'd rather pay you do build and support the enhancements.


                            5. Use a license key which expires. This is cruel, and will give you a bad reputation, but it certainly makes your software stop working.


                            6. Offer it as a web service. SaaS involves no downloads to customers.







                            share|improve this answer



















                            • 4




                              Point 2 is even more important. If it's cheaper buy than reverse engineering, plus yearly updates, no one will try and even if it does, no one will pay a hacker instead the provider of the software.
                              – erm3nda
                              Sep 1 '15 at 20:42










                            • That's true. Reverse engineering is doable but expensive in most situations. @S.Lott, I believe point 6 holds more importance based on the question. If the source code really needs to be protected then it should be remote from the end user.
                              – assetCorp
                              Oct 10 '17 at 11:56













                            up vote
                            425
                            down vote










                            up vote
                            425
                            down vote









                            "Is there a good way to handle this problem?" No. Nothing can be protected against reverse engineering. Even the firmware on DVD machines has been reverse engineered and AACS Encryption key exposed. And that's in spite of the DMCA making that a criminal offense.



                            Since no technical method can stop your customers from reading your code, you have to apply ordinary commercial methods.




                            1. 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.


                            2. 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.


                            3. 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.


                            4. Offer customization at rates so attractive that they'd rather pay you do build and support the enhancements.


                            5. Use a license key which expires. This is cruel, and will give you a bad reputation, but it certainly makes your software stop working.


                            6. Offer it as a web service. SaaS involves no downloads to customers.







                            share|improve this answer














                            "Is there a good way to handle this problem?" No. Nothing can be protected against reverse engineering. Even the firmware on DVD machines has been reverse engineered and AACS Encryption key exposed. And that's in spite of the DMCA making that a criminal offense.



                            Since no technical method can stop your customers from reading your code, you have to apply ordinary commercial methods.




                            1. 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.


                            2. 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.


                            3. 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.


                            4. Offer customization at rates so attractive that they'd rather pay you do build and support the enhancements.


                            5. Use a license key which expires. This is cruel, and will give you a bad reputation, but it certainly makes your software stop working.


                            6. Offer it as a web service. SaaS involves no downloads to customers.








                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 4 '09 at 19:27

























                            answered Nov 4 '08 at 12:29









                            S.Lott

                            313k66436714




                            313k66436714








                            • 4




                              Point 2 is even more important. If it's cheaper buy than reverse engineering, plus yearly updates, no one will try and even if it does, no one will pay a hacker instead the provider of the software.
                              – erm3nda
                              Sep 1 '15 at 20:42










                            • That's true. Reverse engineering is doable but expensive in most situations. @S.Lott, I believe point 6 holds more importance based on the question. If the source code really needs to be protected then it should be remote from the end user.
                              – assetCorp
                              Oct 10 '17 at 11:56














                            • 4




                              Point 2 is even more important. If it's cheaper buy than reverse engineering, plus yearly updates, no one will try and even if it does, no one will pay a hacker instead the provider of the software.
                              – erm3nda
                              Sep 1 '15 at 20:42










                            • That's true. Reverse engineering is doable but expensive in most situations. @S.Lott, I believe point 6 holds more importance based on the question. If the source code really needs to be protected then it should be remote from the end user.
                              – assetCorp
                              Oct 10 '17 at 11:56








                            4




                            4




                            Point 2 is even more important. If it's cheaper buy than reverse engineering, plus yearly updates, no one will try and even if it does, no one will pay a hacker instead the provider of the software.
                            – erm3nda
                            Sep 1 '15 at 20:42




                            Point 2 is even more important. If it's cheaper buy than reverse engineering, plus yearly updates, no one will try and even if it does, no one will pay a hacker instead the provider of the software.
                            – erm3nda
                            Sep 1 '15 at 20:42












                            That's true. Reverse engineering is doable but expensive in most situations. @S.Lott, I believe point 6 holds more importance based on the question. If the source code really needs to be protected then it should be remote from the end user.
                            – assetCorp
                            Oct 10 '17 at 11:56




                            That's true. Reverse engineering is doable but expensive in most situations. @S.Lott, I believe point 6 holds more importance based on the question. If the source code really needs to be protected then it should be remote from the end user.
                            – assetCorp
                            Oct 10 '17 at 11:56










                            up vote
                            302
                            down vote













                            Python is not the tool you need



                            You must use the right tool to do the right thing, and Python was not designed to be obfuscated. It's the contrary; everything is open or easy to reveal or modify in Python because that's the language's philosophy.



                            If you want something you can't see through, look for another tool. This is not a bad thing, it is important that several different tools exist for different usages.



                            Obfuscation is really hard



                            Even compiled programs can be reverse-engineered so don't think that you can fully protect any code. You can analyze obfuscated PHP, break the flash encryption key, etc. Newer versions of Windows are cracked every time.



                            Having a legal requirement is a good way to go



                            You cannot prevent somebody from misusing your code, but you can easily discover if someone does. Therefore, it's just a casual legal issue.



                            Code protection is overrated



                            Nowadays, business models tend to go for selling services instead of products. You cannot copy a service, pirate nor steal it. Maybe it's time to consider to go with the flow...






                            share|improve this answer



















                            • 13




                              Python is not the tool you need. Malbolge is. :)
                              – johndodo
                              Aug 4 '11 at 14:00






                            • 27




                              How does one "easily discover" if someone misuses my code?
                              – Macke
                              Sep 8 '11 at 10:49






                            • 5




                              Good answer, but "casual legal issue"? Really? Where do you live that you have any legal issues that are casual?
                              – Mark E. Haase
                              Sep 16 '13 at 13:40






                            • 1




                              So what programming language?
                              – daniel__
                              Jan 16 '14 at 17:10






                            • 1




                              I think, if we have a frequency - how often expensive obfuscated code is hacked - we could say about practicability of using Python and obfuscated code.
                              – sergzach
                              Feb 18 '15 at 10:28















                            up vote
                            302
                            down vote













                            Python is not the tool you need



                            You must use the right tool to do the right thing, and Python was not designed to be obfuscated. It's the contrary; everything is open or easy to reveal or modify in Python because that's the language's philosophy.



                            If you want something you can't see through, look for another tool. This is not a bad thing, it is important that several different tools exist for different usages.



                            Obfuscation is really hard



                            Even compiled programs can be reverse-engineered so don't think that you can fully protect any code. You can analyze obfuscated PHP, break the flash encryption key, etc. Newer versions of Windows are cracked every time.



                            Having a legal requirement is a good way to go



                            You cannot prevent somebody from misusing your code, but you can easily discover if someone does. Therefore, it's just a casual legal issue.



                            Code protection is overrated



                            Nowadays, business models tend to go for selling services instead of products. You cannot copy a service, pirate nor steal it. Maybe it's time to consider to go with the flow...






                            share|improve this answer



















                            • 13




                              Python is not the tool you need. Malbolge is. :)
                              – johndodo
                              Aug 4 '11 at 14:00






                            • 27




                              How does one "easily discover" if someone misuses my code?
                              – Macke
                              Sep 8 '11 at 10:49






                            • 5




                              Good answer, but "casual legal issue"? Really? Where do you live that you have any legal issues that are casual?
                              – Mark E. Haase
                              Sep 16 '13 at 13:40






                            • 1




                              So what programming language?
                              – daniel__
                              Jan 16 '14 at 17:10






                            • 1




                              I think, if we have a frequency - how often expensive obfuscated code is hacked - we could say about practicability of using Python and obfuscated code.
                              – sergzach
                              Feb 18 '15 at 10:28













                            up vote
                            302
                            down vote










                            up vote
                            302
                            down vote









                            Python is not the tool you need



                            You must use the right tool to do the right thing, and Python was not designed to be obfuscated. It's the contrary; everything is open or easy to reveal or modify in Python because that's the language's philosophy.



                            If you want something you can't see through, look for another tool. This is not a bad thing, it is important that several different tools exist for different usages.



                            Obfuscation is really hard



                            Even compiled programs can be reverse-engineered so don't think that you can fully protect any code. You can analyze obfuscated PHP, break the flash encryption key, etc. Newer versions of Windows are cracked every time.



                            Having a legal requirement is a good way to go



                            You cannot prevent somebody from misusing your code, but you can easily discover if someone does. Therefore, it's just a casual legal issue.



                            Code protection is overrated



                            Nowadays, business models tend to go for selling services instead of products. You cannot copy a service, pirate nor steal it. Maybe it's time to consider to go with the flow...






                            share|improve this answer














                            Python is not the tool you need



                            You must use the right tool to do the right thing, and Python was not designed to be obfuscated. It's the contrary; everything is open or easy to reveal or modify in Python because that's the language's philosophy.



                            If you want something you can't see through, look for another tool. This is not a bad thing, it is important that several different tools exist for different usages.



                            Obfuscation is really hard



                            Even compiled programs can be reverse-engineered so don't think that you can fully protect any code. You can analyze obfuscated PHP, break the flash encryption key, etc. Newer versions of Windows are cracked every time.



                            Having a legal requirement is a good way to go



                            You cannot prevent somebody from misusing your code, but you can easily discover if someone does. Therefore, it's just a casual legal issue.



                            Code protection is overrated



                            Nowadays, business models tend to go for selling services instead of products. You cannot copy a service, pirate nor steal it. Maybe it's time to consider to go with the flow...







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 23 '11 at 7:10









                            Jeff Mercado

                            89.8k18182210




                            89.8k18182210










                            answered Nov 4 '08 at 13:03









                            e-satis

                            348k96264308




                            348k96264308








                            • 13




                              Python is not the tool you need. Malbolge is. :)
                              – johndodo
                              Aug 4 '11 at 14:00






                            • 27




                              How does one "easily discover" if someone misuses my code?
                              – Macke
                              Sep 8 '11 at 10:49






                            • 5




                              Good answer, but "casual legal issue"? Really? Where do you live that you have any legal issues that are casual?
                              – Mark E. Haase
                              Sep 16 '13 at 13:40






                            • 1




                              So what programming language?
                              – daniel__
                              Jan 16 '14 at 17:10






                            • 1




                              I think, if we have a frequency - how often expensive obfuscated code is hacked - we could say about practicability of using Python and obfuscated code.
                              – sergzach
                              Feb 18 '15 at 10:28














                            • 13




                              Python is not the tool you need. Malbolge is. :)
                              – johndodo
                              Aug 4 '11 at 14:00






                            • 27




                              How does one "easily discover" if someone misuses my code?
                              – Macke
                              Sep 8 '11 at 10:49






                            • 5




                              Good answer, but "casual legal issue"? Really? Where do you live that you have any legal issues that are casual?
                              – Mark E. Haase
                              Sep 16 '13 at 13:40






                            • 1




                              So what programming language?
                              – daniel__
                              Jan 16 '14 at 17:10






                            • 1




                              I think, if we have a frequency - how often expensive obfuscated code is hacked - we could say about practicability of using Python and obfuscated code.
                              – sergzach
                              Feb 18 '15 at 10:28








                            13




                            13




                            Python is not the tool you need. Malbolge is. :)
                            – johndodo
                            Aug 4 '11 at 14:00




                            Python is not the tool you need. Malbolge is. :)
                            – johndodo
                            Aug 4 '11 at 14:00




                            27




                            27




                            How does one "easily discover" if someone misuses my code?
                            – Macke
                            Sep 8 '11 at 10:49




                            How does one "easily discover" if someone misuses my code?
                            – Macke
                            Sep 8 '11 at 10:49




                            5




                            5




                            Good answer, but "casual legal issue"? Really? Where do you live that you have any legal issues that are casual?
                            – Mark E. Haase
                            Sep 16 '13 at 13:40




                            Good answer, but "casual legal issue"? Really? Where do you live that you have any legal issues that are casual?
                            – Mark E. Haase
                            Sep 16 '13 at 13:40




                            1




                            1




                            So what programming language?
                            – daniel__
                            Jan 16 '14 at 17:10




                            So what programming language?
                            – daniel__
                            Jan 16 '14 at 17:10




                            1




                            1




                            I think, if we have a frequency - how often expensive obfuscated code is hacked - we could say about practicability of using Python and obfuscated code.
                            – sergzach
                            Feb 18 '15 at 10:28




                            I think, if we have a frequency - how often expensive obfuscated code is hacked - we could say about practicability of using Python and obfuscated code.
                            – sergzach
                            Feb 18 '15 at 10:28










                            up vote
                            128
                            down vote













                            Compile python and distribute binaries!



                            Sensible idea:



                            Use Cython, Nuitka, Shed Skin or something similar to compile python to C code, then distribute your app as python binary libraries (pyd) instead.



                            That way, no Python (byte) code is left and you've done any reasonable amount of obscurification anyone (i.e. your employer) could expect from regular Code, I think. (.NET or Java less safe than this case, as that bytecode is not obfuscated and can relatively easily be decompiled into reasonable source.)



                            Cython is getting more and more compatible with CPython, so I think it should work. (I'm actually considering this for our product.. We're already building some thirdparty libs as pyd/dlls, so shipping our own python code as binaries is not a overly big step for us.)



                            See This Blog Post (not by me) for a tutorial on how to do it. (thx @hithwen)



                            Crazy idea:



                            You could probably get Cython to store the C-files separately for each module, then just concatenate them all and build them with heavy inlining. That way, your Python module is pretty monolithic and difficult to chip at with common tools.



                            Beyond crazy:



                            You might be able to build a single executable if you can link to (and optimize with) the python runtime and all libraries (dlls) statically. That way, it'd sure be difficult to intercept calls to/from python and whatever framework libraries you use. This cannot be done if you're using LGPL code though.






                            share|improve this answer



















                            • 7




                              @Macke, consider citing nuitka
                              – gg349
                              Dec 11 '14 at 17:24












                            • Would compiling with cython work with a python 3.4 Django app, or could it be made to work without a huge amount of effort?
                              – Daniel
                              Sep 15 '15 at 4:35






                            • 1




                              stackoverflow.com/questions/32577864/…
                              – Daniel
                              Nov 4 '15 at 18:08






                            • 3




                              @mlvljr FWIW, IMHO compiling to binaries is a nice tradeoff between selling all your secrets and trying to protect against NSA-class reverse engineering. Esp if you have a big python code base and reasons to be paranoid. ;)
                              – Macke
                              Jan 8 '16 at 8:18








                            • 2




                              hithwen's POST is invalid now.
                              – qg_java_17137
                              Jun 5 at 12:45















                            up vote
                            128
                            down vote













                            Compile python and distribute binaries!



                            Sensible idea:



                            Use Cython, Nuitka, Shed Skin or something similar to compile python to C code, then distribute your app as python binary libraries (pyd) instead.



                            That way, no Python (byte) code is left and you've done any reasonable amount of obscurification anyone (i.e. your employer) could expect from regular Code, I think. (.NET or Java less safe than this case, as that bytecode is not obfuscated and can relatively easily be decompiled into reasonable source.)



                            Cython is getting more and more compatible with CPython, so I think it should work. (I'm actually considering this for our product.. We're already building some thirdparty libs as pyd/dlls, so shipping our own python code as binaries is not a overly big step for us.)



                            See This Blog Post (not by me) for a tutorial on how to do it. (thx @hithwen)



                            Crazy idea:



                            You could probably get Cython to store the C-files separately for each module, then just concatenate them all and build them with heavy inlining. That way, your Python module is pretty monolithic and difficult to chip at with common tools.



                            Beyond crazy:



                            You might be able to build a single executable if you can link to (and optimize with) the python runtime and all libraries (dlls) statically. That way, it'd sure be difficult to intercept calls to/from python and whatever framework libraries you use. This cannot be done if you're using LGPL code though.






                            share|improve this answer



















                            • 7




                              @Macke, consider citing nuitka
                              – gg349
                              Dec 11 '14 at 17:24












                            • Would compiling with cython work with a python 3.4 Django app, or could it be made to work without a huge amount of effort?
                              – Daniel
                              Sep 15 '15 at 4:35






                            • 1




                              stackoverflow.com/questions/32577864/…
                              – Daniel
                              Nov 4 '15 at 18:08






                            • 3




                              @mlvljr FWIW, IMHO compiling to binaries is a nice tradeoff between selling all your secrets and trying to protect against NSA-class reverse engineering. Esp if you have a big python code base and reasons to be paranoid. ;)
                              – Macke
                              Jan 8 '16 at 8:18








                            • 2




                              hithwen's POST is invalid now.
                              – qg_java_17137
                              Jun 5 at 12:45













                            up vote
                            128
                            down vote










                            up vote
                            128
                            down vote









                            Compile python and distribute binaries!



                            Sensible idea:



                            Use Cython, Nuitka, Shed Skin or something similar to compile python to C code, then distribute your app as python binary libraries (pyd) instead.



                            That way, no Python (byte) code is left and you've done any reasonable amount of obscurification anyone (i.e. your employer) could expect from regular Code, I think. (.NET or Java less safe than this case, as that bytecode is not obfuscated and can relatively easily be decompiled into reasonable source.)



                            Cython is getting more and more compatible with CPython, so I think it should work. (I'm actually considering this for our product.. We're already building some thirdparty libs as pyd/dlls, so shipping our own python code as binaries is not a overly big step for us.)



                            See This Blog Post (not by me) for a tutorial on how to do it. (thx @hithwen)



                            Crazy idea:



                            You could probably get Cython to store the C-files separately for each module, then just concatenate them all and build them with heavy inlining. That way, your Python module is pretty monolithic and difficult to chip at with common tools.



                            Beyond crazy:



                            You might be able to build a single executable if you can link to (and optimize with) the python runtime and all libraries (dlls) statically. That way, it'd sure be difficult to intercept calls to/from python and whatever framework libraries you use. This cannot be done if you're using LGPL code though.






                            share|improve this answer














                            Compile python and distribute binaries!



                            Sensible idea:



                            Use Cython, Nuitka, Shed Skin or something similar to compile python to C code, then distribute your app as python binary libraries (pyd) instead.



                            That way, no Python (byte) code is left and you've done any reasonable amount of obscurification anyone (i.e. your employer) could expect from regular Code, I think. (.NET or Java less safe than this case, as that bytecode is not obfuscated and can relatively easily be decompiled into reasonable source.)



                            Cython is getting more and more compatible with CPython, so I think it should work. (I'm actually considering this for our product.. We're already building some thirdparty libs as pyd/dlls, so shipping our own python code as binaries is not a overly big step for us.)



                            See This Blog Post (not by me) for a tutorial on how to do it. (thx @hithwen)



                            Crazy idea:



                            You could probably get Cython to store the C-files separately for each module, then just concatenate them all and build them with heavy inlining. That way, your Python module is pretty monolithic and difficult to chip at with common tools.



                            Beyond crazy:



                            You might be able to build a single executable if you can link to (and optimize with) the python runtime and all libraries (dlls) statically. That way, it'd sure be difficult to intercept calls to/from python and whatever framework libraries you use. This cannot be done if you're using LGPL code though.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jul 19 at 8:18









                            Ziv

                            1,28411533




                            1,28411533










                            answered Sep 8 '11 at 11:14









                            Macke

                            19k56591




                            19k56591








                            • 7




                              @Macke, consider citing nuitka
                              – gg349
                              Dec 11 '14 at 17:24












                            • Would compiling with cython work with a python 3.4 Django app, or could it be made to work without a huge amount of effort?
                              – Daniel
                              Sep 15 '15 at 4:35






                            • 1




                              stackoverflow.com/questions/32577864/…
                              – Daniel
                              Nov 4 '15 at 18:08






                            • 3




                              @mlvljr FWIW, IMHO compiling to binaries is a nice tradeoff between selling all your secrets and trying to protect against NSA-class reverse engineering. Esp if you have a big python code base and reasons to be paranoid. ;)
                              – Macke
                              Jan 8 '16 at 8:18








                            • 2




                              hithwen's POST is invalid now.
                              – qg_java_17137
                              Jun 5 at 12:45














                            • 7




                              @Macke, consider citing nuitka
                              – gg349
                              Dec 11 '14 at 17:24












                            • Would compiling with cython work with a python 3.4 Django app, or could it be made to work without a huge amount of effort?
                              – Daniel
                              Sep 15 '15 at 4:35






                            • 1




                              stackoverflow.com/questions/32577864/…
                              – Daniel
                              Nov 4 '15 at 18:08






                            • 3




                              @mlvljr FWIW, IMHO compiling to binaries is a nice tradeoff between selling all your secrets and trying to protect against NSA-class reverse engineering. Esp if you have a big python code base and reasons to be paranoid. ;)
                              – Macke
                              Jan 8 '16 at 8:18








                            • 2




                              hithwen's POST is invalid now.
                              – qg_java_17137
                              Jun 5 at 12:45








                            7




                            7




                            @Macke, consider citing nuitka
                            – gg349
                            Dec 11 '14 at 17:24






                            @Macke, consider citing nuitka
                            – gg349
                            Dec 11 '14 at 17:24














                            Would compiling with cython work with a python 3.4 Django app, or could it be made to work without a huge amount of effort?
                            – Daniel
                            Sep 15 '15 at 4:35




                            Would compiling with cython work with a python 3.4 Django app, or could it be made to work without a huge amount of effort?
                            – Daniel
                            Sep 15 '15 at 4:35




                            1




                            1




                            stackoverflow.com/questions/32577864/…
                            – Daniel
                            Nov 4 '15 at 18:08




                            stackoverflow.com/questions/32577864/…
                            – Daniel
                            Nov 4 '15 at 18:08




                            3




                            3




                            @mlvljr FWIW, IMHO compiling to binaries is a nice tradeoff between selling all your secrets and trying to protect against NSA-class reverse engineering. Esp if you have a big python code base and reasons to be paranoid. ;)
                            – Macke
                            Jan 8 '16 at 8:18






                            @mlvljr FWIW, IMHO compiling to binaries is a nice tradeoff between selling all your secrets and trying to protect against NSA-class reverse engineering. Esp if you have a big python code base and reasons to be paranoid. ;)
                            – Macke
                            Jan 8 '16 at 8:18






                            2




                            2




                            hithwen's POST is invalid now.
                            – qg_java_17137
                            Jun 5 at 12:45




                            hithwen's POST is invalid now.
                            – qg_java_17137
                            Jun 5 at 12:45










                            up vote
                            57
                            down vote













                            I understand that you want your customers to use the power of python but do not want expose the source code.



                            Here are my suggestions:



                            (a) Write the critical pieces of the code as C or C++ libraries and then use SIP or swig to expose the C/C++ APIs to Python namespace.



                            (b) Use cython instead of Python



                            (c) In both (a) and (b), it should be possible to distribute the libraries as licensed binary with a Python interface.






                            share|improve this answer

















                            • 1




                              Other possibilities in the same vein: Shed Skin code.google.com/p/shedskin and Nuitka kayhayen24x7.homelinux.org/blog/nuitka-a-python-compiler
                              – TryPyPy
                              Jan 14 '11 at 4:03










                            • I just gave a look on Shed Skin as suggested by TyPyPy and it appears to be really good stuff!
                              – Filipe
                              Jan 29 '13 at 11:47















                            up vote
                            57
                            down vote













                            I understand that you want your customers to use the power of python but do not want expose the source code.



                            Here are my suggestions:



                            (a) Write the critical pieces of the code as C or C++ libraries and then use SIP or swig to expose the C/C++ APIs to Python namespace.



                            (b) Use cython instead of Python



                            (c) In both (a) and (b), it should be possible to distribute the libraries as licensed binary with a Python interface.






                            share|improve this answer

















                            • 1




                              Other possibilities in the same vein: Shed Skin code.google.com/p/shedskin and Nuitka kayhayen24x7.homelinux.org/blog/nuitka-a-python-compiler
                              – TryPyPy
                              Jan 14 '11 at 4:03










                            • I just gave a look on Shed Skin as suggested by TyPyPy and it appears to be really good stuff!
                              – Filipe
                              Jan 29 '13 at 11:47













                            up vote
                            57
                            down vote










                            up vote
                            57
                            down vote









                            I understand that you want your customers to use the power of python but do not want expose the source code.



                            Here are my suggestions:



                            (a) Write the critical pieces of the code as C or C++ libraries and then use SIP or swig to expose the C/C++ APIs to Python namespace.



                            (b) Use cython instead of Python



                            (c) In both (a) and (b), it should be possible to distribute the libraries as licensed binary with a Python interface.






                            share|improve this answer












                            I understand that you want your customers to use the power of python but do not want expose the source code.



                            Here are my suggestions:



                            (a) Write the critical pieces of the code as C or C++ libraries and then use SIP or swig to expose the C/C++ APIs to Python namespace.



                            (b) Use cython instead of Python



                            (c) In both (a) and (b), it should be possible to distribute the libraries as licensed binary with a Python interface.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 6 '08 at 7:41









                            bhadra

                            10.9k74546




                            10.9k74546








                            • 1




                              Other possibilities in the same vein: Shed Skin code.google.com/p/shedskin and Nuitka kayhayen24x7.homelinux.org/blog/nuitka-a-python-compiler
                              – TryPyPy
                              Jan 14 '11 at 4:03










                            • I just gave a look on Shed Skin as suggested by TyPyPy and it appears to be really good stuff!
                              – Filipe
                              Jan 29 '13 at 11:47














                            • 1




                              Other possibilities in the same vein: Shed Skin code.google.com/p/shedskin and Nuitka kayhayen24x7.homelinux.org/blog/nuitka-a-python-compiler
                              – TryPyPy
                              Jan 14 '11 at 4:03










                            • I just gave a look on Shed Skin as suggested by TyPyPy and it appears to be really good stuff!
                              – Filipe
                              Jan 29 '13 at 11:47








                            1




                            1




                            Other possibilities in the same vein: Shed Skin code.google.com/p/shedskin and Nuitka kayhayen24x7.homelinux.org/blog/nuitka-a-python-compiler
                            – TryPyPy
                            Jan 14 '11 at 4:03




                            Other possibilities in the same vein: Shed Skin code.google.com/p/shedskin and Nuitka kayhayen24x7.homelinux.org/blog/nuitka-a-python-compiler
                            – TryPyPy
                            Jan 14 '11 at 4:03












                            I just gave a look on Shed Skin as suggested by TyPyPy and it appears to be really good stuff!
                            – Filipe
                            Jan 29 '13 at 11:47




                            I just gave a look on Shed Skin as suggested by TyPyPy and it appears to be really good stuff!
                            – Filipe
                            Jan 29 '13 at 11:47










                            up vote
                            32
                            down vote













                            Is your employer aware that he can "steal" back any ideas that other people get from your code? I mean, if they can read your work, so can you theirs. Maybe looking at how you can benefit from the situation would yield a better return of your investment than fearing how much you could lose.



                            [EDIT] Answer to Nick's comment:



                            Nothing gained and nothing lost. The customer has what he wants (and paid for it since he did the change himself). Since he doesn't release the change, it's as if it didn't happen for everyone else.



                            Now if the customer sells the software, they have to change the copyright notice (which is illegal, so you can sue and will win -> simple case).



                            If they don't change the copyright notice, the 2nd level customers will notice that the software comes from you original and wonder what is going on. Chances are that they will contact you and so you will learn about the reselling of your work.



                            Again we have two cases: The original customer sold only a few copies. That means they didn't make much money anyway, so why bother. Or they sold in volume. That means better chances for you to learn about what they do and do something about it.



                            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.






                            share|improve this answer























                            • What if they release software to customers, and the customer modifies it internally without re-releasing it?
                              – Nick T
                              Aug 9 '10 at 13:36










                            • @Nick: Doesn't change the situation in any way. See my edits.
                              – Aaron Digulla
                              Aug 9 '10 at 14:14






                            • 4




                              +1 for stealing ideas back. Why limit your client-serving power to your in-house solutions, when you could see how others improve on your solution and accordingly improve your own product? "If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas."
                              – Jordan
                              Apr 30 '13 at 5:04










                            • What, if one of your customers re-releases your code or the ideas for free and anonymously? You can't tell who did it and sue them and because they didn't get benifit from it, you won't as well. This will ruine your work while one of you customers only paid the basic price for it. (obviously only works if you have more than one customer for your solution)
                              – Skandix
                              Apr 27 at 11:05








                            • 1




                              @Skandix How exactly would that work? Uploading your work on the Internet doesn't harm you. It would start to harm you if a lot of people would find it AND those people would be paying customers instead. Code theft is a myth. "My knowledge is for free, my time is expensive" (not sure who said that).
                              – Aaron Digulla
                              May 17 at 7:33















                            up vote
                            32
                            down vote













                            Is your employer aware that he can "steal" back any ideas that other people get from your code? I mean, if they can read your work, so can you theirs. Maybe looking at how you can benefit from the situation would yield a better return of your investment than fearing how much you could lose.



                            [EDIT] Answer to Nick's comment:



                            Nothing gained and nothing lost. The customer has what he wants (and paid for it since he did the change himself). Since he doesn't release the change, it's as if it didn't happen for everyone else.



                            Now if the customer sells the software, they have to change the copyright notice (which is illegal, so you can sue and will win -> simple case).



                            If they don't change the copyright notice, the 2nd level customers will notice that the software comes from you original and wonder what is going on. Chances are that they will contact you and so you will learn about the reselling of your work.



                            Again we have two cases: The original customer sold only a few copies. That means they didn't make much money anyway, so why bother. Or they sold in volume. That means better chances for you to learn about what they do and do something about it.



                            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.






                            share|improve this answer























                            • What if they release software to customers, and the customer modifies it internally without re-releasing it?
                              – Nick T
                              Aug 9 '10 at 13:36










                            • @Nick: Doesn't change the situation in any way. See my edits.
                              – Aaron Digulla
                              Aug 9 '10 at 14:14






                            • 4




                              +1 for stealing ideas back. Why limit your client-serving power to your in-house solutions, when you could see how others improve on your solution and accordingly improve your own product? "If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas."
                              – Jordan
                              Apr 30 '13 at 5:04










                            • What, if one of your customers re-releases your code or the ideas for free and anonymously? You can't tell who did it and sue them and because they didn't get benifit from it, you won't as well. This will ruine your work while one of you customers only paid the basic price for it. (obviously only works if you have more than one customer for your solution)
                              – Skandix
                              Apr 27 at 11:05








                            • 1




                              @Skandix How exactly would that work? Uploading your work on the Internet doesn't harm you. It would start to harm you if a lot of people would find it AND those people would be paying customers instead. Code theft is a myth. "My knowledge is for free, my time is expensive" (not sure who said that).
                              – Aaron Digulla
                              May 17 at 7:33













                            up vote
                            32
                            down vote










                            up vote
                            32
                            down vote









                            Is your employer aware that he can "steal" back any ideas that other people get from your code? I mean, if they can read your work, so can you theirs. Maybe looking at how you can benefit from the situation would yield a better return of your investment than fearing how much you could lose.



                            [EDIT] Answer to Nick's comment:



                            Nothing gained and nothing lost. The customer has what he wants (and paid for it since he did the change himself). Since he doesn't release the change, it's as if it didn't happen for everyone else.



                            Now if the customer sells the software, they have to change the copyright notice (which is illegal, so you can sue and will win -> simple case).



                            If they don't change the copyright notice, the 2nd level customers will notice that the software comes from you original and wonder what is going on. Chances are that they will contact you and so you will learn about the reselling of your work.



                            Again we have two cases: The original customer sold only a few copies. That means they didn't make much money anyway, so why bother. Or they sold in volume. That means better chances for you to learn about what they do and do something about it.



                            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.






                            share|improve this answer














                            Is your employer aware that he can "steal" back any ideas that other people get from your code? I mean, if they can read your work, so can you theirs. Maybe looking at how you can benefit from the situation would yield a better return of your investment than fearing how much you could lose.



                            [EDIT] Answer to Nick's comment:



                            Nothing gained and nothing lost. The customer has what he wants (and paid for it since he did the change himself). Since he doesn't release the change, it's as if it didn't happen for everyone else.



                            Now if the customer sells the software, they have to change the copyright notice (which is illegal, so you can sue and will win -> simple case).



                            If they don't change the copyright notice, the 2nd level customers will notice that the software comes from you original and wonder what is going on. Chances are that they will contact you and so you will learn about the reselling of your work.



                            Again we have two cases: The original customer sold only a few copies. That means they didn't make much money anyway, so why bother. Or they sold in volume. That means better chances for you to learn about what they do and do something about it.



                            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.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 20 '12 at 13:07

























                            answered Nov 4 '08 at 12:27









                            Aaron Digulla

                            243k82460682




                            243k82460682












                            • What if they release software to customers, and the customer modifies it internally without re-releasing it?
                              – Nick T
                              Aug 9 '10 at 13:36










                            • @Nick: Doesn't change the situation in any way. See my edits.
                              – Aaron Digulla
                              Aug 9 '10 at 14:14






                            • 4




                              +1 for stealing ideas back. Why limit your client-serving power to your in-house solutions, when you could see how others improve on your solution and accordingly improve your own product? "If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas."
                              – Jordan
                              Apr 30 '13 at 5:04










                            • What, if one of your customers re-releases your code or the ideas for free and anonymously? You can't tell who did it and sue them and because they didn't get benifit from it, you won't as well. This will ruine your work while one of you customers only paid the basic price for it. (obviously only works if you have more than one customer for your solution)
                              – Skandix
                              Apr 27 at 11:05








                            • 1




                              @Skandix How exactly would that work? Uploading your work on the Internet doesn't harm you. It would start to harm you if a lot of people would find it AND those people would be paying customers instead. Code theft is a myth. "My knowledge is for free, my time is expensive" (not sure who said that).
                              – Aaron Digulla
                              May 17 at 7:33


















                            • What if they release software to customers, and the customer modifies it internally without re-releasing it?
                              – Nick T
                              Aug 9 '10 at 13:36










                            • @Nick: Doesn't change the situation in any way. See my edits.
                              – Aaron Digulla
                              Aug 9 '10 at 14:14






                            • 4




                              +1 for stealing ideas back. Why limit your client-serving power to your in-house solutions, when you could see how others improve on your solution and accordingly improve your own product? "If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas."
                              – Jordan
                              Apr 30 '13 at 5:04










                            • What, if one of your customers re-releases your code or the ideas for free and anonymously? You can't tell who did it and sue them and because they didn't get benifit from it, you won't as well. This will ruine your work while one of you customers only paid the basic price for it. (obviously only works if you have more than one customer for your solution)
                              – Skandix
                              Apr 27 at 11:05








                            • 1




                              @Skandix How exactly would that work? Uploading your work on the Internet doesn't harm you. It would start to harm you if a lot of people would find it AND those people would be paying customers instead. Code theft is a myth. "My knowledge is for free, my time is expensive" (not sure who said that).
                              – Aaron Digulla
                              May 17 at 7:33
















                            What if they release software to customers, and the customer modifies it internally without re-releasing it?
                            – Nick T
                            Aug 9 '10 at 13:36




                            What if they release software to customers, and the customer modifies it internally without re-releasing it?
                            – Nick T
                            Aug 9 '10 at 13:36












                            @Nick: Doesn't change the situation in any way. See my edits.
                            – Aaron Digulla
                            Aug 9 '10 at 14:14




                            @Nick: Doesn't change the situation in any way. See my edits.
                            – Aaron Digulla
                            Aug 9 '10 at 14:14




                            4




                            4




                            +1 for stealing ideas back. Why limit your client-serving power to your in-house solutions, when you could see how others improve on your solution and accordingly improve your own product? "If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas."
                            – Jordan
                            Apr 30 '13 at 5:04




                            +1 for stealing ideas back. Why limit your client-serving power to your in-house solutions, when you could see how others improve on your solution and accordingly improve your own product? "If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas."
                            – Jordan
                            Apr 30 '13 at 5:04












                            What, if one of your customers re-releases your code or the ideas for free and anonymously? You can't tell who did it and sue them and because they didn't get benifit from it, you won't as well. This will ruine your work while one of you customers only paid the basic price for it. (obviously only works if you have more than one customer for your solution)
                            – Skandix
                            Apr 27 at 11:05






                            What, if one of your customers re-releases your code or the ideas for free and anonymously? You can't tell who did it and sue them and because they didn't get benifit from it, you won't as well. This will ruine your work while one of you customers only paid the basic price for it. (obviously only works if you have more than one customer for your solution)
                            – Skandix
                            Apr 27 at 11:05






                            1




                            1




                            @Skandix How exactly would that work? Uploading your work on the Internet doesn't harm you. It would start to harm you if a lot of people would find it AND those people would be paying customers instead. Code theft is a myth. "My knowledge is for free, my time is expensive" (not sure who said that).
                            – Aaron Digulla
                            May 17 at 7:33




                            @Skandix How exactly would that work? Uploading your work on the Internet doesn't harm you. It would start to harm you if a lot of people would find it AND those people would be paying customers instead. Code theft is a myth. "My knowledge is for free, my time is expensive" (not sure who said that).
                            – Aaron Digulla
                            May 17 at 7:33










                            up vote
                            25
                            down vote













                            Do not rely on obfuscation. As You have correctly concluded, it offers very limited protection.
                            UPDATE: Here is a link to paper which reverse engineered obfuscated python code in Dropbox. The approach - opcode remapping is a good barrier, but clearly it can be defeated.



                            Instead, as many posters have mentioned make it:




                            • Not worth reverse engineering time (Your software is so good, it makes sense to pay)

                            • Make them sign a contract and do a license audit if feasible.


                            Alternatively, as the kick-ass Python IDE WingIDE does: Give away the code. That's right, give the code away and have people come back for upgrades and support.






                            share|improve this answer



















                            • 1




                              Like this extreme idea. Gets it out there in a huge way and massive market share, then you have a very big customer base for support and addons. I have also been grappling with this question and all the "licensing" answers are basically bull because it doesn't protect against widespread copying, yet doesn't give you any market share advantage.
                              – Thomas Browne
                              Apr 16 '13 at 14:43

















                            up vote
                            25
                            down vote













                            Do not rely on obfuscation. As You have correctly concluded, it offers very limited protection.
                            UPDATE: Here is a link to paper which reverse engineered obfuscated python code in Dropbox. The approach - opcode remapping is a good barrier, but clearly it can be defeated.



                            Instead, as many posters have mentioned make it:




                            • Not worth reverse engineering time (Your software is so good, it makes sense to pay)

                            • Make them sign a contract and do a license audit if feasible.


                            Alternatively, as the kick-ass Python IDE WingIDE does: Give away the code. That's right, give the code away and have people come back for upgrades and support.






                            share|improve this answer



















                            • 1




                              Like this extreme idea. Gets it out there in a huge way and massive market share, then you have a very big customer base for support and addons. I have also been grappling with this question and all the "licensing" answers are basically bull because it doesn't protect against widespread copying, yet doesn't give you any market share advantage.
                              – Thomas Browne
                              Apr 16 '13 at 14:43















                            up vote
                            25
                            down vote










                            up vote
                            25
                            down vote









                            Do not rely on obfuscation. As You have correctly concluded, it offers very limited protection.
                            UPDATE: Here is a link to paper which reverse engineered obfuscated python code in Dropbox. The approach - opcode remapping is a good barrier, but clearly it can be defeated.



                            Instead, as many posters have mentioned make it:




                            • Not worth reverse engineering time (Your software is so good, it makes sense to pay)

                            • Make them sign a contract and do a license audit if feasible.


                            Alternatively, as the kick-ass Python IDE WingIDE does: Give away the code. That's right, give the code away and have people come back for upgrades and support.






                            share|improve this answer














                            Do not rely on obfuscation. As You have correctly concluded, it offers very limited protection.
                            UPDATE: Here is a link to paper which reverse engineered obfuscated python code in Dropbox. The approach - opcode remapping is a good barrier, but clearly it can be defeated.



                            Instead, as many posters have mentioned make it:




                            • Not worth reverse engineering time (Your software is so good, it makes sense to pay)

                            • Make them sign a contract and do a license audit if feasible.


                            Alternatively, as the kick-ass Python IDE WingIDE does: Give away the code. That's right, give the code away and have people come back for upgrades and support.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited May 8 '15 at 13:26

























                            answered Nov 4 '08 at 18:53









                            Konrads

                            1,24411631




                            1,24411631








                            • 1




                              Like this extreme idea. Gets it out there in a huge way and massive market share, then you have a very big customer base for support and addons. I have also been grappling with this question and all the "licensing" answers are basically bull because it doesn't protect against widespread copying, yet doesn't give you any market share advantage.
                              – Thomas Browne
                              Apr 16 '13 at 14:43
















                            • 1




                              Like this extreme idea. Gets it out there in a huge way and massive market share, then you have a very big customer base for support and addons. I have also been grappling with this question and all the "licensing" answers are basically bull because it doesn't protect against widespread copying, yet doesn't give you any market share advantage.
                              – Thomas Browne
                              Apr 16 '13 at 14:43










                            1




                            1




                            Like this extreme idea. Gets it out there in a huge way and massive market share, then you have a very big customer base for support and addons. I have also been grappling with this question and all the "licensing" answers are basically bull because it doesn't protect against widespread copying, yet doesn't give you any market share advantage.
                            – Thomas Browne
                            Apr 16 '13 at 14:43






                            Like this extreme idea. Gets it out there in a huge way and massive market share, then you have a very big customer base for support and addons. I have also been grappling with this question and all the "licensing" answers are basically bull because it doesn't protect against widespread copying, yet doesn't give you any market share advantage.
                            – Thomas Browne
                            Apr 16 '13 at 14:43












                            up vote
                            23
                            down vote













                            Have you had a look at pyminifier? It does Minify, obfuscate, and compress Python code. The example code looks pretty nasty for casual reverse engineering.



                            $ pyminifier --nonlatin --replacement-length=50 /tmp/tumult.py
                            #!/usr/bin/env python3
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ=ImportError
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱=print
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡=False
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨=object
                            try:
                            import demiurgic
                            except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: You're not demiurgic. Actually, I think that's normal.")
                            try:
                            import mystificate
                            except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: Dark voodoo may be unreliable.")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺬ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡
                            class ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨):
                            def __init__(self,*args,**kwargs):
                            pass
                            def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ클(self,dactyl):
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐=demiurgic.palpitation(dactyl)
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲=mystificate.dark_voodoo(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐)
                            return ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲
                            def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯(self,whatever):
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱(whatever)
                            if __name__=="__main__":
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Forming...")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚("epicaricacy","perseverate")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ.ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯("Codswallop")
                            # Created by pyminifier (https://github.com/liftoff/pyminifier)





                            share|improve this answer

















                            • 5




                              The good point on this, is to demoralize anyone who try to decode functionallity. Combine that with Cython and some extra crypt over modules or internet calls, and you probably got prize.
                              – erm3nda
                              Sep 1 '15 at 20:28

















                            up vote
                            23
                            down vote













                            Have you had a look at pyminifier? It does Minify, obfuscate, and compress Python code. The example code looks pretty nasty for casual reverse engineering.



                            $ pyminifier --nonlatin --replacement-length=50 /tmp/tumult.py
                            #!/usr/bin/env python3
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ=ImportError
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱=print
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡=False
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨=object
                            try:
                            import demiurgic
                            except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: You're not demiurgic. Actually, I think that's normal.")
                            try:
                            import mystificate
                            except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: Dark voodoo may be unreliable.")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺬ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡
                            class ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨):
                            def __init__(self,*args,**kwargs):
                            pass
                            def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ클(self,dactyl):
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐=demiurgic.palpitation(dactyl)
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲=mystificate.dark_voodoo(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐)
                            return ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲
                            def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯(self,whatever):
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱(whatever)
                            if __name__=="__main__":
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Forming...")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚("epicaricacy","perseverate")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ.ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯("Codswallop")
                            # Created by pyminifier (https://github.com/liftoff/pyminifier)





                            share|improve this answer

















                            • 5




                              The good point on this, is to demoralize anyone who try to decode functionallity. Combine that with Cython and some extra crypt over modules or internet calls, and you probably got prize.
                              – erm3nda
                              Sep 1 '15 at 20:28















                            up vote
                            23
                            down vote










                            up vote
                            23
                            down vote









                            Have you had a look at pyminifier? It does Minify, obfuscate, and compress Python code. The example code looks pretty nasty for casual reverse engineering.



                            $ pyminifier --nonlatin --replacement-length=50 /tmp/tumult.py
                            #!/usr/bin/env python3
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ=ImportError
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱=print
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡=False
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨=object
                            try:
                            import demiurgic
                            except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: You're not demiurgic. Actually, I think that's normal.")
                            try:
                            import mystificate
                            except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: Dark voodoo may be unreliable.")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺬ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡
                            class ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨):
                            def __init__(self,*args,**kwargs):
                            pass
                            def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ클(self,dactyl):
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐=demiurgic.palpitation(dactyl)
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲=mystificate.dark_voodoo(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐)
                            return ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲
                            def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯(self,whatever):
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱(whatever)
                            if __name__=="__main__":
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Forming...")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚("epicaricacy","perseverate")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ.ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯("Codswallop")
                            # Created by pyminifier (https://github.com/liftoff/pyminifier)





                            share|improve this answer












                            Have you had a look at pyminifier? It does Minify, obfuscate, and compress Python code. The example code looks pretty nasty for casual reverse engineering.



                            $ pyminifier --nonlatin --replacement-length=50 /tmp/tumult.py
                            #!/usr/bin/env python3
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ=ImportError
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱=print
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡=False
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨=object
                            try:
                            import demiurgic
                            except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: You're not demiurgic. Actually, I think that's normal.")
                            try:
                            import mystificate
                            except ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲמּ:
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Warning: Dark voodoo may be unreliable.")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺬ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ巡
                            class ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ澨):
                            def __init__(self,*args,**kwargs):
                            pass
                            def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ클(self,dactyl):
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐=demiurgic.palpitation(dactyl)
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲=mystificate.dark_voodoo(ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ퐐)
                            return ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𠛲
                            def ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯(self,whatever):
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱(whatever)
                            if __name__=="__main__":
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ燱("Forming...")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ=ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐦚("epicaricacy","perseverate")
                            ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲﺃ.ﺭ异𞸐𐤔ﭞﰣﺁں𝕌𨿩𞸇뻛𐬑𥰫嬭ﱌ𢽁𐡆𧪮Ꝫﴹ뙫𢤴퉊ﳦﲣפּܟﺶ𐐤ﶨࠔ𐰷𢡶𧐎𐭈𞸏𢢘𦘼ﶻ𩏃𦽨𞺎𠛘𐠲䉊ﰸﭳᣲ𐠯("Codswallop")
                            # Created by pyminifier (https://github.com/liftoff/pyminifier)






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered May 8 '15 at 10:21









                            Lmwangi

                            1,4601220




                            1,4601220








                            • 5




                              The good point on this, is to demoralize anyone who try to decode functionallity. Combine that with Cython and some extra crypt over modules or internet calls, and you probably got prize.
                              – erm3nda
                              Sep 1 '15 at 20:28
















                            • 5




                              The good point on this, is to demoralize anyone who try to decode functionallity. Combine that with Cython and some extra crypt over modules or internet calls, and you probably got prize.
                              – erm3nda
                              Sep 1 '15 at 20:28










                            5




                            5




                            The good point on this, is to demoralize anyone who try to decode functionallity. Combine that with Cython and some extra crypt over modules or internet calls, and you probably got prize.
                            – erm3nda
                            Sep 1 '15 at 20:28






                            The good point on this, is to demoralize anyone who try to decode functionallity. Combine that with Cython and some extra crypt over modules or internet calls, and you probably got prize.
                            – erm3nda
                            Sep 1 '15 at 20:28












                            up vote
                            16
                            down vote













                            In some circumstances, it may be possible to move (all, or at least a key part) of the software into a web service that your organization hosts.



                            That way, the license checks can be performed in the safety of your own server room.






                            share|improve this answer





















                            • +1 (back to 0): it seems the only true solution to the problem, assuming such an approach to be practical for the setting.
                              – intuited
                              Jul 21 '10 at 17:41






                            • 9




                              Beaware that if your licensing webserver goes down or the customers internet access is down your customer will not be happy that they can't run thier business because of loss of access to licensing checks.
                              – DevPlayer
                              Jul 3 '12 at 16:45






                            • 1




                              @DevPlayer There are solutions to this. You could implement a local key mechanism that allows temporary access when the software cannot reach the remote licensing server.
                              – Jeffrey
                              Mar 2 '14 at 17:49






                            • 1




                              @Jeffrey: That gets you right back to where you started - how to you protect that code. To be safer, you need to put some of the key functionality on your own server, so replacing it would involve substantially effort (at which point, why not just start an open-source competitor?)
                              – Oddthinking
                              Apr 10 '15 at 14:31















                            up vote
                            16
                            down vote













                            In some circumstances, it may be possible to move (all, or at least a key part) of the software into a web service that your organization hosts.



                            That way, the license checks can be performed in the safety of your own server room.






                            share|improve this answer





















                            • +1 (back to 0): it seems the only true solution to the problem, assuming such an approach to be practical for the setting.
                              – intuited
                              Jul 21 '10 at 17:41






                            • 9




                              Beaware that if your licensing webserver goes down or the customers internet access is down your customer will not be happy that they can't run thier business because of loss of access to licensing checks.
                              – DevPlayer
                              Jul 3 '12 at 16:45






                            • 1




                              @DevPlayer There are solutions to this. You could implement a local key mechanism that allows temporary access when the software cannot reach the remote licensing server.
                              – Jeffrey
                              Mar 2 '14 at 17:49






                            • 1




                              @Jeffrey: That gets you right back to where you started - how to you protect that code. To be safer, you need to put some of the key functionality on your own server, so replacing it would involve substantially effort (at which point, why not just start an open-source competitor?)
                              – Oddthinking
                              Apr 10 '15 at 14:31













                            up vote
                            16
                            down vote










                            up vote
                            16
                            down vote









                            In some circumstances, it may be possible to move (all, or at least a key part) of the software into a web service that your organization hosts.



                            That way, the license checks can be performed in the safety of your own server room.






                            share|improve this answer












                            In some circumstances, it may be possible to move (all, or at least a key part) of the software into a web service that your organization hosts.



                            That way, the license checks can be performed in the safety of your own server room.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 4 '08 at 12:29









                            Oddthinking

                            14k1061109




                            14k1061109












                            • +1 (back to 0): it seems the only true solution to the problem, assuming such an approach to be practical for the setting.
                              – intuited
                              Jul 21 '10 at 17:41






                            • 9




                              Beaware that if your licensing webserver goes down or the customers internet access is down your customer will not be happy that they can't run thier business because of loss of access to licensing checks.
                              – DevPlayer
                              Jul 3 '12 at 16:45






                            • 1




                              @DevPlayer There are solutions to this. You could implement a local key mechanism that allows temporary access when the software cannot reach the remote licensing server.
                              – Jeffrey
                              Mar 2 '14 at 17:49






                            • 1




                              @Jeffrey: That gets you right back to where you started - how to you protect that code. To be safer, you need to put some of the key functionality on your own server, so replacing it would involve substantially effort (at which point, why not just start an open-source competitor?)
                              – Oddthinking
                              Apr 10 '15 at 14:31


















                            • +1 (back to 0): it seems the only true solution to the problem, assuming such an approach to be practical for the setting.
                              – intuited
                              Jul 21 '10 at 17:41






                            • 9




                              Beaware that if your licensing webserver goes down or the customers internet access is down your customer will not be happy that they can't run thier business because of loss of access to licensing checks.
                              – DevPlayer
                              Jul 3 '12 at 16:45






                            • 1




                              @DevPlayer There are solutions to this. You could implement a local key mechanism that allows temporary access when the software cannot reach the remote licensing server.
                              – Jeffrey
                              Mar 2 '14 at 17:49






                            • 1




                              @Jeffrey: That gets you right back to where you started - how to you protect that code. To be safer, you need to put some of the key functionality on your own server, so replacing it would involve substantially effort (at which point, why not just start an open-source competitor?)
                              – Oddthinking
                              Apr 10 '15 at 14:31
















                            +1 (back to 0): it seems the only true solution to the problem, assuming such an approach to be practical for the setting.
                            – intuited
                            Jul 21 '10 at 17:41




                            +1 (back to 0): it seems the only true solution to the problem, assuming such an approach to be practical for the setting.
                            – intuited
                            Jul 21 '10 at 17:41




                            9




                            9




                            Beaware that if your licensing webserver goes down or the customers internet access is down your customer will not be happy that they can't run thier business because of loss of access to licensing checks.
                            – DevPlayer
                            Jul 3 '12 at 16:45




                            Beaware that if your licensing webserver goes down or the customers internet access is down your customer will not be happy that they can't run thier business because of loss of access to licensing checks.
                            – DevPlayer
                            Jul 3 '12 at 16:45




                            1




                            1




                            @DevPlayer There are solutions to this. You could implement a local key mechanism that allows temporary access when the software cannot reach the remote licensing server.
                            – Jeffrey
                            Mar 2 '14 at 17:49




                            @DevPlayer There are solutions to this. You could implement a local key mechanism that allows temporary access when the software cannot reach the remote licensing server.
                            – Jeffrey
                            Mar 2 '14 at 17:49




                            1




                            1




                            @Jeffrey: That gets you right back to where you started - how to you protect that code. To be safer, you need to put some of the key functionality on your own server, so replacing it would involve substantially effort (at which point, why not just start an open-source competitor?)
                            – Oddthinking
                            Apr 10 '15 at 14:31




                            @Jeffrey: That gets you right back to where you started - how to you protect that code. To be safer, you need to put some of the key functionality on your own server, so replacing it would involve substantially effort (at which point, why not just start an open-source competitor?)
                            – Oddthinking
                            Apr 10 '15 at 14:31










                            up vote
                            16
                            down vote













                            Shipping .pyc files has its problems - they are not compatible with any other python version than the python version they were created with, which means you must know which python version is running on the systems the product will run on. That's a very limiting factor.






                            share|improve this answer

























                              up vote
                              16
                              down vote













                              Shipping .pyc files has its problems - they are not compatible with any other python version than the python version they were created with, which means you must know which python version is running on the systems the product will run on. That's a very limiting factor.






                              share|improve this answer























                                up vote
                                16
                                down vote










                                up vote
                                16
                                down vote









                                Shipping .pyc files has its problems - they are not compatible with any other python version than the python version they were created with, which means you must know which python version is running on the systems the product will run on. That's a very limiting factor.






                                share|improve this answer












                                Shipping .pyc files has its problems - they are not compatible with any other python version than the python version they were created with, which means you must know which python version is running on the systems the product will run on. That's a very limiting factor.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Feb 16 '09 at 21:09









                                Erik Forsberg

                                3,63422129




                                3,63422129






















                                    up vote
                                    14
                                    down vote













                                    Though there's no perfect solution, the following can be done:




                                    1. Move some critical piece of startup code into a native library.

                                    2. Enforce the license check in the native library.


                                    If the call to the native code were to be removed, the program wouldn't start anyway. If it's not removed then the license will be enforced.



                                    Though this is not a cross-platform or a pure-Python solution, it will work.






                                    share|improve this answer



















                                    • 3




                                      The native library approach makes it much easier for someone to programmatically brute force your license key system as they can use your own code and API to validate their licenses.
                                      – Tom Leys
                                      Nov 24 '08 at 1:15






                                    • 7




                                      So? Use RSA to sign your licence and let them brute force your private key, say consisting of 1024 bits. It is possible, but takes a lot of time... and thus - money.
                                      – Abgan
                                      Dec 29 '08 at 2:18















                                    up vote
                                    14
                                    down vote













                                    Though there's no perfect solution, the following can be done:




                                    1. Move some critical piece of startup code into a native library.

                                    2. Enforce the license check in the native library.


                                    If the call to the native code were to be removed, the program wouldn't start anyway. If it's not removed then the license will be enforced.



                                    Though this is not a cross-platform or a pure-Python solution, it will work.






                                    share|improve this answer



















                                    • 3




                                      The native library approach makes it much easier for someone to programmatically brute force your license key system as they can use your own code and API to validate their licenses.
                                      – Tom Leys
                                      Nov 24 '08 at 1:15






                                    • 7




                                      So? Use RSA to sign your licence and let them brute force your private key, say consisting of 1024 bits. It is possible, but takes a lot of time... and thus - money.
                                      – Abgan
                                      Dec 29 '08 at 2:18













                                    up vote
                                    14
                                    down vote










                                    up vote
                                    14
                                    down vote









                                    Though there's no perfect solution, the following can be done:




                                    1. Move some critical piece of startup code into a native library.

                                    2. Enforce the license check in the native library.


                                    If the call to the native code were to be removed, the program wouldn't start anyway. If it's not removed then the license will be enforced.



                                    Though this is not a cross-platform or a pure-Python solution, it will work.






                                    share|improve this answer














                                    Though there's no perfect solution, the following can be done:




                                    1. Move some critical piece of startup code into a native library.

                                    2. Enforce the license check in the native library.


                                    If the call to the native code were to be removed, the program wouldn't start anyway. If it's not removed then the license will be enforced.



                                    Though this is not a cross-platform or a pure-Python solution, it will work.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Feb 8 '15 at 17:37









                                    Smi

                                    9,95864155




                                    9,95864155










                                    answered Nov 5 '08 at 6:10







                                    I K















                                    • 3




                                      The native library approach makes it much easier for someone to programmatically brute force your license key system as they can use your own code and API to validate their licenses.
                                      – Tom Leys
                                      Nov 24 '08 at 1:15






                                    • 7




                                      So? Use RSA to sign your licence and let them brute force your private key, say consisting of 1024 bits. It is possible, but takes a lot of time... and thus - money.
                                      – Abgan
                                      Dec 29 '08 at 2:18














                                    • 3




                                      The native library approach makes it much easier for someone to programmatically brute force your license key system as they can use your own code and API to validate their licenses.
                                      – Tom Leys
                                      Nov 24 '08 at 1:15






                                    • 7




                                      So? Use RSA to sign your licence and let them brute force your private key, say consisting of 1024 bits. It is possible, but takes a lot of time... and thus - money.
                                      – Abgan
                                      Dec 29 '08 at 2:18








                                    3




                                    3




                                    The native library approach makes it much easier for someone to programmatically brute force your license key system as they can use your own code and API to validate their licenses.
                                    – Tom Leys
                                    Nov 24 '08 at 1:15




                                    The native library approach makes it much easier for someone to programmatically brute force your license key system as they can use your own code and API to validate their licenses.
                                    – Tom Leys
                                    Nov 24 '08 at 1:15




                                    7




                                    7




                                    So? Use RSA to sign your licence and let them brute force your private key, say consisting of 1024 bits. It is possible, but takes a lot of time... and thus - money.
                                    – Abgan
                                    Dec 29 '08 at 2:18




                                    So? Use RSA to sign your licence and let them brute force your private key, say consisting of 1024 bits. It is possible, but takes a lot of time... and thus - money.
                                    – Abgan
                                    Dec 29 '08 at 2:18










                                    up vote
                                    9
                                    down vote













                                    Depending in who the client is, a simple protection mechanism, combined with a sensible license agreement will be far more effective than any complex licensing/encryption/obfuscation system.



                                    The best solution would be selling the code as a service, say by hosting the service, or offering support - although that isn't always practical.



                                    Shipping the code as .pyc files will prevent your protection being foiled by a few #s, but it's hardly effective anti-piracy protection (as if there is such a technology), and at the end of the day, it shouldn't achieve anything that a decent license agreement with the company will.



                                    Concentrate on making your code as nice to use as possible - having happy customers will make your company far more money than preventing some theoretical piracy..






                                    share|improve this answer

























                                      up vote
                                      9
                                      down vote













                                      Depending in who the client is, a simple protection mechanism, combined with a sensible license agreement will be far more effective than any complex licensing/encryption/obfuscation system.



                                      The best solution would be selling the code as a service, say by hosting the service, or offering support - although that isn't always practical.



                                      Shipping the code as .pyc files will prevent your protection being foiled by a few #s, but it's hardly effective anti-piracy protection (as if there is such a technology), and at the end of the day, it shouldn't achieve anything that a decent license agreement with the company will.



                                      Concentrate on making your code as nice to use as possible - having happy customers will make your company far more money than preventing some theoretical piracy..






                                      share|improve this answer























                                        up vote
                                        9
                                        down vote










                                        up vote
                                        9
                                        down vote









                                        Depending in who the client is, a simple protection mechanism, combined with a sensible license agreement will be far more effective than any complex licensing/encryption/obfuscation system.



                                        The best solution would be selling the code as a service, say by hosting the service, or offering support - although that isn't always practical.



                                        Shipping the code as .pyc files will prevent your protection being foiled by a few #s, but it's hardly effective anti-piracy protection (as if there is such a technology), and at the end of the day, it shouldn't achieve anything that a decent license agreement with the company will.



                                        Concentrate on making your code as nice to use as possible - having happy customers will make your company far more money than preventing some theoretical piracy..






                                        share|improve this answer












                                        Depending in who the client is, a simple protection mechanism, combined with a sensible license agreement will be far more effective than any complex licensing/encryption/obfuscation system.



                                        The best solution would be selling the code as a service, say by hosting the service, or offering support - although that isn't always practical.



                                        Shipping the code as .pyc files will prevent your protection being foiled by a few #s, but it's hardly effective anti-piracy protection (as if there is such a technology), and at the end of the day, it shouldn't achieve anything that a decent license agreement with the company will.



                                        Concentrate on making your code as nice to use as possible - having happy customers will make your company far more money than preventing some theoretical piracy..







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Nov 4 '08 at 12:53









                                        dbr

                                        117k56251313




                                        117k56251313






















                                            up vote
                                            9
                                            down vote













                                            The reliable only way to protect code is to run it on a server you control and provide your clients with a client which interfaces with that server.






                                            share|improve this answer

























                                              up vote
                                              9
                                              down vote













                                              The reliable only way to protect code is to run it on a server you control and provide your clients with a client which interfaces with that server.






                                              share|improve this answer























                                                up vote
                                                9
                                                down vote










                                                up vote
                                                9
                                                down vote









                                                The reliable only way to protect code is to run it on a server you control and provide your clients with a client which interfaces with that server.






                                                share|improve this answer












                                                The reliable only way to protect code is to run it on a server you control and provide your clients with a client which interfaces with that server.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Nov 4 '08 at 20:27









                                                Alex Coventry

                                                41.9k42632




                                                41.9k42632






















                                                    up vote
                                                    9
                                                    down vote













                                                    I think there is one more method to protect your Python code; part of the Obfuscation method. I beleive there was a game like Mount and Blade or something that changed and recompiled their own python interpreter (the original interpreter which i believe is open source) and just changed the OP codes in the OP code table to be different then the standard python OP codes.



                                                    So the python source is unmodified but the file extentions of the pyc files are different and the op codes don't match to the public python.exe interpreter. If you checked the games data files all the data was in Python source format.



                                                    All sorts of nasty tricks can be done to mess with amature hackers this way. Stopping a bunch of noob hackers is easy. It's the pro hackers that you will not likely beat. But most companies don't keep pro hackers on staff long I imagine (likely because things get hacked). But amature hackers are all over the place (read as curious IT staff).



                                                    You could for example, in a modified interpreter, allow it to check for certain comments or docstrings in your source. You could have special OP codes for such lines of code. For example:



                                                    OP 234 is for source line "# Copyright I wrote this"
                                                    or compile that line into op codes that are equivelent to "if False:" if "# Copyright" is missing. Basically disabling a whole block of code for what appears to be some obsure reason.



                                                    One use case where recompiling a modified interpreter may be feasable is where you didn't write the app, the app is big, but you are paid to protect it, such as when you're a dedicated server admin for a financial app.



                                                    I find it a little contradictory to leave the source or opcodes open for eyeballs, but use SSL for network traffic. SSL is not 100% safe either. But it's used to stop MOST eyes from reading it. A wee bit precaution is sensible.



                                                    Also, if enough people deem that Python source and opcodes are too visible, it's likely someone will eventually develope at least a simple protection tool for it. So the more people asking "how to protect Python app" only promotes that development.






                                                    share|improve this answer

























                                                      up vote
                                                      9
                                                      down vote













                                                      I think there is one more method to protect your Python code; part of the Obfuscation method. I beleive there was a game like Mount and Blade or something that changed and recompiled their own python interpreter (the original interpreter which i believe is open source) and just changed the OP codes in the OP code table to be different then the standard python OP codes.



                                                      So the python source is unmodified but the file extentions of the pyc files are different and the op codes don't match to the public python.exe interpreter. If you checked the games data files all the data was in Python source format.



                                                      All sorts of nasty tricks can be done to mess with amature hackers this way. Stopping a bunch of noob hackers is easy. It's the pro hackers that you will not likely beat. But most companies don't keep pro hackers on staff long I imagine (likely because things get hacked). But amature hackers are all over the place (read as curious IT staff).



                                                      You could for example, in a modified interpreter, allow it to check for certain comments or docstrings in your source. You could have special OP codes for such lines of code. For example:



                                                      OP 234 is for source line "# Copyright I wrote this"
                                                      or compile that line into op codes that are equivelent to "if False:" if "# Copyright" is missing. Basically disabling a whole block of code for what appears to be some obsure reason.



                                                      One use case where recompiling a modified interpreter may be feasable is where you didn't write the app, the app is big, but you are paid to protect it, such as when you're a dedicated server admin for a financial app.



                                                      I find it a little contradictory to leave the source or opcodes open for eyeballs, but use SSL for network traffic. SSL is not 100% safe either. But it's used to stop MOST eyes from reading it. A wee bit precaution is sensible.



                                                      Also, if enough people deem that Python source and opcodes are too visible, it's likely someone will eventually develope at least a simple protection tool for it. So the more people asking "how to protect Python app" only promotes that development.






                                                      share|improve this answer























                                                        up vote
                                                        9
                                                        down vote










                                                        up vote
                                                        9
                                                        down vote









                                                        I think there is one more method to protect your Python code; part of the Obfuscation method. I beleive there was a game like Mount and Blade or something that changed and recompiled their own python interpreter (the original interpreter which i believe is open source) and just changed the OP codes in the OP code table to be different then the standard python OP codes.



                                                        So the python source is unmodified but the file extentions of the pyc files are different and the op codes don't match to the public python.exe interpreter. If you checked the games data files all the data was in Python source format.



                                                        All sorts of nasty tricks can be done to mess with amature hackers this way. Stopping a bunch of noob hackers is easy. It's the pro hackers that you will not likely beat. But most companies don't keep pro hackers on staff long I imagine (likely because things get hacked). But amature hackers are all over the place (read as curious IT staff).



                                                        You could for example, in a modified interpreter, allow it to check for certain comments or docstrings in your source. You could have special OP codes for such lines of code. For example:



                                                        OP 234 is for source line "# Copyright I wrote this"
                                                        or compile that line into op codes that are equivelent to "if False:" if "# Copyright" is missing. Basically disabling a whole block of code for what appears to be some obsure reason.



                                                        One use case where recompiling a modified interpreter may be feasable is where you didn't write the app, the app is big, but you are paid to protect it, such as when you're a dedicated server admin for a financial app.



                                                        I find it a little contradictory to leave the source or opcodes open for eyeballs, but use SSL for network traffic. SSL is not 100% safe either. But it's used to stop MOST eyes from reading it. A wee bit precaution is sensible.



                                                        Also, if enough people deem that Python source and opcodes are too visible, it's likely someone will eventually develope at least a simple protection tool for it. So the more people asking "how to protect Python app" only promotes that development.






                                                        share|improve this answer












                                                        I think there is one more method to protect your Python code; part of the Obfuscation method. I beleive there was a game like Mount and Blade or something that changed and recompiled their own python interpreter (the original interpreter which i believe is open source) and just changed the OP codes in the OP code table to be different then the standard python OP codes.



                                                        So the python source is unmodified but the file extentions of the pyc files are different and the op codes don't match to the public python.exe interpreter. If you checked the games data files all the data was in Python source format.



                                                        All sorts of nasty tricks can be done to mess with amature hackers this way. Stopping a bunch of noob hackers is easy. It's the pro hackers that you will not likely beat. But most companies don't keep pro hackers on staff long I imagine (likely because things get hacked). But amature hackers are all over the place (read as curious IT staff).



                                                        You could for example, in a modified interpreter, allow it to check for certain comments or docstrings in your source. You could have special OP codes for such lines of code. For example:



                                                        OP 234 is for source line "# Copyright I wrote this"
                                                        or compile that line into op codes that are equivelent to "if False:" if "# Copyright" is missing. Basically disabling a whole block of code for what appears to be some obsure reason.



                                                        One use case where recompiling a modified interpreter may be feasable is where you didn't write the app, the app is big, but you are paid to protect it, such as when you're a dedicated server admin for a financial app.



                                                        I find it a little contradictory to leave the source or opcodes open for eyeballs, but use SSL for network traffic. SSL is not 100% safe either. But it's used to stop MOST eyes from reading it. A wee bit precaution is sensible.



                                                        Also, if enough people deem that Python source and opcodes are too visible, it's likely someone will eventually develope at least a simple protection tool for it. So the more people asking "how to protect Python app" only promotes that development.







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Jul 3 '12 at 17:07









                                                        DevPlayer

                                                        3,42011817




                                                        3,42011817






















                                                            up vote
                                                            8
                                                            down vote













                                                            Another attempt to make your code harder to steal is to use jython and then use java obfuscator.



                                                            This should work pretty well as jythonc translate python code to java and then java is compiled to bytecode. So ounce you obfuscate the classes it will be really hard to understand what is going on after decompilation, not to mention recovering the actual code.



                                                            The only problem with jython is that you can't use python modules written in c.






                                                            share|improve this answer

























                                                              up vote
                                                              8
                                                              down vote













                                                              Another attempt to make your code harder to steal is to use jython and then use java obfuscator.



                                                              This should work pretty well as jythonc translate python code to java and then java is compiled to bytecode. So ounce you obfuscate the classes it will be really hard to understand what is going on after decompilation, not to mention recovering the actual code.



                                                              The only problem with jython is that you can't use python modules written in c.






                                                              share|improve this answer























                                                                up vote
                                                                8
                                                                down vote










                                                                up vote
                                                                8
                                                                down vote









                                                                Another attempt to make your code harder to steal is to use jython and then use java obfuscator.



                                                                This should work pretty well as jythonc translate python code to java and then java is compiled to bytecode. So ounce you obfuscate the classes it will be really hard to understand what is going on after decompilation, not to mention recovering the actual code.



                                                                The only problem with jython is that you can't use python modules written in c.






                                                                share|improve this answer












                                                                Another attempt to make your code harder to steal is to use jython and then use java obfuscator.



                                                                This should work pretty well as jythonc translate python code to java and then java is compiled to bytecode. So ounce you obfuscate the classes it will be really hard to understand what is going on after decompilation, not to mention recovering the actual code.



                                                                The only problem with jython is that you can't use python modules written in c.







                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered May 5 '09 at 21:53









                                                                Piotr Czapla

                                                                14k1976103




                                                                14k1976103






















                                                                    up vote
                                                                    6
                                                                    down vote













                                                                    What about signing your code with standard encryption schemes by hashing and signing important files and checking it with public key methods?



                                                                    In this way you can issue license file with a public key for each customer.



                                                                    Additional you can use an python obfuscator like this one (just googled it).






                                                                    share|improve this answer





















                                                                    • +1 For the signing; -1 for the obfuscator You can at least prevent the code from being changed.
                                                                      – Ali Afshar
                                                                      Nov 4 '08 at 13:07






                                                                    • 2




                                                                      Signing does not work in this context. It's always possible to bypass the signature-checking loader. The first thing you need for useful software protection is an opaque bootstrap mechanism. Not something that Python makes easy.
                                                                      – ddaa
                                                                      Nov 4 '08 at 13:41










                                                                    • Yes, bootstrap in non-python.
                                                                      – Ali Afshar
                                                                      Nov 4 '08 at 16:27










                                                                    • Or validate the licence not only on startup but in several other places. Can be easily implemented, and can severely increase the time to bypass.
                                                                      – Abgan
                                                                      Dec 29 '08 at 2:21















                                                                    up vote
                                                                    6
                                                                    down vote













                                                                    What about signing your code with standard encryption schemes by hashing and signing important files and checking it with public key methods?



                                                                    In this way you can issue license file with a public key for each customer.



                                                                    Additional you can use an python obfuscator like this one (just googled it).






                                                                    share|improve this answer





















                                                                    • +1 For the signing; -1 for the obfuscator You can at least prevent the code from being changed.
                                                                      – Ali Afshar
                                                                      Nov 4 '08 at 13:07






                                                                    • 2




                                                                      Signing does not work in this context. It's always possible to bypass the signature-checking loader. The first thing you need for useful software protection is an opaque bootstrap mechanism. Not something that Python makes easy.
                                                                      – ddaa
                                                                      Nov 4 '08 at 13:41










                                                                    • Yes, bootstrap in non-python.
                                                                      – Ali Afshar
                                                                      Nov 4 '08 at 16:27










                                                                    • Or validate the licence not only on startup but in several other places. Can be easily implemented, and can severely increase the time to bypass.
                                                                      – Abgan
                                                                      Dec 29 '08 at 2:21













                                                                    up vote
                                                                    6
                                                                    down vote










                                                                    up vote
                                                                    6
                                                                    down vote









                                                                    What about signing your code with standard encryption schemes by hashing and signing important files and checking it with public key methods?



                                                                    In this way you can issue license file with a public key for each customer.



                                                                    Additional you can use an python obfuscator like this one (just googled it).






                                                                    share|improve this answer












                                                                    What about signing your code with standard encryption schemes by hashing and signing important files and checking it with public key methods?



                                                                    In this way you can issue license file with a public key for each customer.



                                                                    Additional you can use an python obfuscator like this one (just googled it).







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Nov 4 '08 at 12:59









                                                                    Peter Parker

                                                                    22.9k53873




                                                                    22.9k53873












                                                                    • +1 For the signing; -1 for the obfuscator You can at least prevent the code from being changed.
                                                                      – Ali Afshar
                                                                      Nov 4 '08 at 13:07






                                                                    • 2




                                                                      Signing does not work in this context. It's always possible to bypass the signature-checking loader. The first thing you need for useful software protection is an opaque bootstrap mechanism. Not something that Python makes easy.
                                                                      – ddaa
                                                                      Nov 4 '08 at 13:41










                                                                    • Yes, bootstrap in non-python.
                                                                      – Ali Afshar
                                                                      Nov 4 '08 at 16:27










                                                                    • Or validate the licence not only on startup but in several other places. Can be easily implemented, and can severely increase the time to bypass.
                                                                      – Abgan
                                                                      Dec 29 '08 at 2:21


















                                                                    • +1 For the signing; -1 for the obfuscator You can at least prevent the code from being changed.
                                                                      – Ali Afshar
                                                                      Nov 4 '08 at 13:07






                                                                    • 2




                                                                      Signing does not work in this context. It's always possible to bypass the signature-checking loader. The first thing you need for useful software protection is an opaque bootstrap mechanism. Not something that Python makes easy.
                                                                      – ddaa
                                                                      Nov 4 '08 at 13:41










                                                                    • Yes, bootstrap in non-python.
                                                                      – Ali Afshar
                                                                      Nov 4 '08 at 16:27










                                                                    • Or validate the licence not only on startup but in several other places. Can be easily implemented, and can severely increase the time to bypass.
                                                                      – Abgan
                                                                      Dec 29 '08 at 2:21
















                                                                    +1 For the signing; -1 for the obfuscator You can at least prevent the code from being changed.
                                                                    – Ali Afshar
                                                                    Nov 4 '08 at 13:07




                                                                    +1 For the signing; -1 for the obfuscator You can at least prevent the code from being changed.
                                                                    – Ali Afshar
                                                                    Nov 4 '08 at 13:07




                                                                    2




                                                                    2




                                                                    Signing does not work in this context. It's always possible to bypass the signature-checking loader. The first thing you need for useful software protection is an opaque bootstrap mechanism. Not something that Python makes easy.
                                                                    – ddaa
                                                                    Nov 4 '08 at 13:41




                                                                    Signing does not work in this context. It's always possible to bypass the signature-checking loader. The first thing you need for useful software protection is an opaque bootstrap mechanism. Not something that Python makes easy.
                                                                    – ddaa
                                                                    Nov 4 '08 at 13:41












                                                                    Yes, bootstrap in non-python.
                                                                    – Ali Afshar
                                                                    Nov 4 '08 at 16:27




                                                                    Yes, bootstrap in non-python.
                                                                    – Ali Afshar
                                                                    Nov 4 '08 at 16:27












                                                                    Or validate the licence not only on startup but in several other places. Can be easily implemented, and can severely increase the time to bypass.
                                                                    – Abgan
                                                                    Dec 29 '08 at 2:21




                                                                    Or validate the licence not only on startup but in several other places. Can be easily implemented, and can severely increase the time to bypass.
                                                                    – Abgan
                                                                    Dec 29 '08 at 2:21










                                                                    up vote
                                                                    6
                                                                    down vote













                                                                    You should take a look at how the guys at getdropbox.com do it for their client software, including Linux. It's quite tricky to crack and requires some quite creative disassembly to get past the protection mechanisms.






                                                                    share|improve this answer

















                                                                    • 8




                                                                      but the fact that it was gotten past meant that they failed - the bottom line is just don't try, but go for legal protection.
                                                                      – Chii
                                                                      Nov 17 '08 at 9:52










                                                                    • Is there any information published on how to get pass this protection mechanisms?
                                                                      – Mitar
                                                                      Nov 20 '12 at 2:33















                                                                    up vote
                                                                    6
                                                                    down vote













                                                                    You should take a look at how the guys at getdropbox.com do it for their client software, including Linux. It's quite tricky to crack and requires some quite creative disassembly to get past the protection mechanisms.






                                                                    share|improve this answer

















                                                                    • 8




                                                                      but the fact that it was gotten past meant that they failed - the bottom line is just don't try, but go for legal protection.
                                                                      – Chii
                                                                      Nov 17 '08 at 9:52










                                                                    • Is there any information published on how to get pass this protection mechanisms?
                                                                      – Mitar
                                                                      Nov 20 '12 at 2:33













                                                                    up vote
                                                                    6
                                                                    down vote










                                                                    up vote
                                                                    6
                                                                    down vote









                                                                    You should take a look at how the guys at getdropbox.com do it for their client software, including Linux. It's quite tricky to crack and requires some quite creative disassembly to get past the protection mechanisms.






                                                                    share|improve this answer












                                                                    You should take a look at how the guys at getdropbox.com do it for their client software, including Linux. It's quite tricky to crack and requires some quite creative disassembly to get past the protection mechanisms.







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Nov 4 '08 at 12:20









                                                                    fwzgekg

                                                                    27114




                                                                    27114








                                                                    • 8




                                                                      but the fact that it was gotten past meant that they failed - the bottom line is just don't try, but go for legal protection.
                                                                      – Chii
                                                                      Nov 17 '08 at 9:52










                                                                    • Is there any information published on how to get pass this protection mechanisms?
                                                                      – Mitar
                                                                      Nov 20 '12 at 2:33














                                                                    • 8




                                                                      but the fact that it was gotten past meant that they failed - the bottom line is just don't try, but go for legal protection.
                                                                      – Chii
                                                                      Nov 17 '08 at 9:52










                                                                    • Is there any information published on how to get pass this protection mechanisms?
                                                                      – Mitar
                                                                      Nov 20 '12 at 2:33








                                                                    8




                                                                    8




                                                                    but the fact that it was gotten past meant that they failed - the bottom line is just don't try, but go for legal protection.
                                                                    – Chii
                                                                    Nov 17 '08 at 9:52




                                                                    but the fact that it was gotten past meant that they failed - the bottom line is just don't try, but go for legal protection.
                                                                    – Chii
                                                                    Nov 17 '08 at 9:52












                                                                    Is there any information published on how to get pass this protection mechanisms?
                                                                    – Mitar
                                                                    Nov 20 '12 at 2:33




                                                                    Is there any information published on how to get pass this protection mechanisms?
                                                                    – Mitar
                                                                    Nov 20 '12 at 2:33










                                                                    up vote
                                                                    5
                                                                    down vote













                                                                    The best you can do with Python is to obscure things.




                                                                    • Strip out all docstrings

                                                                    • Distribute only the .pyc compiled files.

                                                                    • freeze it

                                                                    • Obscure your constants inside a class/module so that help(config) doesn't show everything


                                                                    You may be able to add some additional obscurity by encrypting part of it and decrypting it on the fly and passing it to eval(). But no matter what you do someone can break it.



                                                                    None of this will stop a determined attacker from disassembling the bytecode or digging through your api with help, dir, etc.






                                                                    share|improve this answer

























                                                                      up vote
                                                                      5
                                                                      down vote













                                                                      The best you can do with Python is to obscure things.




                                                                      • Strip out all docstrings

                                                                      • Distribute only the .pyc compiled files.

                                                                      • freeze it

                                                                      • Obscure your constants inside a class/module so that help(config) doesn't show everything


                                                                      You may be able to add some additional obscurity by encrypting part of it and decrypting it on the fly and passing it to eval(). But no matter what you do someone can break it.



                                                                      None of this will stop a determined attacker from disassembling the bytecode or digging through your api with help, dir, etc.






                                                                      share|improve this answer























                                                                        up vote
                                                                        5
                                                                        down vote










                                                                        up vote
                                                                        5
                                                                        down vote









                                                                        The best you can do with Python is to obscure things.




                                                                        • Strip out all docstrings

                                                                        • Distribute only the .pyc compiled files.

                                                                        • freeze it

                                                                        • Obscure your constants inside a class/module so that help(config) doesn't show everything


                                                                        You may be able to add some additional obscurity by encrypting part of it and decrypting it on the fly and passing it to eval(). But no matter what you do someone can break it.



                                                                        None of this will stop a determined attacker from disassembling the bytecode or digging through your api with help, dir, etc.






                                                                        share|improve this answer












                                                                        The best you can do with Python is to obscure things.




                                                                        • Strip out all docstrings

                                                                        • Distribute only the .pyc compiled files.

                                                                        • freeze it

                                                                        • Obscure your constants inside a class/module so that help(config) doesn't show everything


                                                                        You may be able to add some additional obscurity by encrypting part of it and decrypting it on the fly and passing it to eval(). But no matter what you do someone can break it.



                                                                        None of this will stop a determined attacker from disassembling the bytecode or digging through your api with help, dir, etc.







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered Nov 4 '08 at 18:45









                                                                        Brian C. Lane

                                                                        3,38211822




                                                                        3,38211822






















                                                                            up vote
                                                                            5
                                                                            down vote













                                                                            Idea of having time restricted license and check for it in locally installed program will not work. Even with perfect obfuscation, license check can be removed. However if you check license on remote system and run significant part of the program on your closed remote system, you will be able to protect your IP.



                                                                            Preventing competitors from using the source code as their own or write their inspired version of the same code, one way to protect is to add signatures to your program logic (some secrets to be able to prove that code was stolen from you) and obfuscate the python source code so, it's hard to read and utilize.



                                                                            Good obfuscation adds basically the same protection to your code, that compiling it to executable (and stripping binary) does. Figuring out how obfuscated complex code works might be even harder than actually writing your own implementation.



                                                                            This will not help preventing hacking of your program. Even with obfuscation code license stuff will be cracked and program may be modified to have slightly different behaviour (in the same way that compiling code to binary does not help protection of native programs).



                                                                            In addition to symbol obfuscation might be good idea to unrefactor the code, which makes everything even more confusing if e.g. call graphs points to many different places even if actually those different places does eventually the same thing.



                                                                            Logical signature inside obfuscated code (e.g. you may create table of values which are used by program logic, but also used as signature), which can be used to determine that code is originated from you. If someone decides to use your obfuscated code module as part of their own product (even after reobfuscating it to make it seem different) you can show, that code is stolen with your secret signature.






                                                                            share|improve this answer



























                                                                              up vote
                                                                              5
                                                                              down vote













                                                                              Idea of having time restricted license and check for it in locally installed program will not work. Even with perfect obfuscation, license check can be removed. However if you check license on remote system and run significant part of the program on your closed remote system, you will be able to protect your IP.



                                                                              Preventing competitors from using the source code as their own or write their inspired version of the same code, one way to protect is to add signatures to your program logic (some secrets to be able to prove that code was stolen from you) and obfuscate the python source code so, it's hard to read and utilize.



                                                                              Good obfuscation adds basically the same protection to your code, that compiling it to executable (and stripping binary) does. Figuring out how obfuscated complex code works might be even harder than actually writing your own implementation.



                                                                              This will not help preventing hacking of your program. Even with obfuscation code license stuff will be cracked and program may be modified to have slightly different behaviour (in the same way that compiling code to binary does not help protection of native programs).



                                                                              In addition to symbol obfuscation might be good idea to unrefactor the code, which makes everything even more confusing if e.g. call graphs points to many different places even if actually those different places does eventually the same thing.



                                                                              Logical signature inside obfuscated code (e.g. you may create table of values which are used by program logic, but also used as signature), which can be used to determine that code is originated from you. If someone decides to use your obfuscated code module as part of their own product (even after reobfuscating it to make it seem different) you can show, that code is stolen with your secret signature.






                                                                              share|improve this answer

























                                                                                up vote
                                                                                5
                                                                                down vote










                                                                                up vote
                                                                                5
                                                                                down vote









                                                                                Idea of having time restricted license and check for it in locally installed program will not work. Even with perfect obfuscation, license check can be removed. However if you check license on remote system and run significant part of the program on your closed remote system, you will be able to protect your IP.



                                                                                Preventing competitors from using the source code as their own or write their inspired version of the same code, one way to protect is to add signatures to your program logic (some secrets to be able to prove that code was stolen from you) and obfuscate the python source code so, it's hard to read and utilize.



                                                                                Good obfuscation adds basically the same protection to your code, that compiling it to executable (and stripping binary) does. Figuring out how obfuscated complex code works might be even harder than actually writing your own implementation.



                                                                                This will not help preventing hacking of your program. Even with obfuscation code license stuff will be cracked and program may be modified to have slightly different behaviour (in the same way that compiling code to binary does not help protection of native programs).



                                                                                In addition to symbol obfuscation might be good idea to unrefactor the code, which makes everything even more confusing if e.g. call graphs points to many different places even if actually those different places does eventually the same thing.



                                                                                Logical signature inside obfuscated code (e.g. you may create table of values which are used by program logic, but also used as signature), which can be used to determine that code is originated from you. If someone decides to use your obfuscated code module as part of their own product (even after reobfuscating it to make it seem different) you can show, that code is stolen with your secret signature.






                                                                                share|improve this answer














                                                                                Idea of having time restricted license and check for it in locally installed program will not work. Even with perfect obfuscation, license check can be removed. However if you check license on remote system and run significant part of the program on your closed remote system, you will be able to protect your IP.



                                                                                Preventing competitors from using the source code as their own or write their inspired version of the same code, one way to protect is to add signatures to your program logic (some secrets to be able to prove that code was stolen from you) and obfuscate the python source code so, it's hard to read and utilize.



                                                                                Good obfuscation adds basically the same protection to your code, that compiling it to executable (and stripping binary) does. Figuring out how obfuscated complex code works might be even harder than actually writing your own implementation.



                                                                                This will not help preventing hacking of your program. Even with obfuscation code license stuff will be cracked and program may be modified to have slightly different behaviour (in the same way that compiling code to binary does not help protection of native programs).



                                                                                In addition to symbol obfuscation might be good idea to unrefactor the code, which makes everything even more confusing if e.g. call graphs points to many different places even if actually those different places does eventually the same thing.



                                                                                Logical signature inside obfuscated code (e.g. you may create table of values which are used by program logic, but also used as signature), which can be used to determine that code is originated from you. If someone decides to use your obfuscated code module as part of their own product (even after reobfuscating it to make it seem different) you can show, that code is stolen with your secret signature.







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited Sep 20 '16 at 12:03

























                                                                                answered Jun 7 '10 at 5:07









                                                                                Mikael Lepistö

                                                                                6,34512627




                                                                                6,34512627






















                                                                                    up vote
                                                                                    5
                                                                                    down vote













                                                                                    Use Cython. It will compile your modules to high-performant C files, which can then be compiled to native binary libraries. This is basically un-reversable, comparing to .pyc bytecode!



                                                                                    I've written a detailed article on how to set up Cython for a Python project, check it out:



                                                                                    Protecting Python Sources With Cython






                                                                                    share|improve this answer



























                                                                                      up vote
                                                                                      5
                                                                                      down vote













                                                                                      Use Cython. It will compile your modules to high-performant C files, which can then be compiled to native binary libraries. This is basically un-reversable, comparing to .pyc bytecode!



                                                                                      I've written a detailed article on how to set up Cython for a Python project, check it out:



                                                                                      Protecting Python Sources With Cython






                                                                                      share|improve this answer

























                                                                                        up vote
                                                                                        5
                                                                                        down vote










                                                                                        up vote
                                                                                        5
                                                                                        down vote









                                                                                        Use Cython. It will compile your modules to high-performant C files, which can then be compiled to native binary libraries. This is basically un-reversable, comparing to .pyc bytecode!



                                                                                        I've written a detailed article on how to set up Cython for a Python project, check it out:



                                                                                        Protecting Python Sources With Cython






                                                                                        share|improve this answer














                                                                                        Use Cython. It will compile your modules to high-performant C files, which can then be compiled to native binary libraries. This is basically un-reversable, comparing to .pyc bytecode!



                                                                                        I've written a detailed article on how to set up Cython for a Python project, check it out:



                                                                                        Protecting Python Sources With Cython







                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited Sep 1 '17 at 14:26

























                                                                                        answered Sep 1 '17 at 6:01









                                                                                        Milford Cubicle

                                                                                        41156




                                                                                        41156






















                                                                                            up vote
                                                                                            4
                                                                                            down vote













                                                                                            I have looked at software protection in general for my own projects and the general philosophy is that complete protection is impossible. The only thing that you can hope to achieve is to add protection to a level that would cost your customer more to bypass than it would to purchase another license.



                                                                                            With that said I was just checking google for python obsfucation and not turning up a lot of anything. In a .Net solution, obsfucation would be a first approach to your problem on a windows platform, but I am not sure if anyone has solutions on Linux that work with Mono.



                                                                                            The next thing would be to write your code in a compiled language, or if you really want to go all the way, then in assembler. A stripped out executable would be a lot harder to decompile than an interpreted language.



                                                                                            It all comes down to tradeoffs. On one end you have ease of software development in python, in which it is also very hard to hide secrets. On the other end you have software written in assembler which is much harder to write, but is much easier to hide secrets.



                                                                                            Your boss has to choose a point somewhere along that continuum that supports his requirements. And then he has to give you the tools and time so you can build what he wants. However my bet is that he will object to real development costs versus potential monetary losses.






                                                                                            share|improve this answer

























                                                                                              up vote
                                                                                              4
                                                                                              down vote













                                                                                              I have looked at software protection in general for my own projects and the general philosophy is that complete protection is impossible. The only thing that you can hope to achieve is to add protection to a level that would cost your customer more to bypass than it would to purchase another license.



                                                                                              With that said I was just checking google for python obsfucation and not turning up a lot of anything. In a .Net solution, obsfucation would be a first approach to your problem on a windows platform, but I am not sure if anyone has solutions on Linux that work with Mono.



                                                                                              The next thing would be to write your code in a compiled language, or if you really want to go all the way, then in assembler. A stripped out executable would be a lot harder to decompile than an interpreted language.



                                                                                              It all comes down to tradeoffs. On one end you have ease of software development in python, in which it is also very hard to hide secrets. On the other end you have software written in assembler which is much harder to write, but is much easier to hide secrets.



                                                                                              Your boss has to choose a point somewhere along that continuum that supports his requirements. And then he has to give you the tools and time so you can build what he wants. However my bet is that he will object to real development costs versus potential monetary losses.






                                                                                              share|improve this answer























                                                                                                up vote
                                                                                                4
                                                                                                down vote










                                                                                                up vote
                                                                                                4
                                                                                                down vote









                                                                                                I have looked at software protection in general for my own projects and the general philosophy is that complete protection is impossible. The only thing that you can hope to achieve is to add protection to a level that would cost your customer more to bypass than it would to purchase another license.



                                                                                                With that said I was just checking google for python obsfucation and not turning up a lot of anything. In a .Net solution, obsfucation would be a first approach to your problem on a windows platform, but I am not sure if anyone has solutions on Linux that work with Mono.



                                                                                                The next thing would be to write your code in a compiled language, or if you really want to go all the way, then in assembler. A stripped out executable would be a lot harder to decompile than an interpreted language.



                                                                                                It all comes down to tradeoffs. On one end you have ease of software development in python, in which it is also very hard to hide secrets. On the other end you have software written in assembler which is much harder to write, but is much easier to hide secrets.



                                                                                                Your boss has to choose a point somewhere along that continuum that supports his requirements. And then he has to give you the tools and time so you can build what he wants. However my bet is that he will object to real development costs versus potential monetary losses.






                                                                                                share|improve this answer












                                                                                                I have looked at software protection in general for my own projects and the general philosophy is that complete protection is impossible. The only thing that you can hope to achieve is to add protection to a level that would cost your customer more to bypass than it would to purchase another license.



                                                                                                With that said I was just checking google for python obsfucation and not turning up a lot of anything. In a .Net solution, obsfucation would be a first approach to your problem on a windows platform, but I am not sure if anyone has solutions on Linux that work with Mono.



                                                                                                The next thing would be to write your code in a compiled language, or if you really want to go all the way, then in assembler. A stripped out executable would be a lot harder to decompile than an interpreted language.



                                                                                                It all comes down to tradeoffs. On one end you have ease of software development in python, in which it is also very hard to hide secrets. On the other end you have software written in assembler which is much harder to write, but is much easier to hide secrets.



                                                                                                Your boss has to choose a point somewhere along that continuum that supports his requirements. And then he has to give you the tools and time so you can build what he wants. However my bet is that he will object to real development costs versus potential monetary losses.







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered Nov 4 '08 at 12:28









                                                                                                Peter M

                                                                                                5,51323680




                                                                                                5,51323680






















                                                                                                    up vote
                                                                                                    4
                                                                                                    down vote













                                                                                                    I was surprised in not seeing pyconcrete in any answer. Maybe because it's newer than the question?



                                                                                                    It could be exactly what you need(ed).



                                                                                                    Instead of obfuscating the code, it encrypts it and decrypts at load time.



                                                                                                    From pypi page:




                                                                                                    Protect python script work flow




                                                                                                    • your_script.py import pyconcrete

                                                                                                    • pyconcrete will hook import module

                                                                                                    • when your script do import MODULE,
                                                                                                      pyconcrete import hook will try to find MODULE.pye first and then
                                                                                                      decrypt MODULE.pye via _pyconcrete.pyd and execute decrypted data (as
                                                                                                      .pyc content)

                                                                                                    • encrypt & decrypt secret key record in _pyconcrete.pyd
                                                                                                      (like DLL or SO) the secret key would be hide in binary code, can’t
                                                                                                      see it directly in HEX view







                                                                                                    share|improve this answer

























                                                                                                      up vote
                                                                                                      4
                                                                                                      down vote













                                                                                                      I was surprised in not seeing pyconcrete in any answer. Maybe because it's newer than the question?



                                                                                                      It could be exactly what you need(ed).



                                                                                                      Instead of obfuscating the code, it encrypts it and decrypts at load time.



                                                                                                      From pypi page:




                                                                                                      Protect python script work flow




                                                                                                      • your_script.py import pyconcrete

                                                                                                      • pyconcrete will hook import module

                                                                                                      • when your script do import MODULE,
                                                                                                        pyconcrete import hook will try to find MODULE.pye first and then
                                                                                                        decrypt MODULE.pye via _pyconcrete.pyd and execute decrypted data (as
                                                                                                        .pyc content)

                                                                                                      • encrypt & decrypt secret key record in _pyconcrete.pyd
                                                                                                        (like DLL or SO) the secret key would be hide in binary code, can’t
                                                                                                        see it directly in HEX view







                                                                                                      share|improve this answer























                                                                                                        up vote
                                                                                                        4
                                                                                                        down vote










                                                                                                        up vote
                                                                                                        4
                                                                                                        down vote









                                                                                                        I was surprised in not seeing pyconcrete in any answer. Maybe because it's newer than the question?



                                                                                                        It could be exactly what you need(ed).



                                                                                                        Instead of obfuscating the code, it encrypts it and decrypts at load time.



                                                                                                        From pypi page:




                                                                                                        Protect python script work flow




                                                                                                        • your_script.py import pyconcrete

                                                                                                        • pyconcrete will hook import module

                                                                                                        • when your script do import MODULE,
                                                                                                          pyconcrete import hook will try to find MODULE.pye first and then
                                                                                                          decrypt MODULE.pye via _pyconcrete.pyd and execute decrypted data (as
                                                                                                          .pyc content)

                                                                                                        • encrypt & decrypt secret key record in _pyconcrete.pyd
                                                                                                          (like DLL or SO) the secret key would be hide in binary code, can’t
                                                                                                          see it directly in HEX view







                                                                                                        share|improve this answer












                                                                                                        I was surprised in not seeing pyconcrete in any answer. Maybe because it's newer than the question?



                                                                                                        It could be exactly what you need(ed).



                                                                                                        Instead of obfuscating the code, it encrypts it and decrypts at load time.



                                                                                                        From pypi page:




                                                                                                        Protect python script work flow




                                                                                                        • your_script.py import pyconcrete

                                                                                                        • pyconcrete will hook import module

                                                                                                        • when your script do import MODULE,
                                                                                                          pyconcrete import hook will try to find MODULE.pye first and then
                                                                                                          decrypt MODULE.pye via _pyconcrete.pyd and execute decrypted data (as
                                                                                                          .pyc content)

                                                                                                        • encrypt & decrypt secret key record in _pyconcrete.pyd
                                                                                                          (like DLL or SO) the secret key would be hide in binary code, can’t
                                                                                                          see it directly in HEX view








                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered Mar 17 at 0:43









                                                                                                        mvallebr

                                                                                                        974929




                                                                                                        974929






















                                                                                                            up vote
                                                                                                            3
                                                                                                            down vote













                                                                                                            It is possible to have the py2exe byte-code in a crypted resource for a C launcher that loads and executes it in memory. Some ideas here and here.



                                                                                                            Some have also thought of a self modifying program to make reverse engineering expensive.



                                                                                                            You can also find tutorials for preventing debuggers, make the disassembler fail, set false debugger breakpoints and protect your code with checksums. Search for ["crypted code" execute "in memory"] for more links.



                                                                                                            But as others already said, if your code is worth it, reverse engineers will succeed in the end.






                                                                                                            share|improve this answer



























                                                                                                              up vote
                                                                                                              3
                                                                                                              down vote













                                                                                                              It is possible to have the py2exe byte-code in a crypted resource for a C launcher that loads and executes it in memory. Some ideas here and here.



                                                                                                              Some have also thought of a self modifying program to make reverse engineering expensive.



                                                                                                              You can also find tutorials for preventing debuggers, make the disassembler fail, set false debugger breakpoints and protect your code with checksums. Search for ["crypted code" execute "in memory"] for more links.



                                                                                                              But as others already said, if your code is worth it, reverse engineers will succeed in the end.






                                                                                                              share|improve this answer

























                                                                                                                up vote
                                                                                                                3
                                                                                                                down vote










                                                                                                                up vote
                                                                                                                3
                                                                                                                down vote









                                                                                                                It is possible to have the py2exe byte-code in a crypted resource for a C launcher that loads and executes it in memory. Some ideas here and here.



                                                                                                                Some have also thought of a self modifying program to make reverse engineering expensive.



                                                                                                                You can also find tutorials for preventing debuggers, make the disassembler fail, set false debugger breakpoints and protect your code with checksums. Search for ["crypted code" execute "in memory"] for more links.



                                                                                                                But as others already said, if your code is worth it, reverse engineers will succeed in the end.






                                                                                                                share|improve this answer














                                                                                                                It is possible to have the py2exe byte-code in a crypted resource for a C launcher that loads and executes it in memory. Some ideas here and here.



                                                                                                                Some have also thought of a self modifying program to make reverse engineering expensive.



                                                                                                                You can also find tutorials for preventing debuggers, make the disassembler fail, set false debugger breakpoints and protect your code with checksums. Search for ["crypted code" execute "in memory"] for more links.



                                                                                                                But as others already said, if your code is worth it, reverse engineers will succeed in the end.







                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited Aug 18 '13 at 8:18









                                                                                                                Smi

                                                                                                                9,95864155




                                                                                                                9,95864155










                                                                                                                answered May 22 '13 at 14:53









                                                                                                                lalebarde

                                                                                                                8471128




                                                                                                                8471128






















                                                                                                                    up vote
                                                                                                                    2
                                                                                                                    down vote













                                                                                                                    Long story short:




                                                                                                                    1. Encrypt your source code

                                                                                                                    2. Write your own python module loader to decrypt your code when importing

                                                                                                                    3. Implement the module loader in C/C++

                                                                                                                    4. You can add more features to the module loader, for example anti-debugger, license control, hardware fingerprint binding, etc.


                                                                                                                    For more detail, look this answer.



                                                                                                                    If you are interested in the topic, this project will help you - pyprotect.






                                                                                                                    share|improve this answer

























                                                                                                                      up vote
                                                                                                                      2
                                                                                                                      down vote













                                                                                                                      Long story short:




                                                                                                                      1. Encrypt your source code

                                                                                                                      2. Write your own python module loader to decrypt your code when importing

                                                                                                                      3. Implement the module loader in C/C++

                                                                                                                      4. You can add more features to the module loader, for example anti-debugger, license control, hardware fingerprint binding, etc.


                                                                                                                      For more detail, look this answer.



                                                                                                                      If you are interested in the topic, this project will help you - pyprotect.






                                                                                                                      share|improve this answer























                                                                                                                        up vote
                                                                                                                        2
                                                                                                                        down vote










                                                                                                                        up vote
                                                                                                                        2
                                                                                                                        down vote









                                                                                                                        Long story short:




                                                                                                                        1. Encrypt your source code

                                                                                                                        2. Write your own python module loader to decrypt your code when importing

                                                                                                                        3. Implement the module loader in C/C++

                                                                                                                        4. You can add more features to the module loader, for example anti-debugger, license control, hardware fingerprint binding, etc.


                                                                                                                        For more detail, look this answer.



                                                                                                                        If you are interested in the topic, this project will help you - pyprotect.






                                                                                                                        share|improve this answer












                                                                                                                        Long story short:




                                                                                                                        1. Encrypt your source code

                                                                                                                        2. Write your own python module loader to decrypt your code when importing

                                                                                                                        3. Implement the module loader in C/C++

                                                                                                                        4. You can add more features to the module loader, for example anti-debugger, license control, hardware fingerprint binding, etc.


                                                                                                                        For more detail, look this answer.



                                                                                                                        If you are interested in the topic, this project will help you - pyprotect.







                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered Jul 30 at 3:03









                                                                                                                        lambda11

                                                                                                                        416




                                                                                                                        416






















                                                                                                                            up vote
                                                                                                                            1
                                                                                                                            down vote













                                                                                                                            using cxfreeze ( py2exe for linux ) will do the job.



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



                                                                                                                            it is available in ubuntu repositories






                                                                                                                            share|improve this answer

















                                                                                                                            • 5




                                                                                                                              I think that simply bundles the .pyc files. Cython, Shed Skin, and PyPy go beyond bytecode.
                                                                                                                              – Cees Timmerman
                                                                                                                              Aug 3 '12 at 11:47















                                                                                                                            up vote
                                                                                                                            1
                                                                                                                            down vote













                                                                                                                            using cxfreeze ( py2exe for linux ) will do the job.



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



                                                                                                                            it is available in ubuntu repositories






                                                                                                                            share|improve this answer

















                                                                                                                            • 5




                                                                                                                              I think that simply bundles the .pyc files. Cython, Shed Skin, and PyPy go beyond bytecode.
                                                                                                                              – Cees Timmerman
                                                                                                                              Aug 3 '12 at 11:47













                                                                                                                            up vote
                                                                                                                            1
                                                                                                                            down vote










                                                                                                                            up vote
                                                                                                                            1
                                                                                                                            down vote









                                                                                                                            using cxfreeze ( py2exe for linux ) will do the job.



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



                                                                                                                            it is available in ubuntu repositories






                                                                                                                            share|improve this answer












                                                                                                                            using cxfreeze ( py2exe for linux ) will do the job.



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



                                                                                                                            it is available in ubuntu repositories







                                                                                                                            share|improve this answer












                                                                                                                            share|improve this answer



                                                                                                                            share|improve this answer










                                                                                                                            answered Mar 3 '12 at 15:13









                                                                                                                            Ali AlNoaimi

                                                                                                                            1,80811428




                                                                                                                            1,80811428








                                                                                                                            • 5




                                                                                                                              I think that simply bundles the .pyc files. Cython, Shed Skin, and PyPy go beyond bytecode.
                                                                                                                              – Cees Timmerman
                                                                                                                              Aug 3 '12 at 11:47














                                                                                                                            • 5




                                                                                                                              I think that simply bundles the .pyc files. Cython, Shed Skin, and PyPy go beyond bytecode.
                                                                                                                              – Cees Timmerman
                                                                                                                              Aug 3 '12 at 11:47








                                                                                                                            5




                                                                                                                            5




                                                                                                                            I think that simply bundles the .pyc files. Cython, Shed Skin, and PyPy go beyond bytecode.
                                                                                                                            – Cees Timmerman
                                                                                                                            Aug 3 '12 at 11:47




                                                                                                                            I think that simply bundles the .pyc files. Cython, Shed Skin, and PyPy go beyond bytecode.
                                                                                                                            – Cees Timmerman
                                                                                                                            Aug 3 '12 at 11:47










                                                                                                                            up vote
                                                                                                                            0
                                                                                                                            down vote













                                                                                                                            Use the same way to protect binary file of c/c++, that is, obfuscate each function body in executable or library binary file, insert an instruction "jump" at the begin of each function entry, jump to special function to restore obfuscated code. Byte-code is binary code of Python script, so




                                                                                                                            • First compile python script to code object

                                                                                                                            • Then iterate each code object, obfuscate co_code of each code object as the following



                                                                                                                            0 JUMP_ABSOLUTE n = 3 + len(bytecode)

                                                                                                                            3
                                                                                                                            ...
                                                                                                                            ... Here it's obfuscated bytecode
                                                                                                                            ...

                                                                                                                            n LOAD_GLOBAL ? (__pyarmor__)
                                                                                                                            n+3 CALL_FUNCTION 0
                                                                                                                            n+6 POP_TOP
                                                                                                                            n+7 JUMP_ABSOLUTE 0



                                                                                                                            • Save obfuscated code object as .pyc or .pyo file


                                                                                                                            Those obfuscated file (.pyc or .pyo) can be used by normal python interpreter, when those code object is called first time




                                                                                                                            • First op is JUMP_ABSOLUTE, it will jump to offset n



                                                                                                                            • At offset n, the instruction is to call a PyCFunction. This function will restore those obfuscated bytecode between offset 3 and n, and put the original byte-code at offset 0. The obfuscated code can be got by the following code




                                                                                                                              char *obfucated_bytecode;
                                                                                                                              Py_ssize_t len;
                                                                                                                              PyFrameObject* frame = PyEval_GetFrame();
                                                                                                                              PyCodeObject *f_code = frame->f_code;
                                                                                                                              PyObject *co_code = f_code->co_code;
                                                                                                                              PyBytes_AsStringAndSize(co_code, &obfucated_bytecode, &len)


                                                                                                                            • After this function returns, the last instruction is to jump to
                                                                                                                              offset 0. The really byte-code now is executed.



                                                                                                                            There is a tool Pyarmor to obfuscate python scripts by this way.






                                                                                                                            share|improve this answer

























                                                                                                                              up vote
                                                                                                                              0
                                                                                                                              down vote













                                                                                                                              Use the same way to protect binary file of c/c++, that is, obfuscate each function body in executable or library binary file, insert an instruction "jump" at the begin of each function entry, jump to special function to restore obfuscated code. Byte-code is binary code of Python script, so




                                                                                                                              • First compile python script to code object

                                                                                                                              • Then iterate each code object, obfuscate co_code of each code object as the following



                                                                                                                              0 JUMP_ABSOLUTE n = 3 + len(bytecode)

                                                                                                                              3
                                                                                                                              ...
                                                                                                                              ... Here it's obfuscated bytecode
                                                                                                                              ...

                                                                                                                              n LOAD_GLOBAL ? (__pyarmor__)
                                                                                                                              n+3 CALL_FUNCTION 0
                                                                                                                              n+6 POP_TOP
                                                                                                                              n+7 JUMP_ABSOLUTE 0



                                                                                                                              • Save obfuscated code object as .pyc or .pyo file


                                                                                                                              Those obfuscated file (.pyc or .pyo) can be used by normal python interpreter, when those code object is called first time




                                                                                                                              • First op is JUMP_ABSOLUTE, it will jump to offset n



                                                                                                                              • At offset n, the instruction is to call a PyCFunction. This function will restore those obfuscated bytecode between offset 3 and n, and put the original byte-code at offset 0. The obfuscated code can be got by the following code




                                                                                                                                char *obfucated_bytecode;
                                                                                                                                Py_ssize_t len;
                                                                                                                                PyFrameObject* frame = PyEval_GetFrame();
                                                                                                                                PyCodeObject *f_code = frame->f_code;
                                                                                                                                PyObject *co_code = f_code->co_code;
                                                                                                                                PyBytes_AsStringAndSize(co_code, &obfucated_bytecode, &len)


                                                                                                                              • After this function returns, the last instruction is to jump to
                                                                                                                                offset 0. The really byte-code now is executed.



                                                                                                                              There is a tool Pyarmor to obfuscate python scripts by this way.






                                                                                                                              share|improve this answer























                                                                                                                                up vote
                                                                                                                                0
                                                                                                                                down vote










                                                                                                                                up vote
                                                                                                                                0
                                                                                                                                down vote









                                                                                                                                Use the same way to protect binary file of c/c++, that is, obfuscate each function body in executable or library binary file, insert an instruction "jump" at the begin of each function entry, jump to special function to restore obfuscated code. Byte-code is binary code of Python script, so




                                                                                                                                • First compile python script to code object

                                                                                                                                • Then iterate each code object, obfuscate co_code of each code object as the following



                                                                                                                                0 JUMP_ABSOLUTE n = 3 + len(bytecode)

                                                                                                                                3
                                                                                                                                ...
                                                                                                                                ... Here it's obfuscated bytecode
                                                                                                                                ...

                                                                                                                                n LOAD_GLOBAL ? (__pyarmor__)
                                                                                                                                n+3 CALL_FUNCTION 0
                                                                                                                                n+6 POP_TOP
                                                                                                                                n+7 JUMP_ABSOLUTE 0



                                                                                                                                • Save obfuscated code object as .pyc or .pyo file


                                                                                                                                Those obfuscated file (.pyc or .pyo) can be used by normal python interpreter, when those code object is called first time




                                                                                                                                • First op is JUMP_ABSOLUTE, it will jump to offset n



                                                                                                                                • At offset n, the instruction is to call a PyCFunction. This function will restore those obfuscated bytecode between offset 3 and n, and put the original byte-code at offset 0. The obfuscated code can be got by the following code




                                                                                                                                  char *obfucated_bytecode;
                                                                                                                                  Py_ssize_t len;
                                                                                                                                  PyFrameObject* frame = PyEval_GetFrame();
                                                                                                                                  PyCodeObject *f_code = frame->f_code;
                                                                                                                                  PyObject *co_code = f_code->co_code;
                                                                                                                                  PyBytes_AsStringAndSize(co_code, &obfucated_bytecode, &len)


                                                                                                                                • After this function returns, the last instruction is to jump to
                                                                                                                                  offset 0. The really byte-code now is executed.



                                                                                                                                There is a tool Pyarmor to obfuscate python scripts by this way.






                                                                                                                                share|improve this answer












                                                                                                                                Use the same way to protect binary file of c/c++, that is, obfuscate each function body in executable or library binary file, insert an instruction "jump" at the begin of each function entry, jump to special function to restore obfuscated code. Byte-code is binary code of Python script, so




                                                                                                                                • First compile python script to code object

                                                                                                                                • Then iterate each code object, obfuscate co_code of each code object as the following



                                                                                                                                0 JUMP_ABSOLUTE n = 3 + len(bytecode)

                                                                                                                                3
                                                                                                                                ...
                                                                                                                                ... Here it's obfuscated bytecode
                                                                                                                                ...

                                                                                                                                n LOAD_GLOBAL ? (__pyarmor__)
                                                                                                                                n+3 CALL_FUNCTION 0
                                                                                                                                n+6 POP_TOP
                                                                                                                                n+7 JUMP_ABSOLUTE 0



                                                                                                                                • Save obfuscated code object as .pyc or .pyo file


                                                                                                                                Those obfuscated file (.pyc or .pyo) can be used by normal python interpreter, when those code object is called first time




                                                                                                                                • First op is JUMP_ABSOLUTE, it will jump to offset n



                                                                                                                                • At offset n, the instruction is to call a PyCFunction. This function will restore those obfuscated bytecode between offset 3 and n, and put the original byte-code at offset 0. The obfuscated code can be got by the following code




                                                                                                                                  char *obfucated_bytecode;
                                                                                                                                  Py_ssize_t len;
                                                                                                                                  PyFrameObject* frame = PyEval_GetFrame();
                                                                                                                                  PyCodeObject *f_code = frame->f_code;
                                                                                                                                  PyObject *co_code = f_code->co_code;
                                                                                                                                  PyBytes_AsStringAndSize(co_code, &obfucated_bytecode, &len)


                                                                                                                                • After this function returns, the last instruction is to jump to
                                                                                                                                  offset 0. The really byte-code now is executed.



                                                                                                                                There is a tool Pyarmor to obfuscate python scripts by this way.







                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered Dec 14 '17 at 0:35









                                                                                                                                Jondy Zhao

                                                                                                                                413




                                                                                                                                413

















                                                                                                                                    protected by Ashwini Chaudhary Mar 27 '14 at 22:40



                                                                                                                                    Thank you for your interest in this question.
                                                                                                                                    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                                                                                                    Would you like to answer one of these unanswered questions instead?



                                                                                                                                    Popular posts from this blog

                                                                                                                                    Lallio

                                                                                                                                    Futebolista

                                                                                                                                    Jornalista