githubEdit

Escaping Restricted Shells

Restricted shells (rbash, rksh, rzsh) limit user capabilities to restrict command execution, script access, and system navigation. These are often implemented for security in shared environments.

Common Techniques to Escape

1. Command Substitution

ls -l `whoami`

Executes allowed command via backticks or $(command).

2. Command Chaining

ls; whoami; id

Executes multiple commands if separators like ;, &&, or || are allowed.

3. Command Injection

Inject commands where user input is executed by the shell.

Example:

command `id`

4. PATH Hijacking

Override the PATH variable to run your own scripts in place of allowed commands.

5. Using Interactive Programs

Escape via built-in programs like:

6. Scripting Languages

Spawn a new unrestricted shell using:

7. Script Files

Create executable script to escape:


Last updated