How can I compile binary shell script for FreeBSD? I tried the Linux binary emulator but it doesn't work.
There is really no such thing as a binary shell script (script means not binary) - although it is possible to tack an executable binary or a compressed file on the end of a shell script, which usually just contains a tail command to strip the shell script and decompress/preprocess and execute the binary.
If correctly set up the script should include the shell to use (#!/bin/sh would be the traditional unix default), or should use only commands common to all shells. Simple thing is to make it readonly for safety and open it with vi and have a look, and then just execute the payload command(s) on the file yourself (with adjustments as needed - often the point is to set up some environment variables or do some preprocessing, most often including decompression).
shc program is not a real shell compiler. From the manual page:
shc itself is not a compiler such as cc, it rather encodes and encrypts a shell script and generates C source code with the added expiration capability. It then uses the system compiler to compile a stripped binary which behaves exactly like the original script. Upon execution, the compiled binary will decrypt and execute the code with the shell -c option. Unfortunatelly, it will not give you any speed improvement as a real C program would
Some scripting languages like e.g. Python convert scripts into bytecode before executing them. Shells that can be used interactively usually don't, they are just interpreters.
One could even argue that save for some embelishments like variables, loops and other control structures, shells are mostly a front-end for the