1) extrair pasta:
# tar xvf shc-3.8.9.tgz
2) entra no diretorio:
# cd shc-3.8.9
3) Copia arquivo:
# cp shc-3.8.9.c shc
4) compila:
make cc -Wall -O6 -pedantic shc.c -o shc
5) make install
O SHC faz o favor de criar um binário do arquivo shell-script (no nosso exemplo), e de quebra ele te mostra o fonte .c do arquivo binário gerado, além de ter opção para expirar o script entre outros. :)
Download: http://www.datsi.fi.upm.es/~Efrosal/
Instalação:
Descompacte em um diretório, lance o famoso make.
$ make
cc -Wall -O6 -pedantic shc.c -o shc
*** ¿Do you want to probe shc with a test script?
*** Please try... make test
Ele pedirá para executar os testes com um make test.cc -Wall -O6 -pedantic shc.c -o shc
*** ¿Do you want to probe shc with a test script?
*** Please try... make test
Caso obtenha algum erro, não sei se é em todos sistemas, você conseguirá testar com um:
$ ./shc -v -r -f match shc shll=sh shc [-i]=-c shc [-x]=exec '%s' "$@" shc [-l]= shc opts= shc: cc match.x.c -o match.x shc: strip match.xAgora execute o binário
$ ./match.x [22215] PAUSED... Hit return!OK, ta rolando...
Obviamente, usuários Debian, podem naturalmente lançar um #apt-get install shc sem problemas.
Brincando com o shc
Script de teste:#!/bin/bash USER="abc" SENHA="password" echo -e "Ola\n usuario: $USER\n senha:$SENHA" |
proxy:/home/linuxuser# ./teste Ola usuario: abc senha:passwordOk, agora vamos compilar:
Antes disto, veremos algumas opções do shc:
-e %s Expiration date in dd/mm/yyyy format [none]
-m %s Message to display upon expiration ["Please contact your provider"]
-f %s File name of the script to compile
-i %s Inline option for the shell interpreter i.e: -e
-x %s eXec command, as a printf format i.e: exec('%s',@ARGV);
-l %s Last shell option i.e: --
-r Relax security. Make a redistributable binary
-v Verbose compilation
-D Switch ON debug exec calls [OFF]
-T Allow binary to be traceable [no]
-C Display license and exit
-A Display abstract and exit
-h Display help and exit
proxy:/home/linuxuser# shc -r -v -f teste.sh
shc shll=bash
shc [-i]=-c
shc [-x]=exec '%s' "$@"
shc [-l]=
shc opts=
shc: cc teste.sh.x.c -o teste.sh.x
shc: strip teste.sh.x
proxy:/home/linuxuser# ./teste.sh.x
Ola
usuario: abc
senha:password
Excelente!!, caso tenha interesse você pode consultar o arquivo fonte teste.sh.x.cEu fiz os testes em 2 sistemas Debian e um Conectiva, o script funcionou sem problemas.
Detalhe: NÃO NECESSITA TER O SHC INSTALADO NAS OUTRAS MÁQUINAS PARA EXECUTAR O ARQUIVO GERADO.
Compilando um shell com data de expiração ( esta opção achei maravilhosa ):
linuxuser@proxy:~$ shc -v -e 24/06/2006 -m "Contate o desenvolvedor - flaviotorres@linuxmasters.info" -f teste.sh shc shll=bash shc [-i]=-c shc [-x]=exec '%s' "$@" shc [-l]= shc opts= shc: cc teste.sh.x.c -o teste.sh.x shc: strip teste.sh.x linuxuser@proxy:~$ ./teste.sh.x ./teste.sh.x has expired! Contate o desenvolvedor - flaviotorres@linuxmasters.infoBom, é isto, bom proveito.