We help IT Professionals succeed at work.

executable binary to shell script

How to convert executable binary to shell script
Comment
Watch Question

Scott SilvaNetwork Administrator

Commented:
It can be done, in a fashion... You basically uuencode the binary and embed the encoded text at the end of the script. Then the script has to uudecode that text back into a binary...  

https://stackoverflow.com/questions/10491704/embed-a-executable-binary-in-a-shell-script#10491738
Or do you mean that you have an exexutable binary, and you want to replace it with a shell script? If so, the answer is probably no, unless you know exactly what the binary does, and what it does is replaceable by a series of linux commands.

If you want help with this, you'll have to provide a _lot_ more information about the binary.
> unless you know exactly what the binary does
i.e. by Reverse Engineering it.

If you have the source code, you might be able to rewrite that as a shell script. But more likely you would just tweak the source to do what you want.

You could also use a wrapper script, e.g.
cat /usr/bin/find.sh
echo "Usage: sudo find.sh [options] [path...] [expression]"
echo "Pass safe parameters to 'find' to be executed as root"
echo "Note, unsafe Actions in 'find' such as -remove and -exec are not passed"
echo "Special characters like double or single quotes might not work"
# sed is inefficient compared to shell Parameter Expansion, but simple and portable
PASSPARS=`echo $@ | sed -e 's/-remove[ $]//g'`
find ${PASSPARS}

Open in new window

Scott SilvaNetwork Administrator

Commented:
Funny that the accepted solution isn't what the question was...
Mine actually converts a binary to a shell script...
But whatever...
Doubly amusing, as the scriptlet I posted was the answer I needed, rather than the answer to the question I'd asked in
https://www.experts-exchange.com/questions/29058111/Linux-Unix-read-only-root-role.html