@princeade said:
guy, nicely put , i once was looking for how to nano a file though a shell not ssh… had to finally echo my code into the file on the PWK labs…
question: Does this work for all reverse shell gotten through other means like (php, perl and python) or only nc shells?
The majority of connect back shells should work fine. I meant nc as the listening service on the local machine. Refer to the netsec.ws link that @sajkox posted to see other options.
I’ve tried the above method few times, but it failed every time. I don’t understand what am I doing wrong…
After doing fg, Enter key is displayed as ^M
Something like this:
I came across this while trying to solve similar issues, might help others. There are few additional commands to what is listed in first post.
• On the remote machine, run python -c ‘import pty; pty.spawn(“bash”)’ and press CTRL-z to put the SSH session to the background.
• Then run stty -a to print out information about your shell. Note the rows and columns (say they are 40 and 160 respectively).
• Now run stty raw -echo to put your shell into raw mode, then fg to get back into the SSH session, and finally reset to reset the shell. It you get asked for the type of the terminal, use xterm-256color.
• After that, run stty rows 40 columns 160 to specify the correct size. You should now have a fully working shell, in particular vi should work.