I know there are other posts about this, but I have tried out all the solutions and fixes that were marked as solution and none of them works for me.
As the title says, I am trying to make a php script execute a bash script when being loaded in a web server (apache).
I am using a wrapper as I saw in another post, so here is the wrapper.c:
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main (int argc, char *argv[]) {
setuid (0);
system ("/bin/sh /var/www/html/scrip/debugport/testversion.sh");
return 0;
}
This is the testversion.sh script:
#!/bin/bash
screen -S skywars -X stuff "stop
"
cd /tmp
pid=$(fuser -n tcp 12321 | awk '{print $1}')
kill -9 $pid
And this is the php code that I am using:
<?php
$message=shell_exec("./var/www/html/scrip/php_root");
print_r($message);
?>
When I do ./php_root (which is the compiled wrapper.c) everything works fine, but when I try to load it from a web server the script doesn't work at all.
It's probably something to do with the permissions, but I used every permission exactly like in this post's solution: Execute root commands via PHP
The wrapper is supposed to make the script be executed as root no matter what user executes it, but it doesn't work.
Thanks guys.