Good day all, I m trying to implement a web interface that will operate my wireless network.
One of the operations is to configure my card into monitor mode. pretty simple, if you run this command:
bash prepareCard.sh wlan0
ifconfig $IFACE down
iwconfig $IFACE mode monitor
ifconfig $IFACE up
$cmd = shell_exec("bash prepareCard.sh wlan0");
Assuming the webserver user that is running the script does not have sufficient permissions, you can try this way to fix it:
visudo to edit
/etc/sudoers and add this line:
ALL ALL=(root) NOPASSWD: /absolute/path/prepareCard.sh
Make sure to set permissions
700 to the script, so no one else can edit it. Then execute your script with
sudo like this:
$cmd = shell_exec("sudo /absolute/path/prepareCard.sh wlan0");
That should execute the script as root without a need to enter a password.