Unable to revive interactive reverse shell using Python

300 Views Asked by At

I've been working on the Scriptkiddie box on Hack the Box and have got to the point of upgrading a dumb to interactive shell step using python. The suggested way to do this is the same as the final example here: https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/

However I get to the point of bringing back my shell to the foreground with fg but from that point I'm unable to execute any commands. Pressing enter just displays ^M:

┌──(kali㉿kali)-[~]
└─$ sudo nc -nlvp 443                                                                                                  1 ⨯
listening on [any] 443 ...
connect to [10.10.14.2] from (UNKNOWN) [10.10.10.226] 58996
whoami
kid
python3 -c 'import pty;pty.spawn("/bin/bash")'
kid@scriptkiddie:~/html$ ^Z
zsh: suspended  sudo nc -nlvp 443
                                                                                                                           
┌──(kali㉿kali)-[~]
└─$ stty raw -echo                                                                                               148 ⨯ 1 ⚙
                                                                                                                           
┌──(kali㉿kali)-[~]
                   └─$                                                                                                     fg⚙
[1]  + continued  sudo nc -nlvp 443
                                   reset^M^M

(fg is typed after executing the stty line). Does anyone know what's going on here?

1

There are 1 best solutions below

0
On

Turned out this was because kali doesnt use bash as default, rather zshell. Switching to bash before starting the process prevents this behaviour.