![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() ![]() |
I was kind of upset when I heard that
Python has no way of hiding it's source code when made into an exe file. So I thought I'd try to do my best to solve that.
www.1v7.com/drsane/a1k8u.txt is really the new source code replacing: www.1v7.com/drsane/mini_game_luck.py That is what source code can now look like thanks to my program: www.1v7.com/drsane/Process_Data.py It's a very simple yet effective encryption method. Yes, of course it's breakable. But I've probably narrowed down potential source editors by at least fifty percent. The program is really easy to use: Header = """
==================================================
WARNING!
DO NOT EDIT ANY CONTENTS OF THIS FILE!
FAILURE TO COMPLY MAY DEEM LOSS OF PROGRAM ACCESS!
Encrypted by JDI 2005 (c) - dr.sane@gmail.com -
==================================================
"""
SOURCE = SOURCE(Header)
SOURCE.ENCRYPT('mini_game_luck.py', 'a1k8u.soul', 1)
SOURCE.EXECUTE('mini_game_luck.py', 'a1k8u.soul', 1)The header is what is shown at the top of the encrypted file for whatever purpose. That simple program demonstrates encrypting a source file (which can have any non-traditional extension). Then runs the encrypted source file (the original source file path is only there for added security, you don't actually need the original file anymore). Soon enough instead of having only 1 for the third argument, I'll add some more choices for more complex encryptions. The example and the format can be found in the Process_Data.py file. Please give me suggestions and feedback, and if you want to use this program to encrypt your source code, feel free (but give me credit). - The Sane
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. Last edited by Sane; Jun 12th, 2005 at 2:51 AM. |
|
|
|
|
|
#2 |
|
Expert Programmer
|
Creative... but of course it really wouldn't take much to decrypt that since your decryption key obviously has to be included in the .exe file.
I am assume that when python is compiled into a .exe file that it actually just puts its script parser in the exe file and attaches a copy of the PY source code into the exe file as some sort of string resource (or similar). The real way to get around this is to write a PY compiler that instead of executing the PY code actually produces machine code... this would solve your problem, though I admit it probably is not an easy task... but hey if no one else has done it you could earn a bit of a reputation (even make a bit of money).
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2005
Posts: 24
Rep Power: 0
![]() |
You could also take a look at this http://www.lysator.liu.se/~astrand/p...s/pyobfuscate/
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() |
No kurifu, it's simpler then that. All the exe does is run your source files in MS-DOS. All your source files remain seperate from the exe and fully editable. With this at least you'd have to go to the time of break pointing by decoder, and then printing the file before it runs it. The only purpose is really so that it isn't completely open to editing.
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I take it py2exe doesn't properly convert the Python to machine code then?
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() ![]() |
Nope all it does is package the Python interpreter with your source files, then creates a console window directed to your main source file.
![]() UPDATED: www.1v7.com/drsane/Process_Data_V13.py Much higher security now, with added features, and more user friendly. I just need to figure out how to delete the file if it accidently creates a blank one when searching for your source. (line 97) Edit: You'd also have to know Python pretty well in order to set the proper interception point in the program, since I replaced the variable names with wierd stuff. Python Board: I CHALLENGE YOU! www.1v7.com/drsane/12as8R12l.encrypted Use whatever methods/resources you wish to give me the real code to this encrypted source code. Here is the class your would use to run the encrypted file: def Methoda(rewl9o,rq079v,r73lef):
if rq079v==1:
import random;a=random.randrange(0, 2)
def rewI9i():return random.choice(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'])
def rewl9i():return rewl9o
return['',rewI9i()][a]+rewI9i()+rewI9i()+[rewl9i()+rewI9i(),''+rewl9i()][a]+["io","ea","au","ey","ta"][random.randrange(r73lef%2,((r73lef%2+1)*2))]+rewI9i()
def Methodb(rewl9i,rq079v,r73lef):
if rq079v==1:
if rewl9i[0]=='':return rewl9i[3]
else:return rewl9i[4]
class SOURCE(object):
def __init__(self, Header):
self.Header = Header
def ENCRYPT(self, r65SuA, r4yw2h, rq079v, r45soA):
if raw_input("""Are You Sure You Wish To Encrypt '%s' to '%s' (Y/N)? """%(r65SuA,r4yw2h)).upper()=="N":import sys;sys.exit()
print"Encrypting...\n%0 Complete";perc=0;the_r65SuA=open(r65SuA,'a');the_r65SuA.close();the_r65SuA=open(r65SuA,'r');rp0S9A=the_r65SuA.read();the_r65SuA.close()
if rp0S9A=="":print"""Error: '%s' does not exist."""%(r65SuA);import os;os.system("find "+r65SuA+" -exec /usr/bin/rm '{}' \;");import sys;sys.exit() ##TODO: DELETE CREATED BLANK
st="#"+r65SuA+"\n"+rp0S9A;r73le=[]
for a in range(len(st)):
r73la=[]
for b in range(len(str(st[a]))):r73la.append(Methoda(str(st[a])[b],rq079v,(a+1)%14))
r73le.append("".join(r73la))
for b in range(1,10):
if (100.0/float(len(st)+1))*float(a+1)>b*10 and perc<b*10:print"%s Complete"%("%"+str(b*10));perc=b*10
if (100.0/float(len(st)+1))*float(a+1)>99.9 and perc<100:print"%100 Complete\nWriting to File...";perc=100
import random;f=random.randrange(1,len(r73le)-1);r4yP2h_=r73le[:f]+[r45soA]+r73le[f:]
the_r65SuA=open(r4yw2h,'a');the_r65SuA.close();the_r65SuA=open(r4yw2h,'w');the_r65SuA.write(self.Header+"".join(r4yP2h_));the_r65SuA.close();print "File Encrypted and Saved!\n"
def EXECUTE(self, rt82Hh, r65SuA, rq079v, r45soA):
the_r65SuA=open(r65SuA,'r');rp0S9A=the_r65SuA.read();the_r65SuA.close();st=rp0S9A[len(self.Header):];r4yP2ha=[];rew59i="*"
for a in range(len(st)):
if st[a:a+15]==r45soA:rew59i="^";st=st[:a]+st[a+15:]
if rew59i=="*":print"""Error: '%s' is not the correct Password for '%s'."""%(r45soA, r65SuA);import sys;sys.exit()
else:
for a in range(1,len(st)+8):
if a%8==0:r4yP2ha.append(Methodb(st[a-8:a],rq079v,(a+1)%14))
rt22j9="".join(r4yP2ha)
if rt22j9[1:len(rt82Hh)+1]==rt82Hh:
for elem in[rt22j9]:exec elem
else:print"""Error: '%s' does not match what is found in the Original Source of the Encrypted File.'"""%(rt82Hh)Have fun! First person wins a cookie! :o
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. Last edited by Sane; Jun 12th, 2005 at 1:58 PM. |
|
|
|
|
|
#7 |
|
Newbie
|
holy $hit.
It doesn't hide the source code? :o :o :o :o :o hmm.....I think i wont go too far into Python then ![]() |
|
|
|
|
|
#8 |
|
Programming Guru
![]() ![]() |
Ya, it's quite bad. I say someone should take the intiative of programming something in C++ which wraps it all together.
But at least my program will help. ![]()
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#9 |
|
Programming Guru
![]() |
Python helping the open source movement.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
|
|
#10 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
If you are so worried about your source file, why don't you distribute the precompiled .pyc file? It's faster anyway.
__________________
I looked it up on the Intergnats! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|