Wednesday, July 9, 2008

restricted shell

this is what i have read in the book ubuntu linux unleashed,

if you have a desire to severly restrict what a user can do, you can provide him with a restricted shell. to run a restricted bash shell, you would use the -r option

ex:- bash -r

then try to do something that you could do as a regular user, such as ls -a,

you will then see

bash: ls: no such file or directory

now my question is suppose i have my shell restricted, how to make it back un restricted ?


stachu dozzie

You can't. But you can search for a program, which can execute other programs. If you can't find out the rest, then you don't deserve unrestricted shell.


Lew pitcher

Assuming that you started the restricted shell from within the shell
bash -r
then all you have to do is exit to get back to your original shell


pk

I guess that if you'd be able to do that, then it would not be a "restricted" shell anymore.
However, according to the man page, if you are able to run a shell script using a command that does not contain "/", then the shell that runs that script is unrestricted. This can probably be exploited to somehow "escape" from the restrictions.

If you don't use the restricted shell as a login shell, just type "exit" to get back to the parent (unrestricted) shell.(btw, "ls -a" works fine for me even in a restricted shell)


pk

pk wrote:

>> now my question is suppose i have my shell restricted, how to make it
>> back un restricted ?

> I guess that if you'd be able to do that, then it would not be
> a "restricted" shell anymore.

Ok, it's actually very easy. Just edit your .bashrc or .bash_profile, and put "/bin/bash" in it. Logout, login, and you have an unrestricted shell. It's that simple. I suppose that, if the administrator wants to protect against that, he'll have to assign rbash with --noprofile and/or --norc as the user's shell.


Maxwell lol

There are ways to escape from sandboxes. the restricted shell is the
easiest to escape from.

For instance, start vi, and then execute a new shell from inside.


Mr C

If you changed your own shell to restricted, and have no access to another account in which to become root, you'll have to boot from a livecd / rescue CD to change it back. Since the restricted shell prevents you from specifing any command with a / in the pathname, and you can't change your PATH, you are stuck.


simon apnic

I don't advise you to use restricted bash shells..There are better choices like chroot, jail shells and others.And definitely you shouldn't do it to yourself, especially if you're using the root account (which many security experts don't recommend).

No comments:

Post a Comment