Shells/TTYs
Teletypewriters and Shells
TTYs
TTYs
You can use the
rlwrap
utility to enable line editing and history:
In order to have a full
TTY
follow this steps:
BASH
:
BASH
:python3 -c 'import pty; pty.spawn("/bin/bash")'
CTRL+Z
stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset;
ZSH
:
ZSH
:Same first two steps and then:
Use arrow-keys
Use arrow-keys
Use
bash
:
Turn history on:
In the
.bashrc
file, make sureHISTSIZE
is not set to0
:
Clear Terminal
Clear Terminal
Set the environmental variable from the terminal to
xterm
:
Terminal Size
Terminal Size
Before check the size of your terminal outside the remote shell to have a reference:
Now you can set it up as you desired to work more comfortably:
Spawning Shells
Spawning Shells
The
pty
module inPython
allows you to spawn a new process in a pseudo-terminal, effectively creating an interactive shell:
The
script
command starts a shell session and records the session to a file./dev/null
is specified as the file where the session is "recorded", but since it's/dev/null
, no logging actually happens:
Uses
echo
to pass thePython
commandos.system('/bin/bash')
to the Python interpreter:
Spawn an interactive shell directly from the terminal:
The command
exec "/bin/sh"
tells Perl to replace the runningPerl
process with a new/bin/sh
shell:
This is similar to the previous example, but without the
-e
flag used directly from the command line. It representsPerl
code where theexec
function is used to spawn a shell:
Ruby
'sexec
function, like in Perl, replaces the current process with a new process—in this case,/bin/sh
:
Runs a shell command from
Lua
, but unlike inPerl
orRuby
, this does not replace the current process. It runs/bin/sh
as a child process:
Replaces the current
Ruby
interpreter (IRB) with the shell:
Used to execute an external shell command:
Changes the default shell used by vim's
:!
command:
Spawn a shell from within the
nmap
interface, enabling the execution of additional shell commands while scanning:
PSY
PSY
PSY
Shell is an interactivePHP REPL (Read-Eval-Print Loop)
used normally for debugging.
Useful Commands:
Useful Commands:
If there are break line characters like
/n
and you want to get ride of then:
Web Shells
Web Shells
Reverse Shells
Reverse Shells
BASH
Reverse Shells
BASH
Reverse ShellsPython
Reverse Shells
Python
Reverse ShellsOne liners
Create the shell file
PHP
Reverse shell:
PHP
Reverse shell:Fetches and executes a remote reverse shell via
curl
:
Powershell
Reverse shell:
Powershell
Reverse shell:Last updated