Connecting Tech Pros Worldwide Help | Site Map

Windows registry access in PHP webpage possible?

  #1  
Old January 27th, 2006, 05:45 PM
Boris
Guest
 
Posts: n/a
Has anyone ever managed to read a Windows registry key in a PHP webpage? I
installed the PHP extension win32std and saved their sample script from
http://wildphp.free.fr/wiki/doku.php...egistry_access as a
webpage. However when I open the webpage (PHP 5.1.2, Windows Server 2003,
IIS 6) I get the error message "Warning: Can't open registry key: The
operation completed successfully." Is registry access only possible in
Windows executables?

Boris


  #2  
Old January 27th, 2006, 10:35 PM
Alvaro G. Vicario
Guest
 
Posts: n/a

re: Windows registry access in PHP webpage possible?


*** Boris escribió/wrote (Fri, 27 Jan 2006 18:32:36 +0100):[color=blue]
> Has anyone ever managed to read a Windows registry key in a PHP webpage? I
> installed the PHP extension win32std and saved their sample script from
> http://wildphp.free.fr/wiki/doku.php...egistry_access as a
> webpage. However when I open the webpage (PHP 5.1.2, Windows Server 2003,
> IIS 6) I get the error message "Warning: Can't open registry key: The
> operation completed successfully." Is registry access only possible in
> Windows executables?[/color]

Just speculating... Apache normally runs under the local system account, if
I recall correctly. The chosen registry key may have more restrictive
permissions.

I suggest you first try to run your script from the command line, so it has
the same privileges as your personal user. If that's the issue, it can be
fixed later.


--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
  #3  
Old January 27th, 2006, 10:35 PM
Alvaro G. Vicario
Guest
 
Posts: n/a

re: Windows registry access in PHP webpage possible?


*** Alvaro G. Vicario escribió/wrote (Fri, 27 Jan 2006 23:24:46 +0100):[color=blue]
> Apache normally runs under the local system account[/color]

Where I said Apache please read IIS and where I said system account please
read IUSR_FOOBAR. See the "Services" snap-in console for further info.


--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
  #4  
Old January 28th, 2006, 03:45 AM
noone
Guest
 
Posts: n/a

re: Windows registry access in PHP webpage possible?


Boris wrote:[color=blue]
> Has anyone ever managed to read a Windows registry key in a PHP webpage? I
> installed the PHP extension win32std and saved their sample script from
> http://wildphp.free.fr/wiki/doku.php...egistry_access as a
> webpage. However when I open the webpage (PHP 5.1.2, Windows Server 2003,
> IIS 6) I get the error message "Warning: Can't open registry key: The
> operation completed successfully." Is registry access only possible in
> Windows executables?
>
> Boris
>
>[/color]


If anything other than the local running user is able to read the
registry, I would consider that a breach of security - BAD - VERY BAD
IDEA.

Another reason to ditch winbloze and go Linux for a desktop.

Michael Austin.
  #5  
Old January 28th, 2006, 01:35 PM
Boris
Guest
 
Posts: n/a

re: Windows registry access in PHP webpage possible?



"Alvaro G. Vicario" <webmaster@NOSPAMdemogracia.com>,
news:1016g7k091kjt.1ryugnjrk4kqo.dlg@40tude.net...[color=blue]
> *** Boris escribió/wrote (Fri, 27 Jan 2006 18:32:36 +0100):[color=green]
>> Has anyone ever managed to read a Windows registry key in a PHP webpage?
>> I
>> installed the PHP extension win32std and saved their sample script from
>> http://wildphp.free.fr/wiki/doku.php...egistry_access as
>> a
>> webpage. However when I open the webpage (PHP 5.1.2, Windows Server 2003,
>> IIS 6) I get the error message "Warning: Can't open registry key: The
>> operation completed successfully." Is registry access only possible in
>> Windows executables?[/color]
>
> Just speculating... Apache normally runs under the local system account,
> if
> I recall correctly. The chosen registry key may have more restrictive
> permissions.[/color]

The script tries to read "HKEY_CURRENT_USER\Control Panel". As far as I know
this key exists for all user accounts. And each user should be able to read
his HKEY_CURRENT_USER branch, too.
[color=blue]
> I suggest you first try to run your script from the command line, so it
> has
> the same privileges as your personal user. If that's the issue, it can be
> fixed later.[/color]

Thanks, I tried that. It works! Actually I would agree that it is a
permission issue but see above. According to
http://support.microsoft.com/kb/163846/en-us the registry keys of the SYSTEM
account are stored at \HKEY_USERS\S-1-5-18. When I check
"\HKEY_USERS\S-1-5-18\Control Panel" the SYSTEM account does have
read-access. I would expect the PHP webpage to be able to find and read this
key under \HKEY_CURRENT_USER?

Boris


  #6  
Old January 29th, 2006, 02:15 PM
Alvaro G. Vicario
Guest
 
Posts: n/a

re: Windows registry access in PHP webpage possible?


*** Boris escribió/wrote (Sat, 28 Jan 2006 14:28:04 +0100):[color=blue]
> Thanks, I tried that. It works! Actually I would agree that it is a
> permission issue but see above. According to
> http://support.microsoft.com/kb/163846/en-us the registry keys of the SYSTEM
> account are stored at \HKEY_USERS\S-1-5-18. When I check
> "\HKEY_USERS\S-1-5-18\Control Panel" the SYSTEM account does have
> read-access. I would expect the PHP webpage to be able to find and read this
> key under \HKEY_CURRENT_USER?[/color]

Please read my second message. IIS runs under its own user, typically
called IUSR_MACHINENAME.

--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
  #7  
Old January 29th, 2006, 11:15 PM
Boris
Guest
 
Posts: n/a

re: Windows registry access in PHP webpage possible?



"Alvaro G. Vicario" <webmaster@NOSPAMdemogracia.com>,
news:zxxo0gj4alh1$.3hp1m1zbr8ep$.dlg@40tude.net...[color=blue]
> *** Boris escribió/wrote (Sat, 28 Jan 2006 14:28:04 +0100):[color=green]
>> Thanks, I tried that. It works! Actually I would agree that it is a
>> permission issue but see above. According to
>> http://support.microsoft.com/kb/163846/en-us the registry keys of the
>> SYSTEM
>> account are stored at \HKEY_USERS\S-1-5-18. When I check
>> "\HKEY_USERS\S-1-5-18\Control Panel" the SYSTEM account does have
>> read-access. I would expect the PHP webpage to be able to find and read
>> this
>> key under \HKEY_CURRENT_USER?[/color]
>
> Please read my second message. IIS runs under its own user, typically
> called IUSR_MACHINENAME.[/color]

I created now a new application pool for the virtual directory which
contains the PHP script and explicitly set the user account to NETWORK
SERVICE. This is the same user account used by ASP.NET scripts. While the
ASP.NET script can access the registry the PHP script still returns the same
error. Meanwhile I also contacted one of the developers of the PHP extension
and asked him if he ever ran his sample script succesfully from a webpage.
If I get an answer I'll forward it.

Boris


Closed Thread