1

I want to start shellinabox on centos through a php api.

When the user hits the api, shellinaboxd -p 'portno' command should get executed and shellinabox should start on the particular port number.

But this does not happen, instead this error comes Error :

Failed to find any available port [on tail -f /var/log/httpd/error_log] The code below runs correctly on ubuntu but not on centos.
Consider rest all things working fine.

$app->get('/test', function() {
    exec('shellinaboxd -p '.$port);
});

Executing:

shellinaboxd -p 'someport' on bash also works fine.

I have php5.5 and apache2 installed on my system.

Jérémie Bertrand
  • 3,025
  • 3
  • 44
  • 53

2 Answers2

1

Error message Failed to find any available port tells you that port is already used.

Try different port.

Guest
  • 11
  • 1
  • Thanks, but that is not the case, I am generating different port numbers and trying to run shellianbox on those ports. $port variable stores these generated ports (one at a time). These generated ports are free ports(range 4500-4600). I have checked if any service is running on the port generated. – Himanshu Mishra Sep 09 '15 at 03:55
0

I have come out with a solution. Centos is SELINUX(Secured linux). So it does not allow any logging action from a process, like php api(in my case, whose user is apache) in its default mode that is "enforcing".

So change the SELINUX mode as:

'SELINUX=disabled' in /etc/selinux/config

and reboot.

It has one more mode i.e. permissive. Read more about it here: https://wiki.centos.org/HowTos/SELinux