You might be able to get the dynamic loader to run an executable for you. Assuming
catis dynamically-linked, your platform's equivalent of/lib/ld-linux.so.2will likely also be in memory and thus usable to run a binary:#$ /lib64/ld-linux-x86-64.so.2 ./chmod chmod: missing operand
If you have a mounted vfat or NTFS filesystem, or another that treats all files as 777, you can create your executable on there.
$ cat > /mnt/windows/chmod < /dev/tcp/localhost/9999If you have a mounted network filesystem, even if it's not locally writable, you can create files on the remote system and use those normally.
If there's a mounted partition you don't care about the contents of, on a drive that is still mostly working, you can replace the contents with a new image of the same filesystem type containing executables you want -
catshould be fine for this in the role people usually useddfor, and you can provide the image over the network.$ cat > /dev/sdb1 < ...
If there is any accessible file that has execute permission on any writable filesystem, you can
cat >into it to replace the contents with a binary of your choosing.$ cat > ~/test.py < ...Since Bash is still running, you could dynamically load a Bash plugin into the process that exposes chmod. In particular, you could install and load
ctypes.sh, which provides a foreign function interface to Bash, and thendlcall chmod ./netcat 511.You could bring in a dynamic library file
foo.soof your construction and then havecatload it on your behalf by way ofLD_PRELOAD, allowing you to execute arbitrary code.$ LD_PRELOAD=./hack.so cat /dev/null