How to make shell_exec run on IIS 6.0

Problem

I have a PHP script that uses shell_execpdf-to-text converter to run the converter. To simplify the task, I created a short script that uses shell_execto simply echo the output of the command dir.

<?php
$cmd = 'C:\\WINDOWS\\system32\\cmd.exe /c ';
echo shell_exec($cmd.' dir');
?>

When I run this on my Apache server, everything works as expected. When I switch to IIS, it seems to be completely overlooked: no errors, no output, no logs, nothing.

Unfortunately, I need to use IIS because I'm going to authenticate my users against the active directory.


Here is what I have tried so far:

  • Run the command with cmd.exe /c, rather than issue it directly
  • Grant Read & Executepermission SERVICEto "C: \ WINDOWS \ system32 \ cmd.exe"
  • Grant Read & Executepermission NETWORK SERVICEto "C: \ WINDOWS \ system32 \ cmd.exe"
  • Grant Read & Executepermission IUSR_MACHINENAMEto "C: \ WINDOWS \ system32 \ cmd.exe"
  • Grant Read & Executepermission Everyoneto "C: \ WINDOWS \ system32 \ cmd.exe" (don’t worry, it didn’t stay that long, haha)
  • Run PHP as an ASAPI Module
    • This is my standard configuration.
  • Run PHP as a CGI Extension
    • This does not work, I get an error: CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.
  • In IIS, set Execute Permissionsto Scripts and Executableson its website
  • Added html markup function and other php functions for the script to find out if it is being processed; it does. It's like a bit is shell_execjust skipped.

Thank you so much for looking at this question, now I am pulling my hair out with a problem

Cheers, Ian


Update 1

, , , Apache - ( shell_exec), apache script cURL. , :).


2

, IIS , , , , , , . ?

+3
6

,

, C:\WINDOWS\SYSTEM32 ( % systemroot%\system32)

cmd.exe  
whoami.exe  

ACL

c:\windows\system32> cacls cmd.exe  
c:\windows\system32> cacls whoami.exe  

"Everyone" Read (R), TEMPORARILY

c:\windows\system32> cacls cmd.exe /E /G everyone:R  
c:\windows\system32> cacls whoami.exe /E /G everyone:R  

whoami.php

<?php  
$output = shell_exec("whoami");  
echo "<pre>$output</pre>";  
?>  

whoami.php - , .

ct29296\iusr_template

"",

c:\windows\system32> cacls cmd.exe /E /R everyone  
c:\windows\system32> cacls whoami.exe /E /R everyone  

, 5, Read + Execute (R) cmd.exe

c:\windows\system32> cacls cmd.exe /E /G ct29296\iusr_template:R  

.

: http://www.myfaqbase.com/index.php?q=php+shell_exec&ul=0&show=f

+3

:

. , PHP .

, PHP Windows. , , , - PHP FastCGI ( , , , ). Microsoft IIS.


  • , PHP Windows Active Directory - , !

Apache LDAP mod_auth_ldap. PHP LDAP :

Active Directory - LDAP. , LDAP Active Directory.

P.S. Apache mod_auth_ldap PHP LDAP- - . Apache mod_auth_ldap HTTP, PHP LDAP .

+2

.exe , proc_open() $other_options = array ('bypass_shell' = > TRUE)

, procmon.exe(sysinternals) - , .

+1

Read & Execute , IIS ( IUSR_MACHINENAME)

0

, IIS, .

IIS . , Apache. , MS-Windows.

Google, .

, IIS , NTLM, . IIS NTLM MSIE. . !

.

0

NETWORK SERVICE READ EXECUTE, READ , . , . , READ EXECUTE, READ IUSR_ cmd.exe.

, http://forums.iis.net/t/1147892.aspx

0

Source: https://habr.com/ru/post/1733476/


All Articles