Skip to content

Commit 9f73ffa

Browse files
committed
Handle both vncserver and WinVNC keys
1 parent 832a906 commit 9f73ffa

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

WindowsRegistry.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ def __init__(self, company="RealVNC", project="WinVNC4", create=0):
6060
while not_opened and i<len(rights)-1:
6161
try:
6262
if platform.machine().endswith('64') and platform.architecture()[0] == '32bit':
63-
print('yes')
64-
print(rights[i])
6563
self.key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, self.keyname, 0, rights[i] | wreg.KEY_WOW64_64KEY)
6664
else:
6765
self.key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, self.keyname,0, rights[i])

vncpasswd.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def main():
125125
if ( args.filename == None and args.passwd == None and (args.registry == False or not platform.system().startswith('Windows')) ):
126126
parser.error('Error: No password file or password passed\n')
127127
if ( args.registry and args.decrypt and platform.system().startswith('Windows')):
128-
reg = wreg.WindowsRegistry("RealVNC", "vncserver")
128+
reg = get_realvnc_key()
129129
( args.passwd, key_type) = reg.getval("Password")
130130
elif not platform.system().startswith('Windows'):
131131
print 'Cannot read from Windows Registry on a %s system' % platform.system()
@@ -159,7 +159,7 @@ def main():
159159
if ( args.filename != None and not args.decrypt ):
160160
do_file_out(args.filename, crypted, args.hex)
161161
if ( args.registry and not args.decrypt and platform.system().startswith('Windows')):
162-
reg = wreg.WindowsRegistry("RealVNC", "vncserver")
162+
reg = get_realvnc_key()
163163
reg.setval('Password', crypted, wreg.WindowsRegistry.REG_BINARY)
164164
elif not platform.system().startswith('Windows'):
165165
print 'Cannot write to Windows Registry on a %s system' % platform.system()
@@ -168,5 +168,22 @@ def main():
168168
print "%scrypted Bin Pass= '%s'" % ( prefix, crypted )
169169
print "%scrypted Hex Pass= '%s'" % ( prefix, crypted.encode('hex') )
170170

171+
172+
def get_realvnc_key():
173+
reg = None
174+
175+
for k in ['vncserver', 'WinVNC4',]:
176+
try:
177+
reg = wreg.WindowsRegistry('RealVNC', k)
178+
break
179+
except WindowsError as e:
180+
if 'The system cannot find the file specified' in str(e):
181+
pass
182+
else:
183+
raise e
184+
185+
return reg
186+
187+
171188
if __name__ == '__main__':
172189
main()

0 commit comments

Comments
 (0)