linux


shc 이용 Shell Script를 Binary file로 변환


written by HuscarL



 설명


"shc" 는 스크립트 파일을 바이너리로 바꿔 주는 역할을 합니다.
php encoder 같은 역할을 한다고 보면 됩니다.

쉘 스크립트도 역시 중요한 "root" 패스워드 정보, "DB" 정보 등 공유되거나 유출되면 안 되는 파일들이 존재합니다.

이럴 때 정말 유용하게 사용될 수 있으니, 아직까지 모르셨던 분들 아래 문서 참고하셔서 도움되시길 바랍니다.


-------------------------------------------------------
1. 다운로드 
-------------------------------------------------------

리눅스 내에서 wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9b.tgz 명령어로 다운 받으세요.

-------------------------------------------------------
2. 설치 
-------------------------------------------------------

[root@ns1 local]# tar xvf shc-3.8.9b.tar

shc-3.8.9b/CHANGES

shc-3.8.9b/Copying

shc-3.8.9b/Makefile

shc-3.8.9b/match

shc-3.8.9b/pru.sh

shc-3.8.9b/shc.1

shc-3.8.9b/shc.c

shc-3.8.9b/shc.html

shc-3.8.9b/shc.README

shc-3.8.9b/test.bash

shc-3.8.9b/test.csh


[root@ns1 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/


"shc" 파일은 /usr/local/bin/ 디렉터리에 설치됩니다.


-------------------------------------------------------
3. 테스트 
-------------------------------------------------------
(1) 파일 생성 (__EOF___ 까지 쉘 상태에서 긁어다가 붙이시면 됩니다.)
cat > /root/tmp/script.sh << __EOF__<br/>#!/bin/sh
#------------------------------
# this file is not encrypted
#------------------------------
echo "I love Duane's articles and will send him a donation via PayPal." 
exit 0;
__EOF__


(2) 명령행 실행
[root@ns1 tmp]# shc -f /root/tmp/script.sh
"script.sh.x"라는 바이너리 파일이 생성된다.


(3) 생성된 스크립트 수행
[root@ns1 tmp]# ./script.sh.x 
I love Duane's articles and will send him a donation via PayPal.


-------------------------------------------------------
4. 특이한 기능 
-------------------------------------------------------
[root@ns1 tmp]# shc -e 09/10/2004 -m "Dude it is too late to run this script." -f script.sh
[root@ns1 tmp]# ./script.sh.x 
./script.sh.x: has expired!
Dude it is too late to run this script.

- 쉘 스크립트에 대한 만료일을 지정하여 실행할 수 있습니다.
- 지정된 날짜 이후는 실행되지 아니합니다.
- 위 예는 "2004년 10월 9일"을 스크립트 만료일로 지정하여 만료 후에는 "Dude it is too late to run this script."라는
메시지를 출력하라고 지정한 내용입니다.

-------------------------------------------------------
5. 참고사항 
-------------------------------------------------------
- "shc" 명령어는 스크립트에 대한 C 소스 코드를 생성합니다.
- binary로 파일이 생성되므로 "./파일명" 형태로 실행하여야 합니다.
- 생성된 스크립트 파일은 이름을 변경해도 무관합니다.

-------------------------------------------------------
6. 기본 실행 옵션 설명 
-------------------------------------------------------
(1) -e date
만료일을 지정합니다. (dd/mm/yyyy format)

(2) -m message
만기 시 메시지를 출력합니다.

(3) -f script_name
컴파일할 스크립트 파일을 지정합니다.




 정리 및 출처




방문 해주셔서 감사합니다. 로그인 없이 가능한

아래 하트♥공감 버튼을 꾹 눌러주시면 감사하겠습니다! 



+ Recent posts