LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 11-08-2013, 02:01 AM   #1
goldengriff
LQ Newbie
 
Registered: Nov 2013
Posts: 14

Rep: Reputation: Disabled
Question run set-uid shell program in ubuntu and set premission 4755


hi dear's,
how i can Run Set-UID shell programs in ubuntu 12.10?
and then, how i can copy /bin/zsh to /tmp, and make it a set-root-uid program with permission 4755????
 
Old 11-08-2013, 02:30 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
a shell script itself is not runnable but executed by an interpreter. Therefore the setuid flag has no any meaning on the script file itself. You need to set it on the interpreter (the real binary executable).
set-root-uid can only be set by root.
 
1 members found this post helpful.
Old 11-08-2013, 02:43 AM   #3
goldengriff
LQ Newbie
 
Registered: Nov 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
a shell script itself is not runnable but executed by an interpreter. Therefore the setuid flag has no any meaning on the script file itself. You need to set it on the interpreter (the real binary executable).
set-root-uid can only be set by root.
how i can set it??
i login as root,
 
Old 11-08-2013, 03:00 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
see man chmod, but you have already wrote: chmod 4755 filename should work.
 
1 members found this post helpful.
Old 11-08-2013, 03:10 AM   #5
goldengriff
LQ Newbie
 
Registered: Nov 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
it's my practice,
2.(2.5 points) Run Set-UID shell programs in Linux, and describe and explain your observations.
a.Login as root, copy /bin/zsh to /tmp, and make it a set-root-uid program with permission 4755. Then login as a normal user, and run /tmp/zsh. Will you get root privilege?
how i can solve it??
whats is ur suggestion??
 
Old 11-08-2013, 03:25 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Will you get root privilege?
What do you need to solve it at all? What is your problem?
What will ls -l /tmp/zsh respond?
 
1 members found this post helpful.
Old 11-08-2013, 03:35 AM   #7
goldengriff
LQ Newbie
 
Registered: Nov 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
is that this solution correct??
when i want set chmod 4755, use below command:
chmode=4755 (it means -r--rwxr-x)
ad for copy /bin/zsh to /tmp, i use blow command:
cp /bin/zsh /tmp
 
Old 11-08-2013, 03:42 AM   #8
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by goldengriff View Post
is that this solution correct??
when i want set chmod 4755, use below command:
chmode=4755 (it means -r--rwxr-x)
ad for copy /bin/zsh to /tmp, i use blow command:
cp /bin/zsh /tmp
first do the cp
then check it with stat

Code:
stat /tmp/zsh
now use the chmod command on /tmp/zsh, and re-check with stat

note any differences
 
1 members found this post helpful.
Old 11-08-2013, 03:49 AM   #9
goldengriff
LQ Newbie
 
Registered: Nov 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
goldengriff-VPCF126FM% cp /bin/zsh /tmp
cp: cannot create regular file `/tmp/zsh': Permission denied
goldengriff-VPCF126FM% su
Password:
root@goldengriff-VPCF126FM:/home/goldengriff# cp /bin/zsh /tmp
cp: cannot create regular file `/tmp/zsh': Text file busy
why??
 
Old 11-08-2013, 04:00 AM   #10
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
looks like you already copied zsh to /tmp/ and you are currently running it

I have no idea how many times you have opened it

if you are doing this in X ( gnome or what ever )
close the terminal and then open a new one
 
1 members found this post helpful.
Old 11-08-2013, 04:23 AM   #11
goldengriff
LQ Newbie
 
Registered: Nov 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
i change chmode with below command:
chmode:5455
and when get the state it's premission not changed??
why??
notice that i close all terminal windows and open new one.
see below command history:
goldengriff-VPCF126FM# /tmp/zsh
goldengriff-VPCF126FM# stat /tmp/zsh
File: `/tmp/zsh'
Size: 688704 Blocks: 1352 IO Block: 4096 regular file
Device: 805h/2053d Inode: 393333 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-11-08 12:44:24.518815236 -0500
Modify: 2013-11-08 12:43:00.826816289 -0500
Change: 2013-11-08 12:43:00.826816289 -0500
Birth: -
goldengriff-VPCF126FM# chmod=4755
goldengriff-VPCF126FM# stat /tmp/zsh
File: `/tmp/zsh'
Size: 688704 Blocks: 1352 IO Block: 4096 regular file
Device: 805h/2053d Inode: 393333 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2013-11-08 12:44:24.518815236 -0500
Modify: 2013-11-08 12:43:00.826816289 -0500
Change: 2013-11-08 12:43:00.826816289 -0500
Birth: -

thanks for ur attention
 
Old 11-08-2013, 04:27 AM   #12
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Code:
echo $chmod
you get 4755

you didn't do anything to /tmp/zsh, you just set a variable

Code:
chmod 4755 /tmp/zsh
please use code tags to make things more readable

[code]
code or output here
[/code]
 
2 members found this post helpful.
Old 11-20-2013, 02:51 AM   #13
goldengriff
LQ Newbie
 
Registered: Nov 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
execute programm

thanks

Last edited by goldengriff; 11-20-2013 at 02:52 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] is executing a set uid program dangerous? dspjm Linux - Software 8 10-03-2011 06:53 AM
Using Set UID to run script as root robo555 Linux - Software 3 11-23-2007 12:05 AM
vfat parition cannot set the files premission to 777. hocheetiong Linux - Newbie 2 09-24-2007 01:14 AM
premission denied to run my c program yoganhyz SUSE / openSUSE 1 03-14-2007 10:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 07:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration