diff --git a/README.md b/README.md index d475588..f9d12fd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ -# RunDecrypt +# Self Extracting Runner (PyInstaller) + +This project builds a Windows executable that: + +1. Contains a bundled `app.zip` +2. Extracts it to a temporary folder at runtime +3. Runs `app.exe` from inside the extracted files +4. Cleans up the temporary folder after execution + +--- + +## Requirements + +- Python 3.8+ +- PyInstaller + +Install PyInstaller: + +```bash +pip install pyinstaller -A simple Project in python which extracts and decrypts your project (base64) and runs it. \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..b6075a2 --- /dev/null +++ b/main.py @@ -0,0 +1,60 @@ +import os +import sys +import zipfile +import tempfile +import subprocess +import shutil + +def resource_path(relative_path: str) -> str: + """ + Get absolute path to resource, works for dev and for PyInstaller bundle. + """ + if hasattr(sys, "_MEIPASS"): + return os.path.join(sys._MEIPASS, relative_path) + return os.path.join(os.path.abspath("."), relative_path) + +def extract_and_run(): + zip_name = "app.zip" + exe_name = "app.exe" + + zip_path = resource_path(zip_name) + + if not os.path.isfile(zip_path): + print("Payload app.zip not found!") + return 1 + + temp_dir = tempfile.mkdtemp(prefix="self_extract_") + + try: + with zipfile.ZipFile(zip_path, "r") as z: + z.extractall(temp_dir) + + exe_path = os.path.join(temp_dir, exe_name) + + if not os.path.isfile(exe_path): + print("app.exe not found inside extracted payload!") + return 2 + + # Run the extracted executable + process = subprocess.Popen( + [exe_path], + cwd=temp_dir, + shell=False + ) + + process.wait() + return process.returncode + + finally: + # Cleanup after execution + try: + shutil.rmtree(temp_dir, ignore_errors=True) + except Exception: + pass + +def main(): + code = extract_and_run() + sys.exit(code if code is not None else 0) + +if __name__ == "__main__": + main()