Python win32con.KEY_READ Examples
The following are 30
code examples of win32con.KEY_READ().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32con
, or try the search function
.
Example #1
Source File: skype.py From Radium with Apache License 2.0 | 7 votes |
def get_regkey(self): try: accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE keyPath = 'Software\\Skype\\ProtectedStorage' try: hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead) except Exception, e: print e return '' num = win32api.RegQueryInfoKey(hkey)[1] k = win32api.RegEnumValue(hkey, 0) if k: key = k[1] return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
Example #2
Source File: windows-privesc-check.py From WHP with Do What The F*ck You Want To Public License | 6 votes |
def check_registry(): for key_string in reg_paths: parts = key_string.split("\\") hive = parts[0] key_string = "\\".join(parts[1:]) try: keyh = win32api.RegOpenKeyEx(getattr(win32con, hive), key_string, 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: #print "Can't open: " + hive + "\\" + key_string continue sd = win32api.RegGetKeySecurity(keyh, win32security.DACL_SECURITY_INFORMATION | win32security.OWNER_SECURITY_INFORMATION) weak_perms = check_weak_write_perms_by_sd(hive + "\\" + key_string, 'reg', sd) if weak_perms: vprint(hive + "\\" + key_string) #print weak_perms if verbose == 0: sys.stdout.write(".") save_issue("WPC003", "writable_reg_paths", weak_perms) # print_weak_perms("x", weak_perms) print # TODO save_issue("WPC009", "writable_eventlog_key", weak_perms) # weak perms on event log reg key
Example #3
Source File: windowsprivcheck.py From LHF with GNU General Public License v3.0 | 6 votes |
def check_registry(): for key_string in reg_paths: parts = key_string.split("\\") hive = parts[0] key_string = "\\".join(parts[1:]) try: keyh = win32api.RegOpenKeyEx(getattr(win32con, hive), key_string, 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: #print "Can't open: " + hive + "\\" + key_string continue sd = win32api.RegGetKeySecurity(keyh, win32security.DACL_SECURITY_INFORMATION | win32security.OWNER_SECURITY_INFORMATION) weak_perms = check_weak_write_perms_by_sd(hive + "\\" + key_string, 'reg', sd) if weak_perms: vprint(hive + "\\" + key_string) #print weak_perms if verbose == 0: sys.stdout.write(".") save_issue("WPC003", "writable_reg_paths", weak_perms) # print_weak_perms("x", weak_perms) print # TODO save_issue("WPC009", "writable_eventlog_key", weak_perms) # weak perms on event log reg key
Example #4
Source File: windowsprivcheck.py From LHF with GNU General Public License v3.0 | 6 votes |
def get_user_paths(): try: keyh = win32api.RegOpenKeyEx(win32con.HKEY_USERS, None , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: return 0 paths = [] subkeys = win32api.RegEnumKeyEx(keyh) for subkey in subkeys: try: subkeyh = win32api.RegOpenKeyEx(keyh, subkey[0] + "\\Environment" , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: pass else: subkey_count, value_count, mod_time = win32api.RegQueryInfoKey(subkeyh) try: path, type = win32api.RegQueryValueEx(subkeyh, "PATH") paths.append((subkey[0], path)) except: pass return paths
Example #5
Source File: windowsprivcheck.py From LHF with GNU General Public License v3.0 | 6 votes |
def get_system_path(): # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment key_string = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment' try: keyh = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, key_string , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: return None try: path, type = win32api.RegQueryValueEx(keyh, "PATH") return path except: return None #name=sys.argv[1] #if not os.path.exists(name): #print name, "does not exist!" #sys.exit()
Example #6
Source File: windows-privesc-check.py From WHP with Do What The F*ck You Want To Public License | 6 votes |
def get_system_path(): # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment key_string = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment' try: keyh = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, key_string , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: return None try: path, type = win32api.RegQueryValueEx(keyh, "PATH") return path except: return None #name=sys.argv[1] #if not os.path.exists(name): #print name, "does not exist!" #sys.exit()
Example #7
Source File: windows-privesc-check.py From WHP with Do What The F*ck You Want To Public License | 6 votes |
def get_user_paths(): try: keyh = win32api.RegOpenKeyEx(win32con.HKEY_USERS, None , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: return 0 paths = [] subkeys = win32api.RegEnumKeyEx(keyh) for subkey in subkeys: try: subkeyh = win32api.RegOpenKeyEx(keyh, subkey[0] + "\\Environment" , 0, win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE | win32con.KEY_READ) except: pass else: subkey_count, value_count, mod_time = win32api.RegQueryInfoKey(subkeyh) try: path, type = win32api.RegQueryValueEx(subkeyh, "PATH") paths.append((subkey[0], path)) except: pass return paths
Example #8
Source File: msw.py From wxGlade with MIT License | 6 votes |
def __init__(self, keyname, handle=None, mode="w"): #access=win32con.KEY_ALL_ACCESS): """Easy access to win32 registry. mode: 'r' or 'w'""" if mode=="w": access = win32con.KEY_ALL_ACCESS elif mode=="r": access = win32con.KEY_READ else: raise ValueError( "mode must be 'r' or 'w'" ) self.mode = mode self.handle = None if handle is None: handle=self.branch # open key try: self.handle = win32api.RegOpenKeyEx(handle, keyname, 0, access) except: #except (pywintypes.error, pywintypes.api_error): self.handle = win32api.RegCreateKey(handle, keyname)
Example #9
Source File: skype.py From BrainDamage with Apache License 2.0 | 6 votes |
def get_regkey(self): try: accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE keyPath = 'Software\\Skype\\ProtectedStorage' try: hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead) except Exception, e: # print e return '' num = win32api.RegQueryInfoKey(hkey)[1] k = win32api.RegEnumValue(hkey, 0) if k: key = k[1] return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
Example #10
Source File: winscp.py From BrainDamage with Apache License 2.0 | 5 votes |
def check_winscp_installed(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE try: key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\Martin Prikryl\WinSCP 2\Configuration\Security', 0, accessRead) return True except Exception, e: return False
Example #11
Source File: win32.py From python-for-android with Apache License 2.0 | 5 votes |
def getProgramsMenuPath(): """Get the path to the Programs menu. Probably will break on non-US Windows. @returns: the filesystem location of the common Start Menu->Programs. """ if not platform.isWinNT(): return "C:\\Windows\\Start Menu\\Programs" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders' hShellFolders = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(hShellFolders, 'Common Programs')[0]
Example #12
Source File: impdirector.py From ConTroll_Remote_Access_Trojan with Apache License 2.0 | 5 votes |
def __init__(self): self.path = "WindowsRegistry" self.map = {} try: import win32api import win32con except ImportError: return subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver for root in (win32con.HKEY_CURRENT_USER, win32con.HKEY_LOCAL_MACHINE): try: hkey = win32api.RegOpenKeyEx(root, subkey, 0, win32con.KEY_READ) except Exception, e: logger.debug('RegistryImportDirector: %s' % e) continue numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey) for i in range(numsubkeys): subkeyname = win32api.RegEnumKey(hkey, i) hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, win32con.KEY_READ) val = win32api.RegQueryValueEx(hskey, '') desc = getDescr(val[0]) #print " RegistryImportDirector got %s %s" % (val[0], desc) #XXX self.map[subkeyname] = (val[0], desc) hskey.Close() hkey.Close() break
Example #13
Source File: winscp.py From BrainDamage with Apache License 2.0 | 5 votes |
def check_masterPassword(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\Martin Prikryl\WinSCP 2\Configuration\Security', 0, accessRead) thisName = str(win32api.RegQueryValueEx(key, 'UseMasterPassword')[0]) if thisName == '0': return False else: return True
Example #14
Source File: winscp.py From BrainDamage with Apache License 2.0 | 5 votes |
def get_logins_info(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE try: key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\Martin Prikryl\WinSCP 2\Sessions', 0, accessRead) except Exception, e: return False
Example #15
Source File: win32.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def getProgramFilesPath(): """Get the path to the Program Files folder.""" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' currentV = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(currentV, 'ProgramFilesDir')[0]
Example #16
Source File: win32.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def getProgramsMenuPath(): """Get the path to the Programs menu. Probably will break on non-US Windows. @returns: the filesystem location of the common Start Menu->Programs. """ if not platform.isWinNT(): return "C:\\Windows\\Start Menu\\Programs" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders' hShellFolders = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(hShellFolders, 'Common Programs')[0]
Example #17
Source File: 文件.py From Librian with Mozilla Public License 2.0 | 5 votes |
def 查詢文件打開方式(文件名): ext = os.path.splitext(文件名)[-1] try: key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, ext, 0, win32con.KEY_READ) except: return None q = win32api.RegQueryValue(key, '') key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, f'{q}\shell\open\command', 0, win32con.KEY_READ) q = win32api.RegQueryValue(key, '') return q
Example #18
Source File: putty.py From BrainDamage with Apache License 2.0 | 5 votes |
def get_default_database(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\\ACS\\PuTTY Connection Manager', 0, accessRead) thisName = str(win32api.RegQueryValueEx(key, 'DefaultDatabase')[0]) if thisName: return thisName else: return ' '
Example #19
Source File: outlook.py From BrainDamage with Apache License 2.0 | 5 votes |
def run(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE keyPath = 'Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows Messaging Subsystem\\Profiles\\Outlook' try: hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead) except Exception, e: return
Example #20
Source File: win32.py From python-for-android with Apache License 2.0 | 5 votes |
def getProgramFilesPath(): """Get the path to the Program Files folder.""" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' currentV = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(currentV, 'ProgramFilesDir')[0]
Example #21
Source File: winscp.py From Radium with Apache License 2.0 | 5 votes |
def check_winscp_installed(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE try: key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\Martin Prikryl\WinSCP 2\Configuration\Security', 0, accessRead) return True except Exception, e: return False
Example #22
Source File: Constant.py From pc-protector-moe with GNU General Public License v3.0 | 5 votes |
def get_desktop(): key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 0, win32con.KEY_READ) return win32api.RegQueryValueEx(key, 'Desktop')[0]
Example #23
Source File: win32.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def getProgramFilesPath(): """Get the path to the Program Files folder.""" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' currentV = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(currentV, 'ProgramFilesDir')[0]
Example #24
Source File: win32.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def getProgramsMenuPath(): """ Get the path to the Programs menu. Probably will break on non-US Windows. @return: the filesystem location of the common Start Menu->Programs. @rtype: L{str} """ if not platform.isWindows(): return "C:\\Windows\\Start Menu\\Programs" keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders' hShellFolders = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, keyname, 0, win32con.KEY_READ) return win32api.RegQueryValueEx(hShellFolders, 'Common Programs')[0]
Example #25
Source File: win32serviceutil.py From ironpython2 with Apache License 2.0 | 5 votes |
def _GetServiceShortName(longName): # looks up a services name # from the display name # Thanks to Andy McKay for this code. access = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE hkey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services", 0, access) num = win32api.RegQueryInfoKey(hkey)[0] longName = longName.lower() # loop through number of subkeys for x in range(0, num): # find service name, open subkey svc = win32api.RegEnumKey(hkey, x) skey = win32api.RegOpenKey(hkey, svc, 0, access) try: # find display name thisName = str(win32api.RegQueryValueEx(skey, "DisplayName")[0]) if thisName.lower() == longName: return svc except win32api.error: # in case there is no key called DisplayName pass return None # Open a service given either it's long or short name.
Example #26
Source File: regcheck.py From ironpython2 with Apache License 2.0 | 5 votes |
def CheckHelpFiles(verbose): if verbose: print "Help Files:" try: key = win32api.RegOpenKey(regutil.GetRootKey(), regutil.BuildDefaultPythonKey() + "\\Help", 0, win32con.KEY_READ) except win32api.error, exc: import winerror if exc.winerror!=winerror.ERROR_FILE_NOT_FOUND: raise return
Example #27
Source File: help.py From ironpython2 with Apache License 2.0 | 5 votes |
def _ListAllHelpFilesInRoot(root): """Returns a list of (helpDesc, helpFname) for all registered help files """ import regutil retList = [] try: key = win32api.RegOpenKey(root, regutil.BuildDefaultPythonKey() + "\\Help", 0, win32con.KEY_READ) except win32api.error, exc: import winerror if exc.winerror!=winerror.ERROR_FILE_NOT_FOUND: raise return retList
Example #28
Source File: outlook.py From Radium with Apache License 2.0 | 5 votes |
def run(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE keyPath = 'Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows Messaging Subsystem\\Profiles\\Outlook' try: hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead) except Exception, e: return
Example #29
Source File: putty.py From Radium with Apache License 2.0 | 5 votes |
def get_default_database(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\\ACS\\PuTTY Connection Manager', 0, accessRead) thisName = str(win32api.RegQueryValueEx(key, 'DefaultDatabase')[0]) if thisName: return thisName else: return ' '
Example #30
Source File: winscp.py From Radium with Apache License 2.0 | 5 votes |
def get_logins_info(self): accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE try: key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\Martin Prikryl\WinSCP 2\Sessions', 0, accessRead) except Exception, e: return False