Shell Scripts Encryption

Dear,
Developers, I need help for OpenWRT Shell Scripts Encryption, I am trying to encrypt shell scripts using shc, after I make, its work in all Linux system but when I try in OpenWRT I am getting an error, if anyone has an idea about it please help me. T.I.A

Posting your error would be a good idea.

Use the </> button in the edit toolbar for pre-formatted text

1 Like
files.sh.x: line 1: syntax error: unexpected "("

this is the error I am getting when I try to run ./files.sh.x & also I try to run sh files.sh.x

May I know if the encrypted shell script runs on BusyBox or not? As in https://neurobin.org/projects/softwares/unix/shc/man.html, there's an option to compile the script for BusyBox.

1 Like

Hello rtau Thanks for your replay, no encrypted shell script not running on BusyBox, but raw shell scripts running on BusyBox & also without. before I was used before I encoded by this command

shc -v -r -T -f file.sh and after you said I have downloaded a new version of shc & then I try with this commands shc -U -B -v -f file -o file2 and shc -Bf file -o file2

but by both error report is the same ./file2: line 1: syntax error: unexpected "("
hope you can help me. T.I.A

Silly question, what is the usecase for encrypted shell scripts on a router where everybody that can log in has root? Especially given https://github.com/yanncam/UnSHc? Just curious...

Best Regards

1 Like

From shc manpage, it seems to use C compiler to compile part of the script to machine code, which is, at least, CPU architecture specific. May I know if you have used the compiler for the target, say for MIPS, when invoking shc?

1 Like

No I haven't used, sir is there any other way to encrypt shell scripts? if you can please help me, thanks...

What are you trying to achieve?

I've found it hard to think of an application for "encrypting" a shell script, as it would seem, by definition, that either

  • It is being run by a privileged user that can automatically decrypt it, so any privileged user would be able to decrypt it without significant effort
  • It is being run interactively, so that any "sensitive" content could be entered by the user at that time

_Edit: See for some context and further information https://blog.dbi-services.com/encryption-of-shell-scripts/_

1 Like

i'm solved build SHC in openwrt 19.07.4

SUCCESS
CFLAGS="-fPIC -pthread -mabi=32 -Wa,--noexecstack -Wall -O3 -Os -pipe -mno-branch-likely -mips32r2
-mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable
-Wno-error=unused-result -msoft-float"

ERROR
CC="mips-openwrt-linux-musl-gcc"
CFLAGS="-Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts
-Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16"

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.