Upgrade reverse shell to interactive
First things first
When getting a reverse shell, it will most probably be a basic shell that doesn't have TAB auto-completion or gets broken when using CTRL + C
To upgrade to a interactive shell we can do the following:
script /dev/null -c bash script
starts a script session that records every command you do, but we pass the output to/dev/null
, thus discarding it, then-c
allows us to pass a command, in this casebash
so it runs the bash shell within that sessionCTRL + Z
Sends current process to the foreground, returning us to our attacking shellstty raw -echo; fg stty
to change terminal settings,raw
to turn on raw mode so input as for exampleCTRL + C
is not interpreted in the attacker terminal and-echo
so its not printed toofg
"foreground" brings back the process of the victim's terminalreset xterm
Write it even if the prompt is hidden, will reset the terminal to its default state and we are almost finishedexport TERM=xterm
Establishes xterm as the terminal emulator if it isn't alreadyexport SHELL=/bin/bash
Optional step but recommended as bash is in almost systems so its compatible and we want everything to be functionalstty size
In our attacking shell, will print current size of the window in rows and columns so that's what we want to imitatestty rows n columns m
Sets the victim shell to the same size as our terminal, so binaries likenano
look proportionate
Last updated