Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm developing a small python script to take a base64 encoded zip, decode it, and run an EXE that's inside the zip only in RAM (so no disk writing). This is what I have so far if it makes sense, except I'm getting an issue with subprocess. How can I accomplish running this in RAM? Any help is appreciated!

from StringIO import StringIO
import base64
import zipfile
import subprocess

base64zipped = base64NonsenseHere

zippass = "thisisjustforme123"

zipdata = StringIO()
zipdata.write(base64.decodestring(base64zipped))
myzipfile = zipfile.ZipFile(zipdata)
myzipfile.setpassword(zippass)
subprocess.Popen(myzipfile.open('Application 1.exe'))

Error:

Traceback (most recent call last):
  File "C:\Users\user\Desktop\DD\Main.py", line 780, in <module>
    subprocess.Popen(myzipfile.open('Application 1.exe'))
  File "C:\Python27\lib\subprocess.py", line 679, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
    startupinfo)
TypeError: must be string without null bytes or None, not str
>>>
share|improve this question
    
Wether or not data is written to disk is determined by your programm and the one you're trying to start. Any reason you're so worried about that ? Also I'm not sure what you are trying to acomplisch with the whole myzipfile.open() thing. If you wan't to start Application1.exe you pass the path to that exe to popen. It's just like you would start the App from cmdline. –  pypat May 7 '13 at 17:55
    
The reason I attempted myzipfile.open() is attempting to find a way to launch the application in RAM as I don't have a path for RAM (unless I'm wrong.) –  Dboy1612 May 7 '13 at 18:00
    
Any application runs inside RAM (not taking into account that the OS may swap parts of the RAM to disk). You just wan't to start that application right ? Just dump the whole zip idea and you'll be fine :) (unless I'm missing something fundamentaly here) –  pypat May 7 '13 at 18:05
2  
I think he's trying to find a way to write something that will run an encrypted executable seamlessly, but without writing the extracted data to a file for security reasons. You'd probably have to write a C-extension to accomplish something like this, as you'd have to get the OS to execute binary data directly, via a stream or some sort of shared memory. You'll also be limited in the size of executables that can be run. Python might not be the best language, since it's so easy to modify (and thus circumvent your in-memory decryption-execution pipeline). –  Silas Ray May 7 '13 at 18:12
    
sr2222's has it down! Encryption is not a BIG worry, but I would like to try and accomplish it in Python if possible. –  Dboy1612 May 7 '13 at 18:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.