LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-06-2005, 02:28 PM   #16
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111

Quote:
Originally posted by kushalkoolwal
What difference is the difference between:
1. When we encrypt a file with some algorithm or
2. Write a C code and get a binary file.
The difference is that encryption makes a script unreadable. Embedding a shell-script in a C-program would probably result in a executable file containing the script still readable.

You could code some form of encryption into the C-program as wel, but I guess that's exactly what the 'SHC' people have done.

My rot13 is not be taken very serious. Though it does make the code unreadable at the first glance, a good novice user can figure it out. As easy/difficult with the compiled C-program.

So, stick with 'SHC'. Easier than writing your own.
 
Old 10-06-2005, 02:37 PM   #17
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally posted by kushalkoolwal
Are there any utilities which can get the C source code from the C binary file? I always use to wonder about this.
No, not really.
All identifiers (variable and function names) are gone. With a disassembler you can can the source in assembly. With a lot of patience one could figure out how what it does, and reconstruct the program is C. Maybe there exist utilities to help with this, but I don't know of any.
 
Old 10-06-2005, 03:34 PM   #18
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
kushalkoolwal - asking about the difference between "encryption" and "binary format" is a good one, and the answer has some important points.

Basically, "binary encoding" makes the program unreadable to a human, but decipherable to the machine.

"Encryption", on the other hand, renders the program undecipherable to *both* the human *and* the machine, without the proper key and decryption function.

The important points are these:

a) "binary encoding" doesn't necessarily make it *unreadable* to the human - merely somewhat inconvenient to decipher

b) In that respect, it is absolutely equivalent to rot13 (a simple data encoding scheme) and "obfuscation" (a souce code encoding scheme).

c) Encoding data so that it can be handled more conveniently (for example, uuencode to transmit binary data over 7-bit ASCII transports) is perfectly legitimate.

d) Confusing simple encoding schemes with true encryption is tantamount to "Security through Obscurity" (i.e. obfuscating the data and hoping nobody will go to the trouble of deciphering it).

Which is basically no security whatsoever.

Again, it sounds like what you need more than some encryption or obfuscation scheme is a good, written "Right to Use" policy, and some good user education.

Honest .. PSM
 
Old 10-06-2005, 06:00 PM   #19
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
wow!!! That was interesting to know. Thanks so much
 
Old 10-07-2005, 10:19 AM   #20
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
If you want, you can send me you encryped script and I'll tell you if I can crack it or not. I'm not a novice user, so I wont accidentally screw up my system. You should send me the script unencyped too so I can compare what I get from trying to crack the encryped script with the real script.
 
Old 10-07-2005, 02:19 PM   #21
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally posted by sirclif
If you want, you can send me you encryped script and I'll tell you if I can crack it or not. I'm not a novice user, so I wont accidentally screw up my system. You should send me the script unencyped too so I can compare what I get from trying to crack the encryped script with the real script.
Don't forget to include your internet IP address and root password - that way we can all "help".
 
Old 10-07-2005, 03:56 PM   #22
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
yea, and we'll probably need a credit card number.
 
Old 10-07-2005, 06:16 PM   #23
ashucool83
LQ Newbie
 
Registered: Sep 2005
Posts: 11

Rep: Reputation: 0
Quote:
What difference is the difference between:
1. When we encrypt a file with some algorithm or
2. Write a C code and get a binary file.
1. Well algorithms use mathematical computations to your file
"plain.txt" to generate an encrypted file "cipher.txt". And these algorithms are generally programmed in some language. And on the encrypted file you run the algorithm again to get back the plain text. Ofcourse you use a password key ... depending on the algorithm.

2. The binaries you get from a C file are actually machine code which the computer understands to execute and accomplish the tasks of your program which you possibly wrote in a High Level Language. Also getting the C file back from a binary is hard. Unlike Java where you can use a decompiler on a java class file to get back the java code.


Hope this helps you understand the difference.

Thanks
 
Old 10-08-2005, 09:05 PM   #24
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
You could have your script encrypted in a C program that feeds it to /bin/bash via a pipe. Bash is supposed to read it from stdin.
 
Old 10-09-2005, 03:37 AM   #25
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
thank you guys. I really appreciate for all your help.

I have one more question to ask:

Does it make difference wrt to system performance if I run a normal shell script or run it through a C binary commands (by embedding those commands in shell script in the C file)?


thanks
 
Old 10-09-2005, 04:47 AM   #26
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Quote:
Originally posted by kushalkoolwal
Does it make difference wrt to system performance if I run a normal shell script or run it through a C binary commands (by embedding those commands in shell script in the C file)?
If you parse the commands yourself with no help from the shell, it'd help in case /bin/bash is replaced with /bin/cat to obtain the source of your program.

But in any way it could be obtained by hijacking (be it replacing all programs executed or library redirection). The best way would be to emulate most of the functionality with the C library
 
Old 10-09-2005, 07:39 AM   #27
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Binaries are typically faster than shell scripts but if your binary is having to call a shell script then it won't be faster. Long ago I'd tested a product from Cactus software that appeared to do what shc says it does. On testing I found that the resulting binary was no faster (or slower) than the original shell script.

To make a binary faster you have to use the C libraries that do equivalent functions to shell commands rather than doing "system shellcommand" calls. The former makes it all machine language whereas the latter makes an external call to another item so has to fork off to that.
 
Old 10-09-2005, 04:41 PM   #28
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 32
kushalkoolwal, with proper encryption, getting at the clear text is designed to be prohibitively CPU intensive. The effort will depend on the length of the key. As always, that's "to the best knowledge of free science" -- it's always possible that some country's secret service knows a much faster algorithm to crack a popular encryption, but we'll never know.

But that's not your situation -- you are giving the cypher and THE KEY to the people from whom you're trying to keep your script. So it doesn't matter that much if it is a sophisticated encryption or rot13.

Compiling a C program may obscure things a little (even though it's not intentionally designed for that). If "install.c" calls system for each line of your original script, and you compile it into "install", then simply running "strings install" has a good chance of printing the whole script, maybe preceded by 10 to 20 unrelated symbols.
 
Old 10-10-2005, 03:27 AM   #29
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Quote:
Originally posted by jlightner
Binaries are typically faster than shell scripts but if your binary is having to call a shell script then it won't be faster. Long ago I'd tested a product from Cactus software that appeared to do what shc says it does. On testing I found that the resulting binary was no faster (or slower) than the original shell script.

To make a binary faster you have to use the C libraries that do equivalent functions to shell commands rather than doing "system shellcommand" calls. The former makes it all machine language whereas the latter makes an external call to another item so has to fork off to that.
Thanks for the information. That clears whole bunch things of me.

Also you mentioned something about "use the C libraries that do equivalent functions to shell commands" . Where I can see the library C commands for my regular shell script commands like cp, fdisk, mv,tar, etc.

Thanks
 
Old 10-10-2005, 05:29 AM   #30
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,516

Rep: Reputation: 240Reputation: 240Reputation: 240
if they are ignorant users they probably wouldn't dare play with it.
why not simply make it non-writeable?
You can make it a root-owned file in their directory.


hiding things is the microsoft way, not ours.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
new shell window by script or code r2d2 Programming 2 12-14-2005 01:59 PM
return value from shell script to c code? khucinx Programming 1 05-13-2004 03:43 PM
c code vs shell script again? khucinx Programming 1 05-12-2004 09:44 PM
c code vs shell script? khucinx Programming 1 05-12-2004 06:06 PM
how to execute shell script with c code? khucinx Programming 3 05-04-2004 02:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:00 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