473,322 Members | 1,540 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,322 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 2790
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. I´m 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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.