shell加密工具shc的安裝和使用
1) 工具說明
shell指令碼是可讀寫的, 很有可能會洩露敏感資訊, 如使用者名稱/密碼/路徑/IP等. 同樣在shell指令碼執行時會也洩露敏感資訊. shc是一個加密shell指令碼的工具, 它的作用是把shell指令碼轉換為一個可執行的二進位制檔案. 這就很好的解決了上述問題.
2) 下載安裝
下載: http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.6.tgz
安裝:
# mkdir -p /orahome/wangnc/shc && cd /orahome/wangnc/shc
# rz (上傳安裝包shc-3.8.6.tgz)
# mkdir /usr/local/man/man1/ (install時會把man檔案放入該目錄,如果該目錄不存在需提前建好)
# tar vxf shc-3.8.6.tgz && cd shc-3.8.6
# make test
# make strings
# 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/
用法:
# which shc
/usr/local/bin/shc
# shc
shc parse(-f): No source file specified
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -f script
3) 加密指令碼
# shc -v -f test.sh
-v是verbose模式, 輸出更詳細編譯日誌;
-f 指定指令碼的名稱.
$ ll test*
-rwxr-xr-x 1 oracle oinstall 1178 Aug 18 10:00 test.sh
-rwx--x--x 1 oracle oinstall 8984 Aug 18 18:01 test.sh.x
-rw-r--r-- 1 oracle oinstall 14820 Aug 18 18:01 test.sh.x.c
$ file test.sh.x
test.sh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
可以看到生成了動態連結可執行二進位制檔案test.sh.x和C原始檔testup.sh.x.c, 注意生成的二進位制檔案因為是動態連結形式, 所以在其它平臺上不能執行.
4) 生成靜態連結的二進位制可執行檔案
可以通過下面的方法生成一個靜態連結的二進位制可執行檔案:
$ CFLAGs=-static shc -r -f test.sh
$ file testup.sh.x
5) 通過sch加密後的指令碼檔案很安全嗎?
一般來說是安全的, 不過可以使用gdb和其它的除錯工具獲得最初的原始碼. 如果需要更加安全的方法, 可以考慮使用wzshSDK. 另外shc還可以設定指令碼的執行期限和自定義返回資訊:
$ shc -e 03/31/2007 -m "the mysql backup scrīpt is now out of date." -f test.sh
-e表示指令碼將在2007年3月31日前失效, 並根據-m定義的資訊返回給終端使用者.
--End--
再分享一下我老師大神的人工智慧教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智慧的隊伍中來!https://www.cnblogs.com/captainbed