@@ -125,7 +125,7 @@ def main():
125
125
if ( args .filename == None and args .passwd == None and (args .registry == False or not platform .system ().startswith ('Windows' )) ):
126
126
parser .error ('Error: No password file or password passed\n ' )
127
127
if ( args .registry and args .decrypt and platform .system ().startswith ('Windows' )):
128
- reg = wreg . WindowsRegistry ( "RealVNC" , "WinVNC4" )
128
+ reg = get_realvnc_key ( )
129
129
( args .passwd , key_type ) = reg .getval ("Password" )
130
130
elif not platform .system ().startswith ('Windows' ):
131
131
print 'Cannot read from Windows Registry on a %s system' % platform .system ()
@@ -159,7 +159,7 @@ def main():
159
159
if ( args .filename != None and not args .decrypt ):
160
160
do_file_out (args .filename , crypted , args .hex )
161
161
if ( args .registry and not args .decrypt and platform .system ().startswith ('Windows' )):
162
- reg = wreg . WindowsRegistry ( "RealVNC" , "WinVNC4" )
162
+ reg = get_realvnc_key ( )
163
163
reg .setval ('Password' , crypted , wreg .WindowsRegistry .REG_BINARY )
164
164
elif not platform .system ().startswith ('Windows' ):
165
165
print 'Cannot write to Windows Registry on a %s system' % platform .system ()
@@ -168,5 +168,22 @@ def main():
168
168
print "%scrypted Bin Pass= '%s'" % ( prefix , crypted )
169
169
print "%scrypted Hex Pass= '%s'" % ( prefix , crypted .encode ('hex' ) )
170
170
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
+
171
188
if __name__ == '__main__' :
172
189
main ()
0 commit comments