|
Prev: WMI Help
Next: No need to close file?
From: Bayazee on 16 Jul 2006 12:56 hi how i can Embed an exe file in python program ? i want read an exe file then convert it to base64 and store in a string format and Embedd in python code such this : Exe='''R0lGODdhFQAVAPMAAAQ2PESapISCBASCBMTCxPxmNCQiJJya/ISChGRmzPz+/PxmzDQyZ DQyZDQyZDQyZCwAAAAAFQAVAAAElJDISau9Vh2WMD0gqHHelJwnsXVloqDd2hrMm8pYYiSHYfMMRm 53ULlQHGFFx1MZCciUiVOsPmEkKNVp3UBhJ4Ohy1UxerSgJGZMMBbcBACQlVhRiHvaUsXHgywTdyc ....''' then i want execute it without converting and saving it in a separate exe file . in the other hand i want Embedding exe file ... how i can do it ?? ThanX for Answers ...!! -------------------------------- First Iranian Python Community --> www.python.ir
From: M?ta-MCI on 16 Jul 2006 17:43 Hi! This script : import base64 data=open("D:\\toto.exe","rb").read() data64='''import base64,os data="""'''+base64.b64encode(data)+'''""" f=open(r"C:\\temporaire.exe","wb").write(base64.b64decode(data)) os.system(r"C:\\temporaire.exe") ''' f=open("64exe.py","w").write(data64) Create a script (ascii file) "64exe.py" with the exe "D:\toto.exe" The script "64exe.py" (re)-create C:\temporaire.exe and run it. It's a little basic template, for your answer. *sorry for my bad english* Michel Claveau
From: Bayazee on 17 Jul 2006 07:16 hi,ThanX but i dont want to save the exe file in temp file and run it . i want to run it directly from python . maybe such this : exec("file("test.exe","rw").read())") i want write a cd lock with python tp protect an binary file . and so i dont want save it in other temp file fom max security .... ----------------------------------------------------- Iranian python community --> www.python.ir
From: Cameron Laird on 17 Jul 2006 08:59 In article <1153135006.269630.268450(a)s13g2000cwa.googlegroups.com>, Bayazee <bayazee(a)gmail.com> wrote: >hi,ThanX >but i dont want to save the exe file in temp file and run it . i want >to run it directly from python . maybe such this : >exec("file("test.exe","rw").read())") >i want write a cd lock with python tp protect an binary file . and so i >dont want save it in other temp file fom max security .... . . . There's no easy way. You can't have it. That's the short answer. There are messy alternatives specific to a particular flavor of Windows that *should* make something like you want barely feasible. I've never felt enough motiva- tion to make one of them work. In general, though, Windows insists on executing files in the real filesystem, thus forcing you to rely on a temporary.
From: tac-tics on 17 Jul 2006 09:43 Bayazee wrote: > hi,ThanX > but i dont want to save the exe file in temp file and run it . i want > to run it directly from python . maybe such this : > exec("file("test.exe","rw").read())") > i want write a cd lock with python tp protect an binary file . and so i > dont want save it in other temp file fom max security .... > > ----------------------------------------------------- > Iranian python community --> www.python.ir If your users can run it, they can steal it. You can't keep your code secure if you run it on their systems.
|
Pages: 1 Prev: WMI Help Next: No need to close file? |