473,473 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Hide the python-script from user

Hi,

recently there was a thread about hiding the python-script from the user.
The OP could use

http://freshmeat.net/projects/pyobfuscate/

H.
Apr 6 '07 #1
7 2964
On Apr 6, 3:19 pm, hlubenow <hluben...@gmx.netwrote:
recently there was a thread about hiding the python-script from the user.
The OP could use
Interesting - thanks

Apr 6 '07 #2
ts-dev wrote:
On Apr 6, 3:19 pm, hlubenow <hluben...@gmx.netwrote:
>recently there was a thread about hiding the python-script from the user.
The OP could use

Interesting - thanks
Well, testing it, it doesn't seem to work very well ...

It seems, Python-code is rather difficult to obfuscate, probably because of
its clear syntax and indentations. Here's yet another approach:

http://pythonhacker.is-a-geek.net/my...e-0.1.zip/view

H.
Apr 6 '07 #3
hlubenow wrote:
ts-dev wrote:
>On Apr 6, 3:19 pm, hlubenow <hluben...@gmx.netwrote:
>>recently there was a thread about hiding the python-script from the
user. The OP could use

Interesting - thanks

Well, testing it, it doesn't seem to work very well ...

It seems, Python-code is rather difficult to obfuscate, probably because
of its clear syntax and indentations. Here's yet another approach:

http://pythonhacker.is-a-geek.net/my...e-0.1.zip/view
>
H.
That didn't work very well either :(.

Ok, but now I can offer a real secure solution:

You can have real encryption in Python using this modules:
http://www.amk.ca/files/python/crypt...o-2.0.1.tar.gz

and

http://sourceforge.net/projects/yawpycrypto

Below I post a code-example that I've written some time ago. With it,
encrypting text is rather easy.

Then you have to program a start-script, that reads in your script and the
decryption-key. The decryption-key must be encrypted too. Such a encrypted
key can be generated by the modules if you don't pass a password to my
function "doEncrypt(). The decryption-key must then be hidden somewhere
within the encrypted program-script. That's because, if the user knows
where to find the key, he can decrypt the program-script.

If your start-script is written, everything should work automatically, one
shouldn't nearly notice the decryption-process.

Ok, here's my example code, how to encrypt and decrypt some text with the
modules:

----------------------------------------------------------------------------

#!/usr/bin/env python

import os
import sys
import base64

from yawPyCrypto.Cipher import DecryptCipher, EncryptCipher
from yawPyCrypto.Cipher import ZipDecryptCipher, ZipEncryptCipher
from yawPyCrypto.Constants import CIPHER_BLOWFISH, MODE_CBC
def doEncrypt(text, passw = None):

e = EncryptCipher(passw, CIPHER_BLOWFISH, MODE_CBC)
e.feed(text)
e.finish()
encryptedtext = e.data

if passw != None:
passwr = passw
else:
passwr = e.password

a = (encryptedtext, passwr)
return a
def doDecrypt(encryptedtext, passw):
d = DecryptCipher(passw)
d.feed(encryptedtext)
d.finish()
decoded = (d.data)
return decoded
# Calling the encryption routine.
# If you just pass the text to encrypt, a password is generated:

a = doEncrypt("For your eyes only !", "Melina")
# Just trying to clean the screen:

if sys.platform == "win32":
os.system("cls")
else:
os.system("clear")

print
print "Hello !"
print
print "I just encrypted some text. It looks like this now:"
print

print base64.b64encode(a[0])

print
print 'Please notice, that I just encoded the text once more using
"base64.b64encode()" to make it printable.'
print
print "The password for decryption is: "
print
print base64.b64encode(a[1])
print
print "Let's decrypt again (the original password must be passed without
b64encoding):"
print
print doDecrypt(a[0], a[1])
print

----------------------------------------------------------------------------

See you

H.
Apr 6 '07 #4
On Sat, 07 Apr 2007 00:19:20 +0200, hlubenow wrote:
Hi,

recently there was a thread about hiding the python-script from the user.
The OP could use

http://freshmeat.net/projects/pyobfuscate/

Wearing my developer hat, I can tell you that there's nothing I love more
than getting error reports from my users that look like this:

Traceback (most recent call last):
File "myapp.py", line 36, in ?
print i1I1Iiii1111 ( )
File "myapp.py", line 33, in i1I1Iiii1111
return IiiIII111iI ( )
File "myapp.py", line 24, in IiiIII111iI
O0oo0OO0 = IiII + I1i1iiI1 ( iI1Ii11111iIi ) + i1i1II [ 2 ] - Oo ( )
File "myapp.py", line 18, in Oo
raise iI1 ( "a problem happened" )
__main__.iI1: a problem happened
I love a challenge!

--
Steven.

Apr 7 '07 #5
hlubenow wrote:
hlubenow wrote:
>ts-dev wrote:
>>On Apr 6, 3:19 pm, hlubenow <hluben...@gmx.netwrote:
recently there was a thread about hiding the python-script from the
user. The OP could use

Interesting - thanks

Well, testing it, it doesn't seem to work very well ...

It seems, Python-code is rather difficult to obfuscate, probably because
of its clear syntax and indentations. Here's yet another approach:

http://pythonhacker.is-a-geek.net/my...e-0.1.zip/view
>>
H.

That didn't work very well either :(.

Ok, but now I can offer a real secure solution:

You can have real encryption in Python using this modules:
http://www.amk.ca/files/python/crypt...o-2.0.1.tar.gz

and

http://sourceforge.net/projects/yawpycrypto

Below I post a code-example that I've written some time ago. With it,
encrypting text is rather easy.

Then you have to program a start-script, that reads in your script and the
decryption-key. The decryption-key must be encrypted too. Such a encrypted
key can be generated by the modules if you don't pass a password to my
function "doEncrypt(). The decryption-key must then be hidden somewhere
within the encrypted program-script. That's because, if the user knows
where to find the key, he can decrypt the program-script.

If your start-script is written, everything should work automatically, one
shouldn't nearly notice the decryption-process.

Ok, here's my example code, how to encrypt and decrypt some text with the
modules:

----------------------------------------------------------------------------
>
#!/usr/bin/env python

import os
import sys
import base64

from yawPyCrypto.Cipher import DecryptCipher, EncryptCipher
from yawPyCrypto.Cipher import ZipDecryptCipher, ZipEncryptCipher
from yawPyCrypto.Constants import CIPHER_BLOWFISH, MODE_CBC
def doEncrypt(text, passw = None):

e = EncryptCipher(passw, CIPHER_BLOWFISH, MODE_CBC)
e.feed(text)
e.finish()
encryptedtext = e.data

if passw != None:
passwr = passw
else:
passwr = e.password

a = (encryptedtext, passwr)
return a
def doDecrypt(encryptedtext, passw):
d = DecryptCipher(passw)
d.feed(encryptedtext)
d.finish()
decoded = (d.data)
return decoded
# Calling the encryption routine.
# If you just pass the text to encrypt, a password is generated:

a = doEncrypt("For your eyes only !", "Melina")
# Just trying to clean the screen:

if sys.platform == "win32":
os.system("cls")
else:
os.system("clear")

print
print "Hello !"
print
print "I just encrypted some text. It looks like this now:"
print

print base64.b64encode(a[0])

print
print 'Please notice, that I just encoded the text once more using
"base64.b64encode()" to make it printable.'
print
print "The password for decryption is: "
print
print base64.b64encode(a[1])
print
print "Let's decrypt again (the original password must be passed without
b64encoding):"
print
print doDecrypt(a[0], a[1])
print

----------------------------------------------------------------------------
>
See you

H.
This still has a problem: The start-script has to know how to decrypt the
main-script and the start-script is visible, so the user can see how it
does it.
Perhaps one could obfuscate the start-script or write a C extension, that
does decrypting instead of the start-script.
This is getting rather complicated ...

H.
Apr 7 '07 #6
hlubenow <hl*******@gmx.netwrites:
Ok, but now I can offer a real secure solution:
Nope.

[snip]
Then you have to program a start-script, that reads in your script and the
decryption-key. The decryption-key must be encrypted too. Such a encrypted
key can be generated by the modules if you don't pass a password to my
function "doEncrypt(). The decryption-key must then be hidden somewhere
within the encrypted program-script. That's because, if the user knows
where to find the key, he can decrypt the program-script.

If your start-script is written, everything should work automatically, one
shouldn't nearly notice the decryption-process.
That is to say, for the user to be able to run your program, they must
have the key. They don't have to know they have the key, but they
have to have it. This isn't really secure, it's just obscure. It
depends on the user not finding the key, and on no one telling them
where it is. A determined and technically savvy user will surely find
the key (not least by debugging the start-script).

Basically, this doesn't work for the same reason that DRM doesn't
work.

--
+-----------------------------------------------------------+
| Jason F. McBrayer jm*****@carcosa.net |
| If someone conquers a thousand times a thousand others in |
| battle, and someone else conquers himself, the latter one |
| is the greatest of all conquerors. --- The Dhammapada |
Apr 8 '07 #7
jm************@carcosa.net (Jason F. McBrayer) writes:
A determined and technically savvy user will surely find
the key (not least by debugging the start-script).
.... and then write a patch that disables the key, and distribute that to
a few million of his not so determined or savvy friends.
Basically, this doesn't work for the same reason that DRM doesn't
work.
That reason being, it only needs to be cracked once. The odds are heavily
stacked in the crackers' favor.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Apr 8 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Mark Buch | last post by:
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
2
by: Raymond Tinsel | last post by:
Hello all, I know this must be a newbie question, but I haven't found the solution in the tutorials I have read. For a dSPACE/Controldesk application I am defining several of my own modules....
0
by: Robert Hilkene | last post by:
Hi there I want to hide output characters in my py program. I found that for Macintosh you implement 4.12 quietconsole -- non-visible stdout output...
4
by: Bell, Kevin | last post by:
Great! And now that it's hiding w/ .pyw, how would I kill it if I want? Just log off, or is there a better way? Kevin
64
by: Bayazee | last post by:
hi can we hide a python code ? if i want to write a commercial software can i hide my source code from users access ? we can conver it to pyc but this file can decompiled ... so ...!! do you...
0
by: Charles Fox | last post by:
Hi guys, I'm playing with Python in emacs, with python mode. I'd like to be able to press a key to toggle the code comments on and off -- to switch between beautiful clean Python code, and the...
3
by: tmallen | last post by:
I'm working on a little FTP project to get comfortable with ftplib. It's all terminal-based right now, and one issue I'm having is hiding password input text. I'd like one of two things to happen...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.