79814514

Date: 2025-11-08 23:50:17
Score: 2
Natty:
Report link

Related question:

Converted a script (myscript.sh) to executable binary (myscript.sh.x) using shc, executing myscript.sh.x generates the same result as the original script myscript.sh.

856bb1fd13ae:/tmp# shc -f myscript.sh
856bb1fd13ae:/tmp# ls
myscript.sh      myscript.sh.x    myscript.sh.x.c
856bb1fd13ae:/tmp# ./myscript.sh
a test script
856bb1fd13ae:/tmp# ./myscript.sh.x
a test script
856bb1fd13ae:/tmp#

Now, saved the container as docker image, say alpine:shc.

22.04 root:~/alpine_nma_security# docker commit 856bb1fd13ae   alpine:shc
sha256:1f51389fb30af66f017686020375c680ce14a316b7e8728ca60746b0196e6c3f
22.04 root:~/alpine_nma_security# docker image list
REPOSITORY                                          TAG               IMAGE ID       CREATED          SIZE
alpine                                              shc               1f51389fb30a   8 seconds ago    214MB

Now, if I start a container from image alpine:shc, and execute the binary myscript.sh.x, which is saved in the image,

22.04 root:~/alpine_nma_security# docker run -it alpine:shc /bin/bash
0178c235a5b0:/# cd /tmp
0178c235a5b0:/tmp# ls
myscript.sh      myscript.sh.x    myscript.sh.x.c
0178c235a5b0:/tmp# ./myscript.sh
a test script
0178c235a5b0:/tmp# ./myscript.sh.x
./myscript.sh.x: ��H�������f]�c�-c
0178c235a5b0:/tmp#

The shc generated executable binary only works where it's generated?

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Harry Sheng