Shell脚本转换成二进制加密、
1、我们需要对IP地址、账号密码进行简单保密。
2、下载安装shc-3.8.9.tgz
wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9b.tgz
[root@VM-20-2-centos soft]# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9b.tgz
--2022-01-13 14:03:40-- http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9b.tgz
Resolving www.datsi.fi.upm.es (www.datsi.fi.upm.es)... 138.100.9.22
Connecting to www.datsi.fi.upm.es (www.datsi.fi.upm.es)|138.100.9.22|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20687 (20K) [application/x-gzip]
Saving to: ‘shc-3.8.9b.tgz’
100%[=====================================================>] 20,687 81.9KB/s in 0.2s
2022-01-13 14:03:41 (81.9 KB/s) - ‘shc-3.8.9b.tgz’ saved [20687/20687]
[root@VM-20-2-centos soft]#
3、解压shc-3.8.9b.tgz
[root@VM-20-2-centos soft]# tar zxvf shc-3.8.9b.tgz
shc-3.8.9b/CHANGES
shc-3.8.9b/Copying
shc-3.8.9b/match
shc-3.8.9b/pru.sh
shc-3.8.9b/shc-3.8.9b.c
shc-3.8.9b/shc.c
shc-3.8.9b/shc.1
shc-3.8.9b/shc.README
shc-3.8.9b/shc.html
shc-3.8.9b/test.bash
shc-3.8.9b/test.csh
shc-3.8.9b/test.ksh
shc-3.8.9b/makefile
shc-3.8.9b/testit
[root@VM-20-2-centos soft]#
4、编译安装
[root@VM-20-2-centos shc-3.8.9b]# make
cc -Wall shc.c -o shc
*** ¿Do you want to probe shc with a test script?
*** Please try... make test
[root@VM-20-2-centos shc-3.8.9b]# make install
*** Installing shc and shc.1 on /usr/local
*** ¿Do you want to continue? y
install -c -s shc /usr/local/bin/
install -c -m 644 shc.1 /usr/local/man/man1/
install: target ‘/usr/local/man/man1/’ is not a directory: No such file or directory
make: *** [install] Error 1
[root@VM-20-2-centos shc-3.8.9b]#
备注:最开始在虚拟机上测试时,报错
[root@localhost shc-3.8.9b]# make install
cc -Wall shc.c -o shc
make: cc:命令未找到
make: *** [shc] 错误 127
原因是没有安装gcc
yum -y install gcc automake autoconf libtool make
#执行这个安装就行
5、简单测试功能
[root@VM-20-2-centos ~]# mkdir scripts
[root@VM-20-2-centos ~]# cd scripts/
[root@VM-20-2-centos scripts]# ls
[root@VM-20-2-centos scripts]# vim hello.sh
[root@VM-20-2-centos scripts]# ls
hello.sh
[root@VM-20-2-centos scripts]# chmod +x hello.sh
[root@VM-20-2-centos scripts]# ./hello.sh
Hello,World!
[root@VM-20-2-centos scripts]# shc -r -f hello.sh
[root@VM-20-2-centos scripts]# ll
total 28
-rwxr-xr-x 1 root root 32 Jan 13 14:11 hello.sh
-rwx--x--x 1 root root 11232 Jan 13 14:11 hello.sh.x
-rw-r--r-- 1 root root 9401 Jan 13 14:11 hello.sh.x.c
[root@VM-20-2-centos scripts]# mv hello.sh.x hello.sh
mv: overwrite ‘hello.sh’? n
[root@VM-20-2-centos scripts]# mv hello.sh.x hello
[root@VM-20-2-centos scripts]# ls
hello hello.sh hello.sh.x.c
[root@VM-20-2-centos scripts]# ./hello
Hello,World!
[root@VM-20-2-centos scripts]#
总结:最后的hello.sh.x 就是二进制文件,hello.sh.x.c是改写的c语言。这个并不绝对保密。简单保密符合要求。更高级别的保密达不到。