Can I compile (protect) a python script? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite
1












I have a python script. It starts with #!/usr/bin/env python
Is there a way I can compile it, and protect it's contents?
I've used shc for bash scripts, and before anyone chimes in with a moan, I know it's not a secure way to protect the contents of the script.



I was hoping there was a secure way to compile a python script and completely stop anyone from seeing the original code.



If not, then maybe something like shc would do, to stop the ill informed from snooping.



Hope that makes sense.



Preston










share|improve this question













closed as off-topic by Byte Commander, user68186, mikewhatever, karel, muru Jan 28 at 1:05


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Byte Commander, user68186, mikewhatever, karel, muru
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 2




    This doesn't seem to be about Ubuntu, but a general programming question. As such, it is off-topic here and should instead rather be asked on e.g. Stack Overflow. However, I think there is already a post that fully covers your question: stackoverflow.com/q/261638/4464570
    – Byte Commander
    Jan 27 at 21:33










  • :( Sorry, will do that
    – Preston Cole
    Jan 27 at 21:37










  • Keep in mind almost anything compiled and be decompiled. Also when compiled with debug / trace options it is even easier to decipher when decompiled.
    – WinEunuuchs2Unix
    Jan 28 at 0:08














up vote
1
down vote

favorite
1












I have a python script. It starts with #!/usr/bin/env python
Is there a way I can compile it, and protect it's contents?
I've used shc for bash scripts, and before anyone chimes in with a moan, I know it's not a secure way to protect the contents of the script.



I was hoping there was a secure way to compile a python script and completely stop anyone from seeing the original code.



If not, then maybe something like shc would do, to stop the ill informed from snooping.



Hope that makes sense.



Preston










share|improve this question













closed as off-topic by Byte Commander, user68186, mikewhatever, karel, muru Jan 28 at 1:05


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Byte Commander, user68186, mikewhatever, karel, muru
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 2




    This doesn't seem to be about Ubuntu, but a general programming question. As such, it is off-topic here and should instead rather be asked on e.g. Stack Overflow. However, I think there is already a post that fully covers your question: stackoverflow.com/q/261638/4464570
    – Byte Commander
    Jan 27 at 21:33










  • :( Sorry, will do that
    – Preston Cole
    Jan 27 at 21:37










  • Keep in mind almost anything compiled and be decompiled. Also when compiled with debug / trace options it is even easier to decipher when decompiled.
    – WinEunuuchs2Unix
    Jan 28 at 0:08












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I have a python script. It starts with #!/usr/bin/env python
Is there a way I can compile it, and protect it's contents?
I've used shc for bash scripts, and before anyone chimes in with a moan, I know it's not a secure way to protect the contents of the script.



I was hoping there was a secure way to compile a python script and completely stop anyone from seeing the original code.



If not, then maybe something like shc would do, to stop the ill informed from snooping.



Hope that makes sense.



Preston










share|improve this question













I have a python script. It starts with #!/usr/bin/env python
Is there a way I can compile it, and protect it's contents?
I've used shc for bash scripts, and before anyone chimes in with a moan, I know it's not a secure way to protect the contents of the script.



I was hoping there was a secure way to compile a python script and completely stop anyone from seeing the original code.



If not, then maybe something like shc would do, to stop the ill informed from snooping.



Hope that makes sense.



Preston







python compiling






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 27 at 21:29









Preston Cole

352




352




closed as off-topic by Byte Commander, user68186, mikewhatever, karel, muru Jan 28 at 1:05


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Byte Commander, user68186, mikewhatever, karel, muru
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by Byte Commander, user68186, mikewhatever, karel, muru Jan 28 at 1:05


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Byte Commander, user68186, mikewhatever, karel, muru
If this question can be reworded to fit the rules in the help center, please edit the question.







  • 2




    This doesn't seem to be about Ubuntu, but a general programming question. As such, it is off-topic here and should instead rather be asked on e.g. Stack Overflow. However, I think there is already a post that fully covers your question: stackoverflow.com/q/261638/4464570
    – Byte Commander
    Jan 27 at 21:33










  • :( Sorry, will do that
    – Preston Cole
    Jan 27 at 21:37










  • Keep in mind almost anything compiled and be decompiled. Also when compiled with debug / trace options it is even easier to decipher when decompiled.
    – WinEunuuchs2Unix
    Jan 28 at 0:08












  • 2




    This doesn't seem to be about Ubuntu, but a general programming question. As such, it is off-topic here and should instead rather be asked on e.g. Stack Overflow. However, I think there is already a post that fully covers your question: stackoverflow.com/q/261638/4464570
    – Byte Commander
    Jan 27 at 21:33










  • :( Sorry, will do that
    – Preston Cole
    Jan 27 at 21:37










  • Keep in mind almost anything compiled and be decompiled. Also when compiled with debug / trace options it is even easier to decipher when decompiled.
    – WinEunuuchs2Unix
    Jan 28 at 0:08







2




2




This doesn't seem to be about Ubuntu, but a general programming question. As such, it is off-topic here and should instead rather be asked on e.g. Stack Overflow. However, I think there is already a post that fully covers your question: stackoverflow.com/q/261638/4464570
– Byte Commander
Jan 27 at 21:33




This doesn't seem to be about Ubuntu, but a general programming question. As such, it is off-topic here and should instead rather be asked on e.g. Stack Overflow. However, I think there is already a post that fully covers your question: stackoverflow.com/q/261638/4464570
– Byte Commander
Jan 27 at 21:33












:( Sorry, will do that
– Preston Cole
Jan 27 at 21:37




:( Sorry, will do that
– Preston Cole
Jan 27 at 21:37












Keep in mind almost anything compiled and be decompiled. Also when compiled with debug / trace options it is even easier to decipher when decompiled.
– WinEunuuchs2Unix
Jan 28 at 0:08




Keep in mind almost anything compiled and be decompiled. Also when compiled with debug / trace options it is even easier to decipher when decompiled.
– WinEunuuchs2Unix
Jan 28 at 0:08










2 Answers
2






active

oldest

votes

















up vote
0
down vote













I haven't try it myself, but I know there's a thing called cx_Freeze. From its description:




cx_Freeze is a set of scripts and modules for freezing Python scripts into executables




I'm not sure how easy or hard it is to unpack executable and actually see the script source in it, so security of this approach is debatable.






share|improve this answer




















  • Will give it a look, thanks :)
    – Preston Cole
    Jan 27 at 21:37

















up vote
0
down vote













I have used one Python compiler during initramfs to speed up boot time for EnhanceIO SSD to HDD block device cacher. It worked well back in 2016 but I don't know how well it compiles today in current Python language.



The compiler used is called Pyinstaller and it:




is a program that freezes (packages) Python programs into stand-alone
executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX.
Its main advantages over similar tools are that PyInstaller works with
Python 2.7 and 3.3—3.6, it builds smaller executables thanks to
transparent compression, it is fully multi-platform, and use the OS
support to load the dynamic libraries, thus ensuring full
compatibility.







share|improve this answer



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I haven't try it myself, but I know there's a thing called cx_Freeze. From its description:




    cx_Freeze is a set of scripts and modules for freezing Python scripts into executables




    I'm not sure how easy or hard it is to unpack executable and actually see the script source in it, so security of this approach is debatable.






    share|improve this answer




















    • Will give it a look, thanks :)
      – Preston Cole
      Jan 27 at 21:37














    up vote
    0
    down vote













    I haven't try it myself, but I know there's a thing called cx_Freeze. From its description:




    cx_Freeze is a set of scripts and modules for freezing Python scripts into executables




    I'm not sure how easy or hard it is to unpack executable and actually see the script source in it, so security of this approach is debatable.






    share|improve this answer




















    • Will give it a look, thanks :)
      – Preston Cole
      Jan 27 at 21:37












    up vote
    0
    down vote










    up vote
    0
    down vote









    I haven't try it myself, but I know there's a thing called cx_Freeze. From its description:




    cx_Freeze is a set of scripts and modules for freezing Python scripts into executables




    I'm not sure how easy or hard it is to unpack executable and actually see the script source in it, so security of this approach is debatable.






    share|improve this answer












    I haven't try it myself, but I know there's a thing called cx_Freeze. From its description:




    cx_Freeze is a set of scripts and modules for freezing Python scripts into executables




    I'm not sure how easy or hard it is to unpack executable and actually see the script source in it, so security of this approach is debatable.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 27 at 21:35









    gmile

    1115




    1115











    • Will give it a look, thanks :)
      – Preston Cole
      Jan 27 at 21:37
















    • Will give it a look, thanks :)
      – Preston Cole
      Jan 27 at 21:37















    Will give it a look, thanks :)
    – Preston Cole
    Jan 27 at 21:37




    Will give it a look, thanks :)
    – Preston Cole
    Jan 27 at 21:37












    up vote
    0
    down vote













    I have used one Python compiler during initramfs to speed up boot time for EnhanceIO SSD to HDD block device cacher. It worked well back in 2016 but I don't know how well it compiles today in current Python language.



    The compiler used is called Pyinstaller and it:




    is a program that freezes (packages) Python programs into stand-alone
    executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX.
    Its main advantages over similar tools are that PyInstaller works with
    Python 2.7 and 3.3—3.6, it builds smaller executables thanks to
    transparent compression, it is fully multi-platform, and use the OS
    support to load the dynamic libraries, thus ensuring full
    compatibility.







    share|improve this answer
























      up vote
      0
      down vote













      I have used one Python compiler during initramfs to speed up boot time for EnhanceIO SSD to HDD block device cacher. It worked well back in 2016 but I don't know how well it compiles today in current Python language.



      The compiler used is called Pyinstaller and it:




      is a program that freezes (packages) Python programs into stand-alone
      executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX.
      Its main advantages over similar tools are that PyInstaller works with
      Python 2.7 and 3.3—3.6, it builds smaller executables thanks to
      transparent compression, it is fully multi-platform, and use the OS
      support to load the dynamic libraries, thus ensuring full
      compatibility.







      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        I have used one Python compiler during initramfs to speed up boot time for EnhanceIO SSD to HDD block device cacher. It worked well back in 2016 but I don't know how well it compiles today in current Python language.



        The compiler used is called Pyinstaller and it:




        is a program that freezes (packages) Python programs into stand-alone
        executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX.
        Its main advantages over similar tools are that PyInstaller works with
        Python 2.7 and 3.3—3.6, it builds smaller executables thanks to
        transparent compression, it is fully multi-platform, and use the OS
        support to load the dynamic libraries, thus ensuring full
        compatibility.







        share|improve this answer












        I have used one Python compiler during initramfs to speed up boot time for EnhanceIO SSD to HDD block device cacher. It worked well back in 2016 but I don't know how well it compiles today in current Python language.



        The compiler used is called Pyinstaller and it:




        is a program that freezes (packages) Python programs into stand-alone
        executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX.
        Its main advantages over similar tools are that PyInstaller works with
        Python 2.7 and 3.3—3.6, it builds smaller executables thanks to
        transparent compression, it is fully multi-platform, and use the OS
        support to load the dynamic libraries, thus ensuring full
        compatibility.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 27 at 23:57









        WinEunuuchs2Unix

        36.8k760138




        36.8k760138












            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491