Remote Win32 Registry confusion?

  • Thread starter benjamin schollnick
  • Start date
B

benjamin schollnick

Folks,

I am having difficulty with *reading* the registry from a remote Windows
box...

1) I need to impersonate a different user name & password, then the
user I
am currently logged in as.
(i.e. access the registry as a administrator)

2) The registry to be examined is on a different machine...

3) I just need the key entry returned....

For example
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DrWatson\AppendToLogFile
returning the value it has been saved with.

I by no means am a Win32 Python expert, but I usually can muddle my way
through....
But I am missing something here... And I am not sure what...

I have proof of concept VBScript code....

strroot = "HKEY_LOCAL_MACHINE"
strKeyPath = "\SOFTWARE\Microsoft\DrWatson"
strKey = "AppendToLogFile"

Dim arrValues
strKeyPath = "\SOFTWARE\Microsoft\DrWatson"
strKey = "AppendToLogfile"
objRegister.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strKey,
value

Wscript.Echo value

Here's the code that I have attempted to use.... Can anyone point out
what
I am missing?

It works fine locally, but I can't figure out how to assign the user
account
and password for the remote system.

import _winreg
import win32com.client



host = "127.0.0.1" # local host
key = _winreg.ConnectRegistry(host, _winreg.HKEY_LOCAL_MACHINE)
hkey = _winreg.OpenKey(key,
r"Software\Microsoft\Windows\CurrentVersion\Uninstall")
num = _winreg.QueryInfoKey(hkey)[0]
print "*** Found %d Software ***" % num

try:
for x in range(1000):
uninstall = _winreg.EnumKey(hkey, x)
skey = _winreg.OpenKey(key,
"Software\Microsoft\Windows\CurrentVersion\Uninstall\%s" % uninstall)
try:
software = _winreg.QueryValueEx(skey, "DisplayName")[0]
print "%s-%s" % (uninstall, software)
except:
pass
except:
pass
 
B

Bjorn Pettersen

Folks,

I am having difficulty with *reading* the registry from a remote
Windows box...

I've only done this once, a long time ago, and the ability has been severly
limited since then by an MS service pack (you should have seen the security
admin's face when I changed his path variable remotely without a trace ;-)
1) I need to impersonate a different user name & password, then the
user I
am currently logged in as.
(i.e. access the registry as a administrator)

You'll at least need to log in to the domain to get your security token,
then use that to impersonate that user.
2) The registry to be examined is on a different machine...

Verify that this isn't turned off by either that machine or a group policy.
3) I just need the key entry returned....

key entry == value(?)

-- bjorn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top