Sch compile for openwrt

Hello, I am writing a shell command with a basic Hello World for testing
image

saved it as chanrio.sh and it runs fine. I have compiled it using shc (shell script compiler) to encrypt and no one can see the code inside when they open my script.
It compiled successfully but when running ./chanrio.sh.x it is showing syntax error

image

even renaming it to chanrio.sh and running sh chanrio.sh doesnt work
Am I missing any step ?

Can you lead us through whole compile process?

Hello, I have created the sh file in openwrt.

moved the file to my ubuntu VM with sch installed

go to the directory of my chanrio.sh
sch -f chanrio.sh

this will create 3 files
image

I copied the encrypted chanrio.sh.x back to openwrt and run

You have to use openwrt sdk and its c compiler, OpenWRT will not run ubuntu binaries.

1 Like

you need to use the -b option for shc. Its been eons since i played with it but there is a patched version for openwrt that has the -b option. Honestly I cannot even remember what the -b option is ... but i do clearly remember the fight to get it going.

from what i recall, the steps were something to this effect..

download the patched version
compile it for openwrt
create the script or upload it to openwrt
run the shc -b some.sh

the two main points are ...you need the patched version of shc (I just recalled, -b is for busybox) do a search for busybox shc

And the second point is, it must been run in openwrt or against busybox while compiling the script.

This is going back on 10 years ago so you may have to do some digging.

Also, its worth mentioning, shc is just obfuscation, it is not very secure, if the attacker, for lack of better words, knows that shc has been used to compile/encrypt the script, shc can be used to unpack/decrypt the script just the same.

1 Like

This is noted and thanks for the input will take a look onto this