"bin/sh: can't access tty; job control turned off” error when running shellcode"
Solution 1
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
Solution 2
If you can change the command of the shell, try:sh +m
instead of sh
. That worked perfectly for me.
Solution 3
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.
Related videos on Youtube
Nosrettap
I recently graduated from Duke University as a computer science and economics double major. I am now working full time as a software developer. I am proficient in Objective-C and Java, and I know (to some degree) C, C++, Python, Perl, SML, Assembly, HTML, CSS, JavaScript.
Updated on September 18, 2022Comments
-
Nosrettap almost 2 years
I'm writing shellcode to exploit a buffer overflow vulnerability on a server. To do so I have port binding shellcode that I send to the server and then I run (from a linux terminal) the command telnet serverAdress 4444 where 4444 is the port which I have opened up. The hope is that I will receive a shell back that I can use to execute commands. However, I always end up with the command
bin/sh: can't access tty; job control turned off
I can't change any of the server code, and I believe the shellcode is correct because I got it from this website (http://www.tsirogiannis.com/exploits-vulnerabilities-videos-papers-shellcode/linuxx86-port-binding-shellcode-xor-encoded-152-bytes/). From my research, it appears that this may have to do with the mode that my terminal is running in (something called interactive mode...or something like that).
All computers involved are linux machines and the machine that I am on is running the latest version of Ubuntu.
Any ideas what this job control error means and how I can fix it?
-
Admin over 4 yearsPossible reason is explained in the below thread, stackoverflow.com/questions/36529881/…
-
-
Jon Bringhurst over 11 yearsWhy does this work?
-
not2qubit about 10 yearsProbably because the console is not allowed by the shell to be a
controlling
terminal. But I have no idea why that is. -
MycrofD about 9 yearsHow to make the edit "::askfirst:/bin/sh" to "ttyS0::askfirst:/bin/sh". What commands should be given ? Bcoz it says "/bin/sh: ::askfirst:/bin/sh: not found"
-
Archemar about 8 yearsI failt to see how this can have any relation with question.
-
Mila Nautikus about 2 yearsthis will disable job control completely, and only remove the initial warning
job control turned off