LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   encrypted executable scripts (https://www.linuxquestions.org/questions/linux-security-4/encrypted-executable-scripts-828202/)

izghitu 08-24-2010 11:04 AM

encrypted executable scripts
 
Hi,

I have some bash and python scripts.

Is there any way to encrypt them but still be able to execute them encrypted?

Please help

Thanks

win32sux 08-24-2010 01:34 PM

What are you hoping to gain with this?

izghitu 08-24-2010 01:38 PM

I'm hoping to be able to give someone my scripts so he can execute them but can't see the contents of the scripts

Les Windoze 08-24-2010 02:28 PM

Don't know about bash (doubt it) and Python but you can with Perl.
Is there a security issue with the `someone' seeing your code?

anomie 08-24-2010 02:59 PM

My WAG is OP has some authentication credentials embedded in his scripts. That or he's hoping to hide proprietary code..?

Quote:

Originally Posted by izghitu
Is there any way to encrypt them but still be able to execute them encrypted?

Nope, and if you think about it the question doesn't make sense. Cipher text is pseudo-random garbage without the right key. You could decrypt the cipher text (e.g. in memory) and then execute the plaintext instructions.

Please describe in detail about your exact problem so that we can take a more informed stab at some solutions.

knudfl 08-24-2010 03:50 PM

There is a well known tool, that "compiles" a shell script
into an ELF executable : shc.
http://asdfasdf.debian.net/~tar/free.../shc-3.8.7.tgz

http://blogs.koolwal.net/2009/01/20/...-based-system/

Is usually available with 'apt-get install shc' or # yum install shc
( RPM : The Rpmforge repo.)
..

spayre 10-27-2010 06:15 AM

i have tried compiling my script using the command below

shc -r -v -f <scriptname.sh>

when i ran the ./scriptname.sh.x, it works!

but when i copied the scriptname.sh.x to another linux machine, give it the permission (chmod 777), it throws an error...

-bash : scriptname.sh.x: cannot execute binary file

any ideas?

vomplete 11-04-2010 01:17 PM

Not sure, but I think that SHC must be installed on both machine (on "compiling machine" and others machines that execute these binary files)

bye

Quote:

Originally Posted by spayre (Post 4140794)
i have tried compiling my script using the command below

shc -r -v -f <scriptname.sh>

when i ran the ./scriptname.sh.x, it works!

but when i copied the scriptname.sh.x to another linux machine, give it the permission (chmod 777), it throws an error...

-bash : scriptname.sh.x: cannot execute binary file

any ideas?



All times are GMT -5. The time now is 07:29 AM.