I am facing an issue when try to obfuscate my script with shc
(installed on Ubuntu 20.04 which running on VMware, the memory size is 4 GB), the original script (test.sh
) size is about 462 KB, after running shc
command as shc -U -f test.sh -o testbin.bin
, I create a new file as testbin.bin
about 600 KB, and I try to run it directly as below:
user@ubuntu:~/Obfuscate_Script$ sudo ./testbin.bin
./testbin.bin: Argument list too long: /bin/bash
I realize the problem encounter is on shc man page
as below:
BUGS
The maximum size of the script that could be executed once compiled is limited by the operating system configuration parameter _SC_ARG_MAX (see sysconf(2))
I try to follow some reference documents such as “Argument list too long”: How do I deal with it, without changing my command? or Increase stack size in Linux with setrlimit, and tried below, first I increase the stack size as unlimited value by ulimit -s unlimited
, and check with getconf ARG_MAX
, it seems works which increase from default value to maximum VMware setting memory as 4 GB
user@ubuntu:~$ getconf ARG_MAX
2097152
user@ubuntu:~$ ulimit -s unlimited
user@ubuntu:~$ getconf ARG_MAX
4611686018427387903
But when I start to generate binary file again as testbin.bin
, now it showing below Warning as:
user@ubuntu:~/Obfuscate_Script$ shc -U -f test.sh -o testbin.bin
shc: WARNING!!
Scripts of length near to (or higher than) the current System limit on
"maximum size of arguments to EXEC", could comprise its binary execution.
In the current System the call sysconf(_SC_ARG_MAX) returns -1 bytes
and your script "test.sh" is 467776 bytes length.
Then I run the testbin.bin
file again, not surprise, it still showing same issue, looks like ulimit -s unlimited
not actually work:
user@ubuntu:~/Obfuscate_Script$ sudo ./testbin.bin
./testbin.bin: Argument list too long: /bin/bash
user@ubuntu:~/Obfuscate_Script$ getconf ARG_MAX
4611686018427387903
I don't know why the Warning message come again since I manually increase stack size to maximum value on Virtual machine already. My Ubuntu 20.04 is running running on VMware 15.5.6 by default setup as 4 GB memory (which i can increase even more, but should not be the root cause), please let me know how to overcome the shc
argument list too long issue, do we need to modify any config file or some settings to resolve that Warning ? thank you !