TTY shells

Spawn shells

  • Python: python -c 'import pty; pty.spawn("/bin/sh")'

  • Bash: echo os.system('/bin/bash')

  • Bash: /bin/sh -i

  • Bash: script -qc /bin/bash /dev/null

  • Perl: perl -e 'exec "/bin/sh";'

  • Perl: exec "/bin/sh";

  • Ruby: exec "/bin/sh"

  • Lua: os.execute('/bin/sh')

  • IRB: exec "/bin/sh"

  • vi: :!bash

  • vi: :set shell=/bin/bash:shell

  • Nmap: !sh

No TTY

If you cannot obtain a full TTY, you can still interact with programs that expect user input. In the following example, the password is passed to sudo read a file:

expect -c 'spawn sudo -S cat "/root/root.txt";expect "*password*";send "<THE_PASSWORD_OF_THE_USER>";send "\r\n";interact'

Last updated