Escaping from Jails
GTFOBins
Search in https://gtfobins.github.io/ if you can execute any binary with "Shell" property
Chroot limitation
From wikipedia: The chroot mechanism is not intended to defend against intentional tampering by privileged (root) users. On most systems, chroot contexts do not stack properly and chrooted programs with sufficient privileges may perform a second chroot to break out.
Therefore, if you are root inside a chroot you can escape creating another chroot. However, in several cases inside the first chroot you won't be able to execute the chroot command, therefore you will need to compile a binary like the following one and run it:
Using python:
Using perl:
Bash Jails
Enumeration
Get info about the jail:
Modify PATH
Check if you can modify the PATH env variable
Using vim
Create script
Check if you can create an executable file with /bin/bash as content
Get bash from SSH
If you are accessing via ssh you can use this trick to execute a bash shell:
Declare
Wget
You can overwrite for example sudoers file
Other tricks
https://fireshellsecurity.team/restricted-linux-shell-escaping-techniques/ https://pen-testing.sans.org/blog/2012/0b6/06/escaping-restricted-linux-shells https://gtfobins.github.io It could also be interesting the page:
Python Jails
Tricks about escaping from python jails in the following page:
Lua Jails
In this page you can find the global functions you have access to inside lua: https://www.gammon.com.au/scripts/doc.php?general=lua_base
Eval with command execution:
Some tricks to call functions of a library without using dots:
Enumerate functions of a library:
Note that every time you execute the previous one liner in a different lua environment the order of the functions change. Therefore if you need to execute one specific function you can perform a brute force attack loading different lua environments and calling the first function of le library:
Get interactive lua shell: If you are inside a limited lua shell you can get a new lua shell (and hopefully unlimited) calling:
Last updated