Forum Moderators: coopster

Message Too Old, No Replies

How to login as a root via using php?

         

shaqun

2:08 am on Feb 12, 2007 (gmt 0)

10+ Year Member



Hello,
I hope I will found my question answer. Because I search many website's and still found nothing.

I need login and use root access via using php, I just start make control panel. So Im using system and root shell commands.

How do i gain root access via using php and login as a root using php? I know how to with sudo, but I need to know how to make login as a root is it possible?

Thank you for help.

Psychopsia

5:17 am on Feb 12, 2007 (gmt 0)

10+ Year Member



Hi, welcome to WW!

Is really necesary to use root permission?
What kind of operations or programming are you using that requires root?

Maybe there's another way to do it without using root "high security risk".

mcavic

6:48 am on Feb 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One good way would be to write modules in C to perform specific functions, use setuid to give root permission to the compiled modules, and then have the control panel execute them. But it would take quite a bit of coding to write the modules so that they can't be exploited.

Or you could write a daemon that would run as root, and let the control panel talk to the daemon over a network socket. That wouldn't require any C. But it would take more work to make it secure.

Any other way that I can think of would be very easily exploitable by local users.

shaqun

11:18 pm on Feb 12, 2007 (gmt 0)

10+ Year Member



Hello,
Thank you for answers, Im using Apache2 and php5 its not important i can change it to apache 1.3 with php4 Im working at my home with my local test linux server.

@Psychopsia,
Im working on php, so i need apache requires root or php need.

@mcavic,
Yes what was Im searching for, "write a daemon that would run as root" How do I write a deamon like a cpanel? Im clearly far off from Perl I know cpanel and others doing this with perl is there any best help or how to websites about writing daemon?

Note: If I finish this job, I will provide revolution to all IRC and radio providers, because my program can setup auto IRC and radio with one click on the panel to any customer and there is no need any ssh config file configuration,also after setup program run irc and radio for customer, also my product can start all IRC and Radio services after rebooting server.

- 800 PHP scripts supported ( better then fantastico )
- Repair any service if broken
- Setup and configure firewall & sync, ddos protection systems with one click.

My future is remove SSH world for linux configurations, and start a new world on big control panel like a Windows.

I have been spend 1 year to write this control panel, so i will spend much more for finish it, there is one step left for me, only need root access for php. I know there is a big lost about dont know Perl Language but Any help, i will be realy happy here.

Thank you for help.

shaqun

3:30 pm on Feb 16, 2007 (gmt 0)

10+ Year Member



help please :(

Psychopsia

4:00 pm on Feb 16, 2007 (gmt 0)

10+ Year Member



Did you tried if it works with system [php.net]() or exec [php.net]()?

Romeo

4:44 pm on Feb 16, 2007 (gmt 0)

10+ Year Member



I fear there is no easy answer for this, and whatever you do, you should be fully aware of the imposed security risks and impacts and you should probably carefully re-consider Mcavic's last sentence:
Any other way that I can think of would be very easily exploitable by local users.
... or remote control panel users, or those bad guys from the dark side ... I may add.

A daemon can be programmed in any language. Perl is just one of them. C is another one.

You may have a look at `webmin`, which is a web based server admin tool distributed under a BSD-like licence, to get some further hints on how things could be done.
Perhaps you may use that as framework and just add a new module with your own special functions.

Kind regards,
R.

shaqun

11:45 pm on Feb 16, 2007 (gmt 0)

10+ Year Member



@Psychopsia
Yes Im currently using exec() function. I tested commands under the whm root 2086 its working well. So this is why im searching for root access.

@Romeo
Thank you for information, im going to setup webmin and look. I believe I will spend 1 year for learn perl language.

okay if is there any other way without security risk please let me know. Otherwise Im already start learn perl lang.

Thank you guys.
All the best..

mcavic

6:11 am on Feb 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I wouldn't bother learning Perl, as there's nothing it can do that PHP can't. I used it before I found PHP, and it was very nice at the time, but it would be very confusing for me to go back to it now, because the syntax is quite different. I even use PHP for non-Web applications, daemons, and socket servers.