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

Embedding exe file

P: n/a
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='''R0lGODdhFQAVAPMAAAQ2PESapISCBASCBMTCxPxmNCQ iJJya/ISChGRmzPz+/PxmzDQyZ
DQyZDQyZDQyZCwAAAAAFQAVAAAElJDISau9Vh2WMD0gqHHelJw nsXVloqDd2hrMm8pYYiSHYfMMRm
53ULlQHGFFx1MZCciUiVOsPmEkKNVp3UBhJ4Ohy1UxerSgJGZM MBbcBACQlVhRiHvaUsXHgywTdyc
....'''

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

Jul 16 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.b6 4decode(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

Jul 16 '06 #2

P: n/a
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

Jul 17 '06 #3

P: n/a
In article <11**********************@s13g2000cwa.googlegroups .com>,
Bayazee <ba*****@gmail.comwrote:
>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 ....
Jul 17 '06 #4

P: n/a

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.

Jul 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.