YUMSERV
반응형

shc란 스크립트 내용을 암호화 시켜 실행파일로 만들어줍니다.

shc를 이용해서 스크립트를 다른 사용자가 수정하지못하고, 보지 못하게 하는 목적을 갖고있습니다.



1. shc 다운로드


# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz

# tar xvfz shc-3.8.7.tgz

# cd shc-3.8.7

# make



2. shc 암호화 


shc를 이용해서 암호화 하려면 스크립트 상단에 반드시 #!/bin/bash이 있어야 변환이 가능합니다.

test.sh 라는 스크립트를 하나 만들어주었습니다.


# cat test.sh

#!/bin/bash


touch /root/test1


EX) shc -r -v -T -f 스크립트 파일


# ./shc -r -v -T -f ./test.sh

shc shll=bash

shc [-i]=-c

shc [-x]=exec '%s' "$@"

shc [-l]=

shc opts=

shc: cc  /root/test.sh.x.c -o /root/test.sh.x

shc: strip /root/test.sh.x

shc: chmod go-r /root/test.sh.x


만들어준 test.sh 파일을 암호화 시켰으며, shc 암호한 뒤에는 아래 test.sh.x 와 test.sh.c 파일이 생성됩니다.


# ls -al

-rw-r--r-- 1 root root    31  5월 13 11:09 test.sh

-rwx--x--x 1 root root 11080  5월 13 11:09 test.sh.x

-rw-r--r-- 1 root root  9467  5월 13 11:09 test.sh.x.c


test.sh.x 파일의 경우 바이너리 파일이며, testh.sh.x.c는 C source 파일입니다.

test.sh.x 파일을 확인해보면 바이너리 파일임을 알 수 있습니다.


# file test.sh.x

test.sh.x: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0803f8c4af69869d5ac47a7f327652127282dbd6, stripped


-e 옵션을 이용해서 스크립트 구동가능한 날짜를 제한할 수 있습니다.

# shc -e 20/05/2020 -m "The end" -f 스크립트 파일

이렇게 설정을 해주게 되면, 2020년 5월 20일 이후에 The end 메시지가 출력하게 되면서 구동되지 않습니다.




반응형
profile

YUMSERV

@lena04301

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!