如果你的shell腳本包含了敏感的口令或者其它重要信息, 而且你不希望用戶通過ps -ef(查看系統每個進程的狀態)捕獲敏感信息.
你可以使用shc工具來給shell腳本增加一層額外的安全保護. shc是一個腳本編譯工具, 使用RC4加密算法,
它能夠把shell程序轉換成二進制可執行文件(支持靜態鏈接和動態鏈接).
該工具能夠很好的支持: 需要加密, 解密, 或者通過命令參數傳遞口令的環境.
shc下載鏈接
http://www.datsi.fi.upm.es/%7Efrosal/sources/
shc-3.8.7.tgz shc-3.8.7.tgz(缺一個shc.c)
shc-3.8.7.tgz 按照Makefile 會報錯
*** Running a compiled test script!
*** It must fail showing "./match.x: has expired!"
./match.x
./match.x: has expired!
Please contact your provider
原因是由於它設置來過期時間
直接跳過
make (shc必須在絕對路徑下使用)
make install (直接shc)
注:根據它的Makefile 創建man1目錄來存放shc.1 mkdir -p /usr/local/man/man1/
shc
-e:指定過期時間爲2010年10月20日
-m:過期後打印出的信息;
-v: verbose
-r: 可在相同操作系統的不同主機上執行
-f: 指定源she
1). 加密腳本.
vim hello.sh
echo "Hello world"
# shc -r -v -f hello.sh
-v: 是verbose模式,輸出更詳細編譯日誌. -f: 指定腳本的名稱.
上面命令在屏幕上的輸出:
shc shll=sh
shc [-i]=-c
shc [-x]=exec ‘%s’ “$@”
shc [-l]=
shc opts=
shc: cc hello.sh.x.c -o hello.sh.x
shc: strip hello.x
shc: chmod go-r hello.sh.x
我們可以看到生成了動態鏈接可執行二進制文件hello.sh.x和C源文件hello.x.c, 注意生成的二進制文件因爲是動態鏈接形式, 所以在其它平臺上不能運行:
#file hello.sh.x
hello.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.9, stripped
2). 生成靜態鏈接的二進制可執行文件.
不過, 我們可以通過下面的方法生成一個靜態鏈接的二進制可執行文件:
# CFLAGS=-static shc -r -f hello.sh
# file hello.sh.x
shc -e 03/31/2007 -m “the mysql backup script is now out of date.” -f mysql_back.sh
shc腳本編譯工具
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Gentoo安裝詳解(二)-- 編譯內核
孤逐王
2020-07-01 19:16:07
Gentoo如何配置網絡
leeagle
2020-06-16 15:52:48
gentoo linux install git + redmine
leeagle
2020-06-16 15:52:48
gentoo安裝的點點滴滴(六)
beyondkmp
2020-06-12 18:01:24
Gentoo startx出現Failed to load module問題解決
Sunday
2020-02-24 03:17:13
Gentoo安裝詳解(四)--安裝X桌面環境
孤逐王
2020-02-23 23:19:22
用crossdev安裝mips交叉編譯工具鏈
leeagle
2020-02-23 19:24:13
如何配置gentoo的源
leeagle
2020-02-23 19:24:03
gentoo apache2 啓動失敗解決
leeagle
2020-02-23 19:24:03
Gentoo安裝配置使用nfs
leeagle
2020-02-23 19:24:03
解決gentoo系統無聲音,Alsamixer默認靜音導致的
leeagle
2020-02-23 19:24:03
Gentoo/Arch Linux雜記
iteye_20966
2020-02-23 13:47:01
gentoo安裝skype
beyondkmp
2020-02-23 00:48:01
gentoo xfce桌面fn+f9關閉觸摸板
beyondkmp
2020-02-23 00:48:00
vsftp相關
z_yong_cool
2020-02-22 16:37:31