Vaccine: pty.spawn not working/not able to make shell interactive :(

Hi guys, i’m trying to get into pentesting so i’m slowly going through the starting point tutorials, unfortunately I keep getting stuck at seemingly random stages where what i’m doing just doesn’t seem to work like it does in the tutorial.

I am at this stage:
"We got the foothold. We will quickly make our shell fully interactive:

python3 -c 'import pty;pty.spawn("/bin/bash")'
CTRL+Z
stty raw -echo
fg
export TERM=xterm

"
but when I try to run the python command I dont get any kind of shell, and when I fg back to the listener I had open it’s still in raw mode so I cant press return on the “export TERM=xterm” command, if I do CTRL+J to send a return it just does returns me to the normal nc shell:

As u can see from ps the python command is seemingly running. Not sure what to do here, i’d appreciate any suggestions.

Thanks :slight_smile:

No idea why this is the case, but it seems like this bit in the tutorial is written wrong:

image

I found another tutorial online that said to use “stty raw -echo; fg” on one line, this works better and I get a shell with tab completion.

I’d be interested to know why this is the case and if theres a better way to do this, if anyone knows.

Thanks :slight_smile:

It’s very hard to understand, I don’t have the answer, but I can think that the problem is the character for controlling the terminal. Because the stty command, interact with them.

So if you want restore the terminal, you need to type “stty sane”, when the terminal don’t work the backspace you need to type “stty erase ^H” etc. I think with the command “stty raw etc” you lost some special character for controlling you terminal, like “\r” for example.

Try also “stty raw -echo && fg”

1 Like