By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,929 Members | 1,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,929 IT Pros & Developers. It's quick & easy.

Windows registry access in PHP webpage possible?

P: 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
Jan 27 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
*** Boris escribió/wrote (Fri, 27 Jan 2006 18:32:36 +0100):
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?


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
--
Jan 27 '06 #2

P: n/a
*** Alvaro G. Vicario escribió/wrote (Fri, 27 Jan 2006 23:24:46 +0100):
Apache normally runs under the local system account


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
--
Jan 27 '06 #3

P: n/a
Boris wrote:
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

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.
Jan 28 '06 #4

P: n/a

"Alvaro G. Vicario" <we*******@NOSPAMdemogracia.com>,
news:10*****************************@40tude.net...
*** Boris escribió/wrote (Fri, 27 Jan 2006 18:32:36 +0100):
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?
Just speculating... Apache normally runs under the local system account,
if
I recall correctly. The chosen registry key may have more restrictive
permissions.


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.
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.


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
Jan 28 '06 #5

P: n/a
*** Boris escribió/wrote (Sat, 28 Jan 2006 14:28:04 +0100):
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?


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
--
Jan 29 '06 #6

P: n/a

"Alvaro G. Vicario" <we*******@NOSPAMdemogracia.com>,
news:zx*****************************@40tude.net...
*** Boris escribió/wrote (Sat, 28 Jan 2006 14:28:04 +0100):
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?


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


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
Jan 29 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.