Skip to main content

Identify Restricted Shell

Common restricted shells:

Typical Restrictions

  • Cannot cd
  • Cannot change PATH, SHELL, ENV
  • Cannot use / in commands
  • Cannot redirect output (>, >>)
  • Cannot use exec

Quick Escapes

SSH

Bypass rbash on login:
Force pseudo-terminal with command:

Invoke Unrestricted Shell

If / blocked, use available commands:

Language Interpreters

Python

Perl

Ruby

Lua

PHP

Node.js


Editor Escapes

vi / vim

Or:

ed

nano


Pager Escapes

less

more

man


Program-specific Escapes

awk

find

nmap (old)

ftp

gdb

zip

tar

expect

tee

Write to files even when redirect blocked:

PATH Manipulation

If PATH is restricted but you can set variables:
If export blocked:

Copy Trick

If cp is available:

Environment Variables

BASH_ENV

If BASH_ENV is not cleared:

ENV (for sh)


lshell Escapes

lshell (Python-based limited shell) has known bypasses:

Chroot Escape

If inside chroot jail with root:

Quick Reference