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
"CTRL + Z"
stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=/bin/bash #Optional
stty size #In attacking shell to check sizing you want
stty rows n columns m #"n" and "m" corresponding to the size we just checkedscript /dev/null -c bash scriptstarts a script session that records every command you do, but we pass the output to/dev/null, thus discarding it, then-callows us to pass a command, in this casebashso it runs the bash shell within that sessionCTRL + ZSends current process to the foreground, returning us to our attacking shellstty raw -echo; fg sttyto change terminal settings,rawto turn on raw mode so input as for exampleCTRL + Cis not interpreted in the attacker terminal and-echoso its not printed toofg"foreground" brings back the process of the victim's terminalreset xtermWrite it even if the prompt is hidden, will reset the terminal to its default state and we are almost finishedexport TERM=xtermEstablishes xterm as the terminal emulator if it isn't alreadyexport SHELL=/bin/bashOptional step but recommended as bash is in almost systems so its compatible and we want everything to be functionalstty sizeIn 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 mSets the victim shell to the same size as our terminal, so binaries likenanolook proportionate
Last updated