By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

hide sourcecode

P: n/a
Hi, is it possible to protect the python sourcecode?
I have a nice little script and i dont want to show everbody the source.

Im using python on a windows pc.

Thank you - Mark
Jul 18 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
You could move the .PY file somewhere where
it cannot be seen and leave the .pyc for execution
or you can "freeze" it with py2exe.

-Larry

"Mark Buch" <ma*******@ewetel.net> wrote in message
news:bv*************@news.t-online.com...
Hi, is it possible to protect the python sourcecode?
I have a nice little script and i dont want to show everbody the source.

Im using python on a windows pc.

Thank you - Mark

Jul 18 '05 #2

P: n/a
> Hi, is it possible to protect the python sourcecode?
I have a nice little script and i dont want to show everbody the source.

Im using python on a windows pc.


Compile the .py file into bytecode (.pyc). That .pyc file will only be
usable on platforms with the same x.y version of Python as you.

Remember that .pyc files suffer from the same decompilation
vulnerabilities as any other programming language (which is why there
exists software cracks). If someone wants to know what you are doing,
they will.

- Josiah

P.S. What kind of script do you have that you want to hide from prying eyes?
Jul 18 '05 #3

P: n/a
Josiah Carlson wrote:
Hi, is it possible to protect the python sourcecode?
I have a nice little script and i dont want to show everbody the source.

Im using python on a windows pc.


Compile the .py file into bytecode (.pyc). That .pyc file will only be
usable on platforms with the same x.y version of Python as you.

Remember that .pyc files suffer from the same decompilation
vulnerabilities as any other programming language (which is why there
exists software cracks). If someone wants to know what you are doing,
they will.


I don't know about Windows, but on Unix you can create a script with
permissions 700 and create a small setuid program executing this script.

Don't know whether Windows has such useful things though, probably not :-P

Gerrit.

--
PrePEP: Builtin path type
http://people.nl.linux.org/~gerrit/c.../pep-xxxx.html
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/

Jul 18 '05 #4

P: n/a
> I don't know about Windows, but on Unix you can create a script with
permissions 700 and create a small setuid program executing this script.

Don't know whether Windows has such useful things though, probably not :-P


I've never used setuid, but I would imagine that it works as the name
suggests, it sets the user id of the process. Which would allow you to
run the script with Python, but not read the source.

There is likely a nontrivial set of methods and system calls where a
script could use the 'run as' service in windows to do a similar thing,
but I wouldn't want to write it.

- Josiah
Jul 18 '05 #5

P: n/a
In a lighter vein, why do you want to hide your
python source code? Python is an 'open source' language
so I advise you to share your source code with us :-)

-Anand

Josiah Carlson <jc******@nospam.uci.edu> wrote in message news:<bv**********@news.service.uci.edu>...
I don't know about Windows, but on Unix you can create a script with
permissions 700 and create a small setuid program executing this script.

Don't know whether Windows has such useful things though, probably not :-P


I've never used setuid, but I would imagine that it works as the name
suggests, it sets the user id of the process. Which would allow you to
run the script with Python, but not read the source.

There is likely a nontrivial set of methods and system calls where a
script could use the 'run as' service in windows to do a similar thing,
but I wouldn't want to write it.

- Josiah

Jul 18 '05 #6

P: n/a
Anand Pillai wrote:
In a lighter vein, why do you want to hide your
python source code? Python is an 'open source' language
so I advise you to share your source code with us :-)


I'm all about sharing the code, the starter of the thread wanted to hide
it, I was just answering his question.

- Josiah
Jul 18 '05 #7

P: n/a

"Simon Wittber" <dr******@metaplay.com.au> wrote in message
news:005a01c3ec89$b10eaeb0$0000fea9@simonxp...
Anand wrote:
Python is an 'open source' language so I advise you to share your source code with us :-)


This was preceded by "In a lighter vein, why do you want to hide your
python source code?".
Python is open-source, true. However that does not mean programs written
in Python must be open-sourced. Maybe I am having a bad day,
I think so.
but I read your comment as a mob/peer pressure tactic,


Come now. One person's opinion, written 'in a lighter vein' and concluded
with ':-)' is hardly mob pressure, and not even much peer pressure.

In any case, there are a couple of relevant and related points contained in
'Python is open-source'.

On the one hand, Guido intentionally did not GPL Python or put any but the
most obvious and sensible restrictions on its use. In particular, one can
do the following that GPL prohibits: modify the compile and eval functions
to use a different set of op codes and distribute apps using the modified
interpreter without making the source of the modified interpreter
available. (This is not absolute security, but it does make disassembly of
application runtime code harder.)

On the other hand, Guido and the developers, as Python developers,
generally prefer that Python code be potentially and actually shared. So
they are under no obligation and are disinclined to do anything to make
non-sharing easier, not withstanding whatever they may have to do privately
to feed themselves and their families.

Terry J. Reedy


Jul 18 '05 #8

P: n/a
"Mark Buch" <ma*******@ewetel.net> wrote in message news:<bv*************@news.t-online.com>...
Hi, is it possible to protect the python sourcecode?
I have a nice little script and i dont want to show everbody the source.

Im using python on a windows pc.

Thank you - Mark


This comes up every once in a while. If you want to hide your source,
python is probably a bad choice of language -- it's designed to be
easy to understand, and you can probably decompile the byte-code
pretty easily.

Have you considered Perl? The advantage of Perl is, you could share
the source code with anybody you wanted, and be perfectly safe. You
can easily write Perl code that makes no sense at all to anyone but
you :)
Jul 18 '05 #9

P: n/a
> Josiah Carlson <jc******@nospam.uci.edu> wrote in message
news:<bv**********@news.service.uci.edu>...
I don't know about Windows, but on Unix you can create a script with
permissions 700 and create a small setuid program executing this

script.

One way is to hide the source as obfuscated "cleartext".
We build obfuscators for many languages, and could easily
build one for Python.
See http://www.semanticdesigns.com/Produ...ors/index.html.

(Hello from another Irviner!)
--
Ira D. Baxter, Ph.D., CTO 512-250-1018
Semantic Designs, Inc. www.semdesigns.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 18 '05 #10

P: n/a
"Ira Baxter" <id******@semdesigns.com> writes:
One way is to hide the source as obfuscated "cleartext".


As usual Python comes with batteries included:

# -*- coding=rot13 -*-

cevag "uryyb ebg13 jbeyq"

:-)

Bernhard

--
Intevation GmbH http://intevation.de/
Skencil http://sketch.sourceforge.net/
Thuban http://thuban.intevation.org/
Jul 18 '05 #11

P: n/a
Bernhard Herzog wrote:
....
As usual Python comes with batteries included:

# -*- coding=rot13 -*-

cevag "uryyb ebg13 jbeyq"

cevag h"uryyb ebg13 jbeyq"

Don't you mean?

Nice trick, btw, especially what happens if you include a syntax error
(translated to un-encoded :) ).

Have fun,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

Jul 18 '05 #12

P: n/a
"Mike C. Fletcher" <mc******@rogers.com> writes:
Bernhard Herzog wrote:
...
As usual Python comes with batteries included:

# -*- coding=rot13 -*-

cevag "uryyb ebg13 jbeyq"

cevag h"uryyb ebg13 jbeyq"

Don't you mean?


Yes. I had played around with that a few months ago and should have
checked the code again before posting.

Bernhard

--
Intevation GmbH http://intevation.de/
Skencil http://sketch.sourceforge.net/
Thuban http://thuban.intevation.org/
Jul 18 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.