LITTLEBLACKDOG.COM Forum Index LITTLEBLACKDOG.COM

 
LWD LWD   FAQ FAQ   Memberlist Memberlist   Usergroups Usergroups   Active Topics Active Topics   Register Register  
  Profile Profile   Log in to check your private messages Log in to check your private messages   Log in Log in  
  Who is Online Who is Online   Image Gallery Image Gallery   Chat Chat   Search Search  
  LWDGear       LBDGear  

View next topic
View previous topic
Post new topic     Reply to topic   LITTLEBLACKDOG.COM Forum Index -> Operating Systems » OS - Unix
Author Message
chris_g_g
Cat Chaser
Cat Chaser


Joined: 15 Feb 2001
Posts: 476
Location: United Kingdom

Post Posted: Fri Jul 28, 2006 3:14 am   Post subject: verdict on a false shell Reply with quote Back to top  

On FreeBSD, I'm trying to limit a bunch of remote access users to only the commands I deem suitable. I've a false shell that seems to work fine and want to know what a bunch of clever dogs think!
Bear in mind this will only work for remote logins. Local logins exit instantly.
Code: Select all
#!/bin/sh
[ "$1" = "-c" ] && shift
read CMD PARAMS << eot
$@
eot
case $CMD in
  ls|pwd|whoami)
    $CMD $PARAMS
  ;;
  *)
  ;;
esac

This example only allows 'ls', 'pwd' and 'whoami'. All other commands (hopefully) fail!

Thoughts? Comments? Blaringly obvious security holes that should see me shot at dawn???

_________________
If it moves, its biology.
If it smells, its chemistry.
If it doesn't work, its physics!
View user's profile Send private message
T
Curmudgeon


Joined: 17 May 2001
Posts: 16085
Location: Airstrip One

Post Posted: Fri Jul 28, 2006 5:08 am   Post subject: Reply with quote Back to top  

If you're not letting them run anything except pwd and whoami then ls is superfluous.

_________________
Got questions? Click here.
Still got questions? Click here, too.

affabletoaster, Akely, anglachel, blahpony, CMTG, EdisonRex, Elk, Equin, evilness, Fido, fathertyme, Goddess, Jaymac, je, jodygirl, KingKobra, Lycander, mally, Max, OhioArt2, perrito_blanco, Rover, Spot, sully_51, Superdwarf, the taz man, thriftyjack, twiztid, wrathiron, yiayia49

A journey of 3,500 miles begins with a single comic.

Would you like
good music at a price that is right? CD Baby, baby.

The best way to blow off steam is to blow off someone's nadgers.
View user's profile Send private message Visit poster's website
squashman
Big Dog
Big Dog


Joined: 08 Oct 2001
Posts: 3471
Location: 1265 Lombardi Ave.

Post Posted: Sun Jul 30, 2006 9:30 am   Post subject: Reply with quote Back to top  

Sounds like a good idea. I believe FreeShell does something similar for their free accounts. They are not that restrictive though. My other thought was to do it with Group Permissions or if you are using BASH then use the Restrive Shell option.
View user's profile Send private message Send e-mail
chris_g_g
Cat Chaser
Cat Chaser


Joined: 15 Feb 2001
Posts: 476
Location: United Kingdom

Post Posted: Tue Aug 01, 2006 1:41 am   Post subject: Reply with quote Back to top  

Toxin: Those commands were just in there as examples, they're not what users would be using. The first version of this shell didn't handle spaces so having ls in the list is a handy test with something like ls -l

Squashman: I thought about rbash but my understanding of what I've read is that it's restrictions are not as severe as this approach. I'm taking the attitude that the less a user can do, the less stuff they can break! Will have to check out FreeShell and see what they do/have, thanks for the pointer.


It's only 12 lines of 'code' but I've been staring at it for a while and a fresh set of eyes often sees things the tired ones miss. I'm no wizard script writer and am slightly worried that something so simple seems to do the job so well!!!

_________________
If it moves, its biology.
If it smells, its chemistry.
If it doesn't work, its physics!
View user's profile Send private message
EdisonRex
Lead Dog
Lead Dog


Joined: 06 May 2002
Posts: 10052
Location: Not Moscow

Post Posted: Tue Aug 01, 2006 1:00 pm   Post subject: Reply with quote Back to top  

be careful of what you allow for commands. Anything allowing a copy and directory list allows any sentient hacker to first find the shell ini and to change it. Unless you leave the shell ini somewhere out of reach. Also any command that allows a push into a new shell with arguments would be a bad thing. And don't let people download stuff. First thing I'd download is a script from my full-priv environment, and I'd work on figuring out some way to get a real shell to run it.

*edit* have you tried any pipe commands with that? for instance if ls | more works, then you have a security hole. Because I can probably craft something to get a push out of your script.

_________________
Garret: It's so retro.
EGM: What does retro mean to you?
Parker: Like, old and outdated.
View user's profile Send private message AIM Address Yahoo Messenger
chris_g_g
Cat Chaser
Cat Chaser


Joined: 15 Feb 2001
Posts: 476
Location: United Kingdom

Post Posted: Wed Aug 02, 2006 3:27 am   Post subject: Reply with quote Back to top  

EdisonRex wrote:
*edit* have you tried any pipe commands with that? for instance if ls | more works, then you have a security hole. Because I can probably craft something to get a push out of your script.

I have now... and it fails. Even if ls and more are both in the allowed list, ls just gets upset that 'pipe' isn't a valid argument. Either that or it claims it can't find the file "| more", depending on spaces or not around the pipe.

You bring up some interesting other points too. More food for thought!

_________________
If it moves, its biology.
If it smells, its chemistry.
If it doesn't work, its physics!
View user's profile Send private message
Display posts from previous:   
Post new topic     Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours

Help us keep advertisements off this site. Donate today!