bypassing-restricted-shells

Escapes restricted shells, chroot jails, and command filters during authorized penetration tests.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill bypassing-restricted-shells
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bypassing-restricted-shells
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/linux-hardening/bypassing-restricted-shells
Command: npx skills add https://github.com/xalgord/xalgorix --skill bypassing-restricted-shells

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

During authorized penetration tests, landing in a restricted shell (rbash, rksh, lshell), a chroot jail, or a filtered command-injection point often stalls the assessment. This Skill provides a systematic escape matrix so testers can determine whether the confinement actually holds or can be broken to obtain arbitrary command execution.

Core Features & Use Cases

  • GTFOBins Shell-Outs: Abuse allowed binaries (vi, less, awk, find, perl, python) that expose shell functions to spawn /bin/sh from inside a restricted shell.
  • Chroot and Sandbox Escapes: Break out of chroot jails when root inside the jail (double-chroot technique, break_chroot.c) and escape Lua/Python language sandboxes via load(string.char(...)) or debug.debug().
  • Filter and Bad-Character Bypasses: Defeat space/keyword filters using ${IFS}, brace expansion, quote insertion, wildcards, and base64/hex/tr/rev encoding.
  • Use Case: A tester lands in rbash on a jump host where vi is permitted; using :set shell=/bin/sh then :shell, they obtain an unrestricted shell and document the finding with proof and remediation advice.

Quick Start

Use the bypassing-restricted-shells skill to enumerate my current rbash session and identify viable escape techniques with confirmation commands.

Frequently Asked Questions about bypassing-restricted-shells

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I escape an rbash restricted shell?

Escape rbash by shelling out from any allowed binary with a GTFOBins Shell function, such as `:set shell=/bin/sh` then `:shell` in vi, or `awk 'BEGIN {system("/bin/sh")}'`. Builtins like `declare -n PATH; export PATH=/bin; bash -i` also work when PATH assignment is blocked.

How to break out of a chroot jail as root?

Chroot does not defend against privileged users. Compile and run a double-chroot program: mkdir a directory, chroot into it while your CWD stays outside, chdir("..") repeatedly, then chroot(".") to anchor at the real filesystem root and exec a shell.

How do I bypass space filters in command injection?

Replace spaces with ${IFS} or $IFS, for example `cat${IFS}/etc/passwd`, or use brace expansion like `{cat,/etc/passwd}`. For blocked keywords, insert quotes or backslashes, use wildcards like /usr/bin/who*mi, or encode the command with base64, hex, tr, or rev.

Can SSH bypass a restricted shell before it starts?

Yes. The restricted shell only applies after a normal login, so the SSH command channel runs before it. Commands like `ssh -t user@host bash` or `ssh user@host -t "bash --noprofile -i"` can return an unrestricted interactive shell.

When does a chroot escape not work?

Chroot escapes require root privileges inside the jail; an unprivileged process cannot call chroot or mount. If the service drops privileges, uses pivot_root with namespace isolation, or combines chroot with seccomp, these techniques will fail.