Xxxxxxxxxxxxxx ConverT Shell Script to C - Binary [executable ] xxxxxxxxxxxxxxX
Hi many times we required to convert our script to be executable might be any of below reasons .
- We don't want to share our script code
- We want to set suid, guid that we can't do with shell scripts
- Want to run script without any extension as ./script.sh OR sh script.sh etc...
Here an fantastic toll that will hep you to achieve so .
Download & Install
Note: Install proper Linux/Unix flavor rpm and architecture else it will not going to work as expected
Download:
Install:
Write your script
AM taking example of expire-date.sh
Convert to executable c binary
## Conver to exe using shc
## Now test
## Execute
Have a fun ... Now remove your C code and sh code .
--Shirish Shukla
Hi many times we required to convert our script to be executable might be any of below reasons .
- We don't want to share our script code
- We want to set suid, guid that we can't do with shell scripts
- Want to run script without any extension as ./script.sh OR sh script.sh etc...
Here an fantastic toll that will hep you to achieve so .
Download & Install
Note: Install proper Linux/Unix flavor rpm and architecture else it will not going to work as expected
Download:
# cat /etc/redhat-release
Red Hat Enterprise Linux ES release 3 (Taroon)
# uname -i
i386
### So have downloaded right rpm for CentOS-6
# wget http://pkgs.repoforge.org/shc/shc-3.8.6-1.el3.rf.i386.rpm
Red Hat Enterprise Linux ES release 3 (Taroon)
# uname -i
i386
### So have downloaded right rpm for CentOS-6
# wget http://pkgs.repoforge.org/shc/shc-3.8.6-1.el3.rf.i386.rpm
Install:
# cd /rpms/shc/
# rpm -ivh shc-3.8.6-1.el3.rf.i386.rpm
warning: shc-3.8.6-1.el3.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:shc ########################################### [100%]
# rpm -ivh shc-3.8.6-1.el3.rf.i386.rpm
warning: shc-3.8.6-1.el3.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:shc ########################################### [100%]
Write your script
AM taking example of expire-date.sh
Convert to executable c binary
# cd /myscripts; ls -lrt expire-date.sh
-rwxr-xr-x 1 root root 599 Mar 20 18:25 expire-date.sh
-rwxr-xr-x 1 root root 599 Mar 20 18:25 expire-date.sh
## Conver to exe using shc
# shc -f expire-date.sh
# gcc -o getexpiredt expire-pwd-date.sh.x.c
# mv getexpiredt /bin/ <<-- As per your requirement
# gcc -o getexpiredt expire-pwd-date.sh.x.c
# mv getexpiredt /bin/ <<-- As per your requirement
## Now test
# file getexpiredt
getexpiredt: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
getexpiredt: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
## Execute
# getexpiredt
Enter Password Date [ DD:MM:YYYY EG: 25:02:2012] Format
DD: 01
MM: 02
YY: 2012
YOUR Password Will Expire on : Tue 1-May-2012
##
Enter Password Date [ DD:MM:YYYY EG: 25:02:2012] Format
DD: 01
MM: 02
YY: 2012
YOUR Password Will Expire on : Tue 1-May-2012
##
Have a fun ... Now remove your C code and sh code .
# rm -fr expire-pwd-date.sh*
--Shirish Shukla
shc is not working for me.Can u suggest some other?
ReplyDeleteWht error you are getting ... !
ReplyDelete