Reputation: 21
I have a file index.php which has a button that request for another php file named script.php.
This webpage is hosted on my local IIS running Windows server 2012 R2 DTC.
Files location is : c:\inetpub\wwwroot
I have installed PHP. It is running fine.
I am able to get the output if I run this command in powershell console but no response when invoked from webpage I set execution policy unrestricted for both 32 as well as 64 bit powershell but still no help.
index.php
<form id="contact-form" method="post" action="script.php">
<input type="submit" class="button orange" name="submit" value="Check Services">
<form>
script php
<?php
$output=shell_exec('powershell.exe "Get-Service"');
echo $output;
?>
When I run the file index php in browser, I get the following error message.
Get-Service : Cannot open Service Control Manager on computer '.'. This operation might require other privileges. At line:1 char:1 + Get-Service + ~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-Service], InvalidOperatio nException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Power Shell.Commands.GetServiceCommand
For files and error message,ref to link http://cloudbrox.com/o9tj/
Upvotes: 0
Views: 1757
Reputation: 24370
What do you get when you run this code:
<?php
$output=shell_exec('powershell "[Security.Principal.WindowsIdentity]::GetCurrent()"');
echo $output;
?>
Here is a sample of the output I get, make special note of the Name field:
AuthenticationType : NTLM
ImpersonationLevel : None
IsAuthenticated : True
IsGuest : False
IsSystem : False
IsAnonymous : False
Name : SHADOWFAX\Goyuix
Chance are that the account that PHP is using just doesn't have the right permissions to get the list of services running on the local computer. This will help you identify that account and then you can successfully evaluate your options for either changing the account that PHP is using and/or granting the appropriate permissions for that account.
Upvotes: 2