473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

execve problem???

HI there...
I compile the following code(as root) and sets the setuid bit...
as it gives a shell to any user but when the setuid bit is set the
shell should have the privileges of root but in my case it doesn't
have those privileges. I'm using redhat 7.1

#include<stdio.h>
#include<unistd.h>

int main()
{
char *file[2];
file[0]="/bin/sh";
file[1]=NULL;
execve(file[0],file ,NULL);

return 0;
}

Thanks!
Nov 13 '05 #1
3 2793
Java Boy wrote:
HI there...
I compile the following code(as root) and sets the setuid bit...
as it gives a shell to any user but when the setuid bit is set the
shell should have the privileges of root but in my case it doesn't
have those privileges. I'm using redhat 7.1
Unfortunately, this has nothing to do with standard C -- making it off
topic on news:comp.lang.c.

#include<stdio.h>
#include<unistd.h>

int main()
{
char *file[2];
file[0]="/bin/sh";
file[1]=NULL;
execve(file[0],file ,NULL);

return 0;
}


This should be asked in news:comp.os.linux.development.apps.

When you have a question about standard C, come on back (but read the
FAQs first).
HTH,
--ag
--
Artie Gold -- Austin, Texas

Nov 13 '05 #2
In 'comp.lang.c', "Ema" <pa*****@supereva.it> wrote:
Don't know the solution to the problem you posted, but I found following
mistakes:
#include<stdio.h>
#include<unistd.h>
#include <stdlib.h>

int main()
{
char *file[2];


file[0]="/bin/sh"; /* NOOO! */
Why not? How is the 1st parameter of execve() defined? Does it has to point
to a modifiable string?
file[0] = malloc(8);
sprintf(file[0],"/bin/sh");

file[1]=NULL;
execve(file[0],file ,NULL);


If you insist in using malloc(), you also must use free().
return 0;
}


--
-ed- em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #3
On 6 Aug 2003 17:44:50 -0700, Java Boy <ja*****@zapo.net> wrote:
I compile the following code(as root) and sets the setuid bit...
as it gives a shell to any user but when the setuid bit is set the
shell should have the privileges of root but in my case it doesn't


Is the executable owned by root? SUID makes the program run as the
owner of the file, which is not necessarily root.

This probably isn't a good question for comp.lang.c, as it is not a
general C question.
--
-| Bob Hauck
-| To Whom You Are Speaking
-| http://www.haucks.org/
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: goodnamesalltaken | last post by:
Hello fellow python users, I've been working on a basic implementation of a privilege separated web server, and I've goto the point of running a basic cgi script. Basically when the execCGI...
0
by: glmlima | last post by:
I need to implement a prompt of commands (mere academic project). The function presents errors in the call execve, as parameter. It follows the code below. Im using gcc... thanks. #include...
4
by: neojia | last post by:
hi, I am trying to figure out the system call from user space to kernel space. So, I read glibc wrapper first. But I cannot figure out the exact meaning of INTERNAL_SYSCALL for execve system...
2
by: scoobydoo666 | last post by:
Hi I want to execute a command using execve() from my program. Is it possible to get the output redirected to a buffer/file like popen() does? Thanks
1
by: yogamatt1970 | last post by:
I have some code which runs on a number of different machines, however I see problems on one particular Solaris box. When I call Popen.wait(), the following exception is raised: .. . . File...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.