Windows registry access in PHP webpage possible?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boris

    Windows registry access in PHP webpage possible?

    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


  • Alvaro G. Vicario

    #2
    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
    --

    Comment

    • Alvaro G. Vicario

      #3
      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
      --

      Comment

      • noone

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

        Comment

        • Boris

          #5
          Re: Windows registry access in PHP webpage possible?


          "Alvaro G. Vicario" <webmaster@NOSP AMdemogracia.co m>,
          news:1016g7k091 kjt.1ryugnjrk4k qo.dlg@40tude.n et...[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_U SER\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_US ER 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_USER S\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_U SER?

          Boris


          Comment

          • Alvaro G. Vicario

            #6
            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_USER S\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_U SER?[/color]

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

            --
            -+ Á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
            --

            Comment

            • Boris

              #7
              Re: Windows registry access in PHP webpage possible?


              "Alvaro G. Vicario" <webmaster@NOSP AMdemogracia.co m>,
              news:zxxo0gj4al h1$.3hp1m1zbr8e p$.dlg@40tude.n et...[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_USER S\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_U SER?[/color]
              >
              > Please read my second message. IIS runs under its own user, typically
              > called IUSR_MACHINENAM E.[/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


              Comment

              Working...