LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-29-2015, 07:40 AM   #1
Aashika
LQ Newbie
 
Registered: Sep 2014
Posts: 15

Rep: Reputation: Disabled
openssl encrypted file is giving cannot execute binary file error


I have encrypted my shell script with openssl command:
Code:
openssl enc -aes-256-cbc -salt -in file.txt -out file.txt.enc -k PASS
then I have renamed the .enc file to the original .sh file and tried to run it, but it gives me the "cannot execute binary file" error.
Can I execute a script which is openssl encrypted?? If yes then how??

Thank you in advance
 
Old 06-29-2015, 09:59 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by Aashika View Post
Can I execute a script which is openssl encrypted??
no.
 
Old 06-29-2015, 10:07 AM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Linux executes only elf type executables or files starting with she bang. Encryption produces non-decipherable data - garbage for linux to execute.

You can use openssl to decipher and pass the output via a pipe to bash or sh.
 
Old 06-30-2015, 02:35 AM   #4
Aashika
LQ Newbie
 
Registered: Sep 2014
Posts: 15

Original Poster
Rep: Reputation: Disabled
thankyou..
Is there any other way by which I can encrypt a file and then execute the encrypted file?
shc will help me encrypt the file and also allow me to run that particular encrypted file.. but if I want to run that encrypted file on another system, I will have to install shc on the another system as well..
 
Old 06-30-2015, 01:04 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Can't be done. Either the file is encrypted (and becomes binary garbage as far as a program loader is concerned) or it isn't. The shell does not, and can not, interpret what is garbage.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error; Cannot execute binary file kumar Saurabh Linux - General 8 06-20-2011 07:12 AM
make with make file yields error: /usr/bin/javac: cannot execute binary file bweaver Ubuntu 4 11-19-2010 02:58 PM
getting error 'cannot execute binary file' kapilbajpai88 Linux - Newbie 15 09-20-2010 06:00 AM
unable to run c program , error : cannot execute binary file soni_silver17 Linux - Software 4 03-30-2009 08:45 AM
While installing informix-SE 7.0 it gives error as cannot execute binary file sp2797 Linux - Server 1 09-07-2006 09:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration