Error in Shell prompt
I have made a script in C which spawns a shell. Here it is
Code:
#include<stdio.h> Code:
chmod +s mycode I dont understand why i am not getting root shell ? According to the definition of SUID, it is Quote:
My OS info Code:
Linux bt 3.2.6 #1 SMP Fri Feb 17 10:40:05 EST 2012 i686 GNU/Linux |
Please try to avoid using machine code instead of proper C-source. It has no advantage, except make you look stupid.
|
I expect bash is starting with ruid of the user but euid of root and in response to this it sets euid=ruid.
setuid(0) in the program before it does the implicit return might get you what you want. In a more realistic/useful setting you'd have a shellcode that starts with setuid(0) to deal with this. Or you could run an interpreter such as perl instead of bash, set the uid in perl and finally exec bash. Obviously we're expecting you not to run these on any systems you don't own. |
1. suid is not honoured by the kernel for 'scripts' ie non-compiled langs eg shell, Perl, Python etc
eg http://www.techrepublic.com/blog/ope...d-to-know/3785 2. as above 'Obviously we're expecting you not to run these on any systems you don't own.' |
Quote:
I got root from your solution. Here is the final code which worked Code:
#include<stdio.h> What is its use ? Thanks |
Quote:
Much more detail at http://www.cs.berkeley.edu/~daw/pape...d-usenix02.pdf in fact it's good to have a look regularly at http://www.cs.berkeley.edu/~daw/papers/ where DAW posts educational stuff. |
Quote:
|
All times are GMT -5. The time now is 07:49 PM. |