All Questions
22 questions
0
votes
2
answers
174
views
I lose permission every day at midnight
I require a file at the top of my PHP scripts. The file just has connection object for MySQL:
$c->new mysqli('host','usr','pass','db')
The file has 400 permission: -r--------
and I keep it in /etc/...
0
votes
1
answer
5k
views
Run root script from www-data user
I have a problem to run a command that requires root privileges via php on the apache server
I added a command to sudoers so that it does not require a password for the user
visudo:
#
# This file ...
0
votes
1
answer
341
views
what is the safe/secure way to execute commands from website?
I'm working on a website from which some services are generated and need to be placed on the system folder, and those services might also need to start/stop using the systemctl command.
Both commands ...
0
votes
1
answer
5k
views
Execute an shell script with sudo inside from php
I want to execute a command line command as root from a php file. In my case I want to view the crontab file in my php page.
Running the sudo command in php is not recommended and on my raspberry pi ...
0
votes
2
answers
1k
views
How do i make a program run with elevated privileges but not as root?
I am testing CTF like thing in my laptop and i have option to upload a PHP file which when executed grants shell to uploader, (reverse shell), however there is a problem. When i do
su - www-data
cd /...
0
votes
1
answer
651
views
“sudo ls -a1 /home” Permission Denied
I have a php script that will run exec("bash /path/to/list.sh $dir", $out);
The contents of list.sh are...
#!/bin/bash
sudo /usr/bin/ls -a1 $@ 2>&1
I have given apache permission to run ls ...
0
votes
0
answers
163
views
Mount does not work in script when run by php
So I have a script that's placed in my apache2 html folder and should be executed by an http post. The script requires root (I know that's not safe at all, ignore that please), so I set the user www-...
0
votes
0
answers
1k
views
PHP shell_exec to run debian system service
I'm trying to control a system service with PHP's shell_exec function :
shell_exec('sudo /usr/sbin/service icecast2 stop');
But the only way I can get it to work is by allowing ALL users root access ...
0
votes
1
answer
1k
views
unable to run command as sudo in php (CentOS 7)
I need to run a sudo command from a PHP script in CentOS 7, but I am getting an error:
sudo: no tty present and no askpass program specified
I have edited my sudoers file with the following lines, ...
0
votes
0
answers
565
views
Workaround for running privileged commands from www-data user
I would like to append a string to a file located in /tmp/ from a php script. The command I would like to execute is:
sudo sed -e 's/$/,yes/' -i /tmp/a.csv
The Problem
I can't run a sudo command ...
0
votes
1
answer
5k
views
Running SSH command from PHP gives sudo: no tty present and no askpass program specified error even though NOPASSWD settings are done
I am using LAMPP to run apache server. From a php file I am executing a python script which executes ssh, scp commands. But I am getting error:
sudo: no tty present and no askpass program specified
I ...
1
vote
1
answer
1k
views
Restart PHP-FPM from a PHP script
I am running a LEMP stack and wish to write a simple control panel for it.
So, I want to be able to restart php-fpm from a php script. To achieve this, this is what I did.
Created a binary wrapper ...
0
votes
1
answer
98
views
Security concerns
I've recently been struggling with ways to make a easy way for my father to both mount and unmount a harddrive on a linux based system. I thought of a way to execute a shell script with PHP. The ...
2
votes
1
answer
776
views
mdadm inconsistencies when run programmatically
Update #1:
I just gave an extra layer of testing, writing a shell script (.sh, #!/bin/bash) and a php script to be executed by php's cli.
Bash works.
It seems that it's not the Apache's HTTP ...
2
votes
0
answers
720
views
PHP exec and amixer
I'm trying to make php lower the dB level of amixer using exec, but it seems like php isn't able to perform the task which requires sudo-access. What should be the best way to solve this?
I tried:
...