Wiki‎ > ‎

Encrypt shell script on Linux and BAT file on Windows

posted Apr 26, 2017, 12:19 PM by Dong Xu   [ updated Oct 17, 2017, 2:39 PM ]
Alternative: https://unix.stackexchange.com/questions/90178/how-can-i-either-encrypt-or-render-my-shell-script-unreadable

  1. Write your script (script-base.sh)

    #!/bin/sh 
    echo "Hello World" 
  2. Encrypt your script (give a password):

    openssl enc -e -aes-256-cbc -a -in script-base.sh > script-enc 
  3. Write de Wrapper (script-final.sh):

    #!/bin/sh 
    openssl enc -d -aes-256-cbc -a -in script-enc | sh - 
  4. Run "script-final.sh", enter the password, and the script will run without write the plain text script on disk.

Windows Batch

https://superuser.com/questions/868340/how-can-i-convert-a-windows-batch-script-to-a-exe

Here are 2 free programs that I highly recommend for creating EXE's out of batch files

1 - Bat To Exe Converter

2 - Bat 2 Exe

You can use both programs with simple GUI.

Bat To Exe Converter supports also CLI commands (\? flag for help). Basic example from documentation:

Bat_To_Exe_Converter.exe -bat mybatfile.bat -save myprogram.exe -icon myicon


Comments