@@ -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" , "WinVNC4" )
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" , "WinVNC4" )
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+
171188if __name__ == '__main__' :
172189 main ()
0 commit comments