Interactive vs Non-Interactive Shells
Differences and how to upgrade non-interactive shells
- Non-interactive shells are limited e.g., you won't be able to backspace, move the arrow keys to retrieve past commands run, or auto-complete commands as you would on an Interactive shell.
1
# Example of a non-interactive shell
2
3
# Running commands
4
$ whoami
5
whoami
6
parrot
7
$
8
9
# Using the up arrow to rerun the last command
10
$ ^[[A
1
# Example of an interactive shell
2
3
# Running commands
4
┌─[parrot@parrot]─[~]
5
└──╼ $whoami
6
parrot
7
┌─[parrot@parrot]─[~]
8
└──╼ $
9
10
# Using the up arrow to rerun the last command
11
┌─[parrot@parrot]─[~]
12
└──╼ $whoami
- Non-interactive shells can be upgraded. Not only is this more convenient but it may also be a requirement when submitting evidence for certain pentesting certifications.
- When you pop a shell on a system it will be non-interactive and before you try to upgrade the shell, you need to see what's installed on it e.g.,
python
,python3
,bash
, etc. as one of those will be a requirement for running the upgrade.
1
# Identifying what's installed, look for other binaries too!
2
$ which python python3 bash zsh
3
/usr/bin/python3
4
/usr/bin/bash
5
1
# Upgrading the shell with python3
2
3
$ python3 -c 'import pty; pty.spawn("/bin/bash")'
4
┌─[parrot@parrot]─[~]
5
└──╼ $whoami
6
parrot
- If upgrading a shell fails it's likely the binary used (
python
, etc.) is not installed or if you copy/pasted the command, the format may have changed e.g.,’
instead of'
like in the example below. - If you're stuck here with the
>
just double check your command and run again or try another way.
1
# Example of a failed shell upgrade
2
3
python3 -c 'import pty; pty.spawn("/bin/bash")’
4
> whoami
5
whoami
1
python -c 'import pty; pty.spawn("/bin/bash")'
2
3
python3 -c 'import pty; pty.spawn("/bin/bash")'
4
5
script -qc /bin/bash /dev/null
6
7
perl -e 'exec "/bin/bash";'
Last modified 7mo ago