shell加密工具shc的安裝和使用

2021-08-31 01:44:54 字數 2035 閱讀 7384

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!

1) 工具說明

shell指令碼是可讀寫的, 很有可能會洩露敏感資訊, 如使用者名稱/密碼/路徑/ip等. 同樣在shell指令碼執行時會也洩露敏感資訊. shc是乙個加密shell指令碼的工具, 它的作用是把shell指令碼轉換為乙個可執行的二進位制檔案. 這就很好的解決了上述問題.

安裝:# 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表示指令碼將在2023年3月31日前失效, 並根據-m定義的資訊返回給終端使用者.

--end--           

給我老師的人工智慧教程打call!

Shell 指令碼加密工具 shc

為什麼要加密shell指令碼呢?當然是為了安全!可能指令碼裡面涉及到密碼之類的就需要進行加密了 要保護自己編寫的shell指令碼程式,方法有很多,最簡單的方法有兩種 1 加密 2 設定過期時間,下面以shc工具為例說明 shc是乙個加密shell指令碼的工具.它的作用是把shell指令碼轉換為乙個可...

shell加密工具shc的安裝和使用

1 工具說明 shell指令碼是可讀寫的,很有可能會洩露敏感資訊,如使用者名稱 密碼 路徑 ip等.同樣在shell指令碼執行時會也洩露敏感資訊.shc是乙個加密shell指令碼的工具 它的作用是把shell指令碼轉換為乙個可執行的二進位制檔案.這就很好的解決了上述問題.安裝 mkdir p ora...

shc加密shell指令碼

1.加壓shc 3.8.9b.tgz tar xzvf shc 3.8.9b.tgz cd shc 3.8.9b 2.建立幫助文件目錄 mkdir p usr local man man1 3.安裝 make install 4.安裝完,加密test.sh shc r t f test.sh 如果要...