set up the password in the complied python code

Something that might challenge most of the users on the forum? Post it here.

Moderators: KDoiron, ChrJim, mawe, python

set up the password in the complied python code

Postby jliu66 on Thu Jan 10, 2008 2:14 pm

Hi, Dear my friends,

I have a trick questions to ask you about python scripts for help.

How can I set up a complied python code with a password so that nobody can touch or modify it and even copy it from one PC to another PC? In other words,
is there any way to have the high security in either python script or the complied python scripts? Another question is that the complied python code can be decoded back the orignal script or not? It is all security related issues. If you have better suggestions, I will be happy to listen and many thanks in advance.


Best,

John
jliu66
Python Fan
Python Fan
 
Posts: 2
Joined: Thu Jan 10, 2008 2:04 pm

Re: set up the password in the complied python code

Postby music on Sun Jan 13, 2008 11:46 am

Short answer: you can't.

Long answer: It's impossible to fully protect a program from tampering by the owner of the machine it's running on, and I'd even argue that this is a questionable objective. You certainly can't keep people from simply copying files. In addition, it is possible to get Python source code (though likely not identical to the original) back from a compiled Python bytecode file (.pyc or .pyo).

If you find yourself wanting to do something like this, you should examine your motives and see if there is another way to achieve your objectives. Fighting the ingenuity of your users will always be a losing battle, and nobody wants to use a program that views them as the enemy.
User avatar
music
Ultimate Python Hacker
Ultimate Python Hacker
 
Posts: 1330
Joined: Wed Jun 27, 2007 4:03 pm
Location: Virginia, USA

Re: set up the password in the complied python code

Postby redmarvel on Mon Jan 14, 2008 4:48 pm

However, if you want to obfuscate your code to prevent other programmers from being able to read it easily, well, you can find some solutions to that one in the Challenges forum. :twisted:
. . . . The Rockin' Red Femme Fatale
Uncommonly upping the ante. Unfortunatly undoing unnatural acts.

(If you find my posts helpful, put something [anything at all] in your profile)
User avatar
redmarvel
Ultimate Python Hacker
Ultimate Python Hacker
 
Posts: 1854
Joined: Fri Jul 06, 2007 1:21 pm
Location: Venus

Re: set up the password in the complied python code

Postby Smriti on Thu Jan 17, 2008 5:01 am

music is right
"It's impossible to fully protect a program from tampering by the owner of the machine it's running on."

Hiding code from a user is, well, an illusion. This is true for any software, written in any language. It is just a matter of how much effort someone has to spend on hacking your application.

There is an option to compile .py to .pyc and only distribute .pyc files (Python bytecode). Bytecode is not human readable, but it is possible to reverse engineer. For 99% of home-brew applications this will be more than sufficient. If not: learn to be better than the best hackers, and come back in, say, 30 years.

By the way: py2exe does not provide any better protection. It just packs all .pyc files into a zip archive (which can be appended to the .exe). The zip archive can be extracted very easily, and then a hacker has the bytecode again.



However the options with you to hide your code are :
1. Code obfuscation
2. Encryption of the code
3. Converting the code to binary

But I am sure, after all this your code is still not secure(from hardcore hackers) :) .
Smriti
New Python User
New Python User
 
Posts: 43
Joined: Fri Dec 14, 2007 4:06 am

Re: set up the password in the complied python code

Postby music on Thu Jan 17, 2008 9:32 am

Smriti wrote:However the options with you to hide your code are :
1. Code obfuscation
2. Encryption of the code
3. Converting the code to binary

But I am sure, after all this your code is still not secure(from hardcore hackers) :) .


Or, in the case of interpreted languages like Python, even from moderately patient amateurs.
User avatar
music
Ultimate Python Hacker
Ultimate Python Hacker
 
Posts: 1330
Joined: Wed Jun 27, 2007 4:03 pm
Location: Virginia, USA


Return to Intermediate

Who is online

Users browsing this forum: No registered users and 2 guests


Sponsored by Dreamlink Web hosting and Traduzioni Rumeno Italiano and ASSP Deluxe for cPanel.