Page cover
githubEdit

book-skullShells/TTYs

chevron-rightTeletypewriters hashtag
circle-info

Get a Full TTY

BASH

  1. python3 -c 'import pty; pty.spawn("/bin/bash")'

  2. CTRL+Z

  3. stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset;

ZSH

  1. python3 -c 'import pty; pty.spawn("/bin/bash")'

  2. CTRL+Z

  3. stty raw -echo; fg %1; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset;

circle-info

Clear Terminal

Change the env to xterm
export TERM=xterm
circle-info

Terminal Size

Check your terminal size
stty size
Now, change it in the target
stty rows <NUMBER> columns <NUMBER>
circle-info

Use arrow-keys

Just use it
bash
Turn history on
set -o history
  • In the .bashrc file, make sure HISTSIZE is not set to 0:

HISTSIZE=1000
HISTFILESIZE=1000
circle-info

rlwrap enables line editing and history:

Listener example
rlwrap nc -lvnp <port>
Connection example
rlwrap nc 10.10.10.131 6200
chevron-rightSpawning Shellshashtag
circle-info

The pty module in Python allows you to spawn a new process in a pseudo-terminal, effectively creating an interactive shell:

circle-info

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:

circle-info

Also is possible to use echo to pass Python os.system('/bin/bash') to the Python interpreter:

circle-info

Spawn an interactive shell directly from the terminal:

circle-info

The command exec "/bin/sh" replaces the running Perl process with a new /bin/sh shell:

circle-info

Ruby's exec function, like in Perl, replaces the current process with a new process—in this case, /bin/sh:

circle-info

Runs a shell command from Lua, but unlike in Perl or Ruby, this does not replace the current process. It runs /bin/sh as a child process:

circle-info

Replaces the current Ruby interpreter (IRB) with the shell:

circle-info

Used to execute an external shell command:

circle-info

Changes the default shell used by vim's :! command:

circle-info

Spawn a shell from within the nmap interface, enabling the execution of additional shell commands while scanning:

chevron-rightPSYhashtag

PSY Shell is an interactive PHP REPL (Read-Eval-Print Loop) used normally for debugging.

chevron-rightWeb Shellshashtag
chevron-rightBASH Reverse Shellshashtag
circle-info

FIFO

chevron-rightPython Reverse Shellshashtag
circle-info

Interactive / PTY Shell

circle-info

Dumb Shell using subprocess

chevron-rightPHP Reverse shellhashtag
chevron-rightPowershell Reverse shellhashtag
chevron-rightNode-Red Reverse shellhashtag
  • Once you received the connection use another listener you get a more stable shell:

  • Then use script:

chevron-rightBind Shellshashtag
circle-info
  • First, find ports were inbound connections are allowed:

circle-info

Check the firewall rules in Windows:

Last updated