Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I duno why you'd want to do that though. Kinda goes against the open source spirit amiright?
Hello SAG ,
first thank you for helping me man ,& i really apreciate this so much
second ,no i like open source, but i want this to encrypt a shell script that will do a project in our company & i want to be the only responsible one for this project ,as the company fired me since one month ago & returned me again then asked for this project, so i didnt want the company to take it,cuz it may fire me again or even if they did ,then they will feel that they really loose me,,
maybe i'm bad in this thing ,but life is hard & i have a house & wife
but in that case running them in openssl requires password to decrypt them & execute it..Make an entry on crontab with some prerequisite details. May it works
I wonder. They probably do the encryption this way:
Encrypt:
1) Encrypt text of script.
2) Bind the encrypted text with an executable.
Decrypt and Run:
1) Executable decrypts bound text.
2) Open a pipe. Run bash making it read the pipe just like a file. Send decrypted text to pipe.
However I think the decrypted text sent to pipe can be intercepted.. somewhere or somehow.
Do you mean for code obfuscation? If so then you're getting way too complicated. It's not encrypted with a key or anything like that. It's rewritten into such a way that it is unreadable for humans to easily edit.
There's two main methods of obfuscation that I can think of off of the top of my head.
1) take out all white spaces and comments and compact the code to a single line. (aka compacting)
2) Do same as #1 but in addition take and create an inhuman amount of variables and scramble them up in a confusing manner.
Here's an example using Javascript... Plain text
PHP Code:
var a="Hello World!"; function MsgBox(msg) { alert(msg+"\n"+a); } MsgBox("OK");
Obfuscated JavaScript
PHP Code:
var _0x41a8=["\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21","\x0A","\x4F\x4B"];var a=_0x41a8[0];function MsgBox(_0x786dx3){alert(_0x786dx3+_0x41a8[1]+a);} ;MsgBox(_0x41a8[2]);
When you run both of them in a browser they do the exact same thing. Now imagine a JavaScript program with 1500 lines of code which has been obfuscated. It would be nearly impossible to decrypt by a human. Hundreds of man hours would be wasted doing it even if it were decrypted. Either way the person trying to get the code has wasted time and money.
Quote:
Originally Posted by HuMan-BiEnG
maybe i'm bad in this thing ,but life is hard & i have a house & wife
Ethically I don't think you're wrong. It all breaks down to company loyalty and the misunderstanding relationship between employee and company. If the company is not required to show loyalty to it's employees and fire them at any time then why should the employee have to show loyalty to the company? You should look into "whistle blowing" for more information on what I mean.
I never said it was encrypted, in fact I stated it was not encryption. He wanted to know how to hide the code. Code obfuscation is how one would do it without compiling it into a binary. People commonly mistake code obfuscation for encryption so usually when they ask for code encryption what they actually want is obfuscation. I seriously doubt the OP wants to enter a password just to have a script decoded each time it was ran. On top of any root level password needed.
I never said it was encrypted, in fact I stated it was not encryption. He wanted to know how to hide the code. Code obfuscation is how one would do it without compiling it into a binary. People commonly mistake code obfuscation for encryption so usually when they ask for code encryption what they actually want is obfuscation. I seriously doubt the OP wants to enter a password just to have a script decoded each time it was ran. On top of any root level password needed.
Hi,
If you don't mind, have a look at the first link I posted in post #4. From that page:
Quote:
The program "shc" creates C source code out of your shell script then encrypts it (script.sh.x.c). The encrypted shell script is: script.sh.x. Now copy the original "script.sh" file to a floppy disk or some other system for backup or in case you need to edit it in the future. Then, delete it from the server and delete the "script.sh.x.c" file it creates.
Neat feature
You can also specify a time limit on the shell script so that it will no longer execute after a certain date and you can specify a custom message to echo back to the user. Run this command on the "script.sh" file we created earlier in this tut:
shc -e 09/10/2004 -m "Dude it is too late to run this script." -f script.sh
./script.sh.x
./script.sh.x has expired!
Dude it is too late to run this script.
In the above command the date October 9, 2004 is set as the expiration date (-e 09/10/2004) and the custom message was set to display to the user (-m "Dude it is too late to run this script.") when the binary is executed. Note the date format is dd/mm/yyyy.
By using shc there's no need at all to decrypt a script before running it. If OP want encryption then I believe this is the easiest way to go. The encrypted script is the only one he has to leave on the server, is executable but unreadable. I've used it on various occasions and it does the trick.
Do you mean for code obfuscation? If so then you're getting way too complicated. It's not encrypted with a key or anything like that. It's rewritten into such a way that it is unreadable for humans to easily edit.
No I never meant "code obfuscation". You're the only one who made an assumption for that. And I don't think it is that complicated in fact the concept is way too simple for me.
Quote:
Originally Posted by sag47
I never said it was encrypted, in fact I stated it was not encryption. He wanted to know how to hide the code. Code obfuscation is how one would do it without compiling it into a binary. People commonly mistake code obfuscation for encryption so usually when they ask for code encryption what they actually want is obfuscation. I seriously doubt the OP wants to enter a password just to have a script decoded each time it was ran. On top of any root level password needed.
Yup but unfortunately that was what the OP requested (see title). You're the only one who decided that it's not. Making a reply based on his question I think could never be a bad move on my part.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.