"bin/sh: can't access tty; job control turned off” error when running shellcode"

Just remove /dev/console

cd /dev
rm -f console
ln -s ttyS0 console

edit/change the /etc/inittab content

::askfirst:/bin/sh

to:

ttyS0::askfirst:/bin/sh

If you can change the command of the shell, try:sh +m instead of sh. That worked perfectly for me.


This mean that advanced commands such as Ctrl+Z and Ctrl+C are not available, because sh is not writing to a tty, but to a socket. For this reason, sh will not support background processes (command &) and the associated bg/fg/disown/jobs commands. But note that processes forking themselves and closing their inputs will still work.

You might have noticed that if a background jobs tries to read data from the terminal, the shell stops it (as in, SIGSTOP) and informs you that it has paused the process. If the shell does not do so, you have a race condition and what you write may end up in the background process or in the shell. This makes for an interesting and infuriating mess in your shell session.

Either use a more elaborate shellcode that creates a virtual terminal (but that's not a shellcode anymore once that happens), or just be aware that your ugly hack has limitations.