make a password protected bash script resist/refuse “bash -x” when the password is given

旧时模样 提交于 2019-12-13 01:25:26

问题


I want to give my long scripts to customer. The customer must not be able to read the scripts even if he has the password. The following command locks and unlocks the script but the set +x is simply ignored.

The code:

read -p 'Script: ' S &&
  C=$S.crypt \
  H='eval "$((dd if=$0 bs=1 skip=//|gpg -d) 2>/dev/null)";
    exit;' &&
  gpg -c<$S | cat >$C <(echo $H | sed s://:$(echo "$H" | wc -c):) - \
    <(chmod +x $C)

回答1:


Given that it is an interpreted script that at some point must be loaded into memory and interpreted it is impossible to completely avoid anyone being able to dump out the contents of the script. It can easily be achieved i.e. with a wrapper script around the bash executable...



来源:https://stackoverflow.com/questions/20468373/make-a-password-protected-bash-script-resist-refuse-bash-x-when-the-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!