python类HKEY_LOCAL_MACHINE的实例源码

buildserver.py 文件源码 项目:get-youtube-subtitle-url-node 作者: joegesualdo 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        python_version = kwargs.pop('python', '3.4')
        python_path = None
        for node in ('Wow6432Node\\', ''):
            try:
                key = compat_winreg.OpenKey(
                    compat_winreg.HKEY_LOCAL_MACHINE,
                    r'SOFTWARE\%sPython\PythonCore\%s\InstallPath' % (node, python_version))
                try:
                    python_path, _ = compat_winreg.QueryValueEx(key, '')
                finally:
                    compat_winreg.CloseKey(key)
                break
            except Exception:
                pass

        if not python_path:
            raise BuildError('No such Python version: %s' % python_version)

        self.pythonPath = python_path

        super(PythonBuilder, self).__init__(**kwargs)
iebutton.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def unregister(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.DeleteValue( hKey, "ButtonText" )
        _winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object
        _winreg.DeleteValue( hKey, "CLSID" )
        _winreg.DeleteValue( hKey, "Default Visible" )
        _winreg.DeleteValue( hKey, "ToolTip" )
        _winreg.DeleteValue( hKey, "Icon" )
        _winreg.DeleteValue( hKey, "HotIcon" )
        _winreg.DeleteKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
    except WindowsError:
        print "Couldn't delete Standard toolbar regkey."
    else:
        print "Deleted Standard toolbar regkey."

#
# test implementation
#
registry.py 文件源码 项目:PythonForWindows 作者: hakril 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __call__(self, name, sam=KEY_READ):
        """Get a registry key::

            registry(r"HKEY_LOCAL_MACHINE\\Software")
            registry("HKEY_LOCAL_MACHINE")("Software")

        :rtype: :class:`PyHKey`
        """

        if name in self.registry_base_keys:
            key = self.registry_base_keys[name]
            if sam != key.sam:
                key = key.reopen(sam)
            return key
        if "\\" not in name:
            raise ValueError("Unknow registry base key <{0}>".format(name))
        base_name, subkey = name.split("\\", 1)
        if base_name not in self.registry_base_keys:
            raise ValueError("Unknow registry base key <{0}>".format(base_name))
        return self.registry_base_keys[base_name](subkey,  sam)
iebutton.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def register(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.SetValueEx( hKey, "ButtonText", 0, _winreg.REG_SZ, classobj._button_text_ )
        _winreg.SetValueEx( hKey, "ClsidExtension", 0, _winreg.REG_SZ, classobj._reg_clsid_ ) # reg value for calling COM object
        _winreg.SetValueEx( hKey, "CLSID", 0, _winreg.REG_SZ, "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}" ) # CLSID for button that sends command to COM object
        _winreg.SetValueEx( hKey, "Default Visible", 0, _winreg.REG_SZ, "Yes" )
        _winreg.SetValueEx( hKey, "ToolTip", 0, _winreg.REG_SZ, classobj._tool_tip_ )
        _winreg.SetValueEx( hKey, "Icon", 0, _winreg.REG_SZ, classobj._icon_)
        _winreg.SetValueEx( hKey, "HotIcon", 0, _winreg.REG_SZ, classobj._hot_icon_)
    except WindowsError:
        print "Couldn't set standard toolbar reg keys."
    else:
        print "Set standard toolbar reg keys."
iebutton.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def register(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.SetValueEx( hKey, "ButtonText", 0, _winreg.REG_SZ, classobj._button_text_ )
        _winreg.SetValueEx( hKey, "ClsidExtension", 0, _winreg.REG_SZ, classobj._reg_clsid_ ) # reg value for calling COM object
        _winreg.SetValueEx( hKey, "CLSID", 0, _winreg.REG_SZ, "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}" ) # CLSID for button that sends command to COM object
        _winreg.SetValueEx( hKey, "Default Visible", 0, _winreg.REG_SZ, "Yes" )
        _winreg.SetValueEx( hKey, "ToolTip", 0, _winreg.REG_SZ, classobj._tool_tip_ )
        _winreg.SetValueEx( hKey, "Icon", 0, _winreg.REG_SZ, classobj._icon_)
        _winreg.SetValueEx( hKey, "HotIcon", 0, _winreg.REG_SZ, classobj._hot_icon_)
    except WindowsError:
        print "Couldn't set standard toolbar reg keys."
    else:
        print "Set standard toolbar reg keys."
iebutton.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def unregister(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.DeleteValue( hKey, "ButtonText" )
        _winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object
        _winreg.DeleteValue( hKey, "CLSID" )
        _winreg.DeleteValue( hKey, "Default Visible" )
        _winreg.DeleteValue( hKey, "ToolTip" )
        _winreg.DeleteValue( hKey, "Icon" )
        _winreg.DeleteValue( hKey, "HotIcon" )
        _winreg.DeleteKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
    except WindowsError:
        print "Couldn't delete Standard toolbar regkey."
    else:
        print "Deleted Standard toolbar regkey."

#
# test implementation
#
buildserver.py 文件源码 项目:optimalvibes 作者: littlemika 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        python_version = kwargs.pop('python', '3.4')
        python_path = None
        for node in ('Wow6432Node\\', ''):
            try:
                key = compat_winreg.OpenKey(
                    compat_winreg.HKEY_LOCAL_MACHINE,
                    r'SOFTWARE\%sPython\PythonCore\%s\InstallPath' % (node, python_version))
                try:
                    python_path, _ = compat_winreg.QueryValueEx(key, '')
                finally:
                    compat_winreg.CloseKey(key)
                break
            except Exception:
                pass

        if not python_path:
            raise BuildError('No such Python version: %s' % python_version)

        self.pythonPath = python_path

        super(PythonBuilder, self).__init__(**kwargs)
disguise.py 文件源码 项目:cuckoo-headless 作者: evandowning 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def patch_scsi_identifiers(self):
        types = {
            "DiskPeripheral": self.HDD_IDENTIFIERS,
            "CdRomPeripheral": self.CDROM_IDENTIFIERS,
        }

        for row in itertools.product([0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]):
            type_ = query_value(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port %d\\Scsi Bus %d\\Target Id %d\\Logical Unit Id %d" % row, "Type")
            value = query_value(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port %d\\Scsi Bus %d\\Target Id %d\\Logical Unit Id %d" % row, "Identifier")
            if not type_ or not value:
                continue

            value = value.lower()
            if "vbox" in value or "vmware" in value or "qemu" in value or "virtual" in value:
                if type_ in types:
                    new_value = random.choice(types[type_])
                else:
                    log.warning("Unknown SCSI type (%s), disguising it with a random string", type_)
                    new_value = random_string(len(value))

                set_regkey(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port %d\\Scsi Bus %d\\Target Id %d\\Logical Unit Id %d" % row,
                           "Identifier", REG_SZ, new_value)
dbgview.py 文件源码 项目:cuckoo-headless 作者: evandowning 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def start(self):
        if not self.options.get("dbgview"):
            return

        dbgview_path = os.path.join("bin", "dbgview.exe")
        if not os.path.exists(dbgview_path):
            log.error("DbgView.exe not found!")
            return

        # Make sure all logging makes it into DbgView.
        set_regkey(
            _winreg.HKEY_LOCAL_MACHINE, DebugPrintFilter,
            "", _winreg.REG_DWORD, 0xffffffff
        )

        self.filepath = os.path.join(self.analyzer.path, "bin", "dbgview.log")

        # Accept the EULA and enable Kernel Capture.
        subprocess.Popen([
            dbgview_path, "/accepteula", "/t", "/k", "/l", self.filepath,
        ])
        log.info("Successfully started DbgView.")
disguise.py 文件源码 项目:cuckoodroid-2.0 作者: idanr1986 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def patch_scsi_identifiers(self):
        types = {
            "DiskPeripheral": self.HDD_IDENTIFIERS,
            "CdRomPeripheral": self.CDROM_IDENTIFIERS,
        }

        for row in itertools.product([0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]):
            type_ = query_value(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port %d\\Scsi Bus %d\\Target Id %d\\Logical Unit Id %d" % row, "Type")
            value = query_value(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port %d\\Scsi Bus %d\\Target Id %d\\Logical Unit Id %d" % row, "Identifier")
            if not type_ or not value:
                continue

            value = value.lower()
            if "vbox" in value or "vmware" in value or "qemu" in value or "virtual" in value:
                if type_ in types:
                    new_value = random.choice(types[type_])
                else:
                    log.warning("Unknown SCSI type (%s), disguising it with a random string", type_)
                    new_value = random_string(len(value))

                set_regkey(HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port %d\\Scsi Bus %d\\Target Id %d\\Logical Unit Id %d" % row,
                           "Identifier", REG_SZ, new_value)
iebutton.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def register(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.SetValueEx( hKey, "ButtonText", 0, _winreg.REG_SZ, classobj._button_text_ )
        _winreg.SetValueEx( hKey, "ClsidExtension", 0, _winreg.REG_SZ, classobj._reg_clsid_ ) # reg value for calling COM object
        _winreg.SetValueEx( hKey, "CLSID", 0, _winreg.REG_SZ, "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}" ) # CLSID for button that sends command to COM object
        _winreg.SetValueEx( hKey, "Default Visible", 0, _winreg.REG_SZ, "Yes" )
        _winreg.SetValueEx( hKey, "ToolTip", 0, _winreg.REG_SZ, classobj._tool_tip_ )
        _winreg.SetValueEx( hKey, "Icon", 0, _winreg.REG_SZ, classobj._icon_)
        _winreg.SetValueEx( hKey, "HotIcon", 0, _winreg.REG_SZ, classobj._hot_icon_)
    except WindowsError:
        print "Couldn't set standard toolbar reg keys."
    else:
        print "Set standard toolbar reg keys."
IRONGATE_malware_source.py 文件源码 项目:TC2017 作者: G4lB1t 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def detect_vmware():
    detected = False

    # try:
    #     with OpenKey(HKEY_LOCAL_MACHINE,
    #                  r"HARDWARE\\DEVICEMAP\\Scsi\\Scsi Port 0\\Scsi Bus 0\\Target Id 0\\Logical Unit Id 0") as key:
    #         print 1
    # except Exception, e:
    #     print(e)

    try:
        with OpenKey(HKEY_LOCAL_MACHINE, r"SOFTWARE\\VMware, Inc.\\VMware Tools") as key:
            detected = True
    except Exception, e:
        pass
##        print(e)

    windows_path = os.environ['WINDIR']
    if os.path.isfile(os.path.join(windows_path, r"system32\drivers\vmmouse.sys")) or \
            os.path.isfile(os.path.join(windows_path, r"system32\drivers\vmhgfs.sys")):
        detected = True

    return detected
msvs.py 文件源码 项目:mbuild 作者: intelxed 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _find_msvc_in_registry(env,version):
    if _is_py2:
        import _winreg as winreg
    else:
        import winreg

    vs_ver = str(version) + '.0'
    vs_key = 'SOFTWARE\\Microsoft\\VisualStudio\\' + vs_ver + '\\Setup\\VS'
    vc_key = 'SOFTWARE\\Microsoft\\VisualStudio\\' + vs_ver + '\\Setup\\VC'
    vs_dir = _read_registry(winreg.HKEY_LOCAL_MACHINE, vs_key, 'ProductDir')
    vc_dir = _read_registry(winreg.HKEY_LOCAL_MACHINE, vc_key, 'ProductDir')

    # On a 64-bit host, look for a 32-bit installation 

    if (not vs_dir or not vc_dir):
        vs_key = 'SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\' + \
            vs_ver + '\\Setup\\VS'
        vc_key = 'SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\' + \
            vs_ver + '\\Setup\\VC'
        vs_dir = _read_registry(winreg.HKEY_LOCAL_MACHINE, 
                                vs_key, 'ProductDir')
        vc_dir = _read_registry(winreg.HKEY_LOCAL_MACHINE, 
                                vc_key, 'ProductDir')
    return (vs_dir,vc_dir)
img.py 文件源码 项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _create_win(self):
        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                r'Software\Microsoft\Windows NT\CurrentVersion\Fonts')
        except EnvironmentError:
            try:
                key = _winreg.OpenKey(
                    _winreg.HKEY_LOCAL_MACHINE,
                    r'Software\Microsoft\Windows\CurrentVersion\Fonts')
            except EnvironmentError:
                raise FontNotFound('Can\'t open Windows font registry key')
        try:
            path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
            self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
            for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
                path = self._lookup_win(key, self.font_name, STYLES[style])
                if path:
                    self.fonts[style] = ImageFont.truetype(path, self.font_size)
                else:
                    if style == 'BOLDITALIC':
                        self.fonts[style] = self.fonts['BOLD']
                    else:
                        self.fonts[style] = self.fonts['NORMAL']
        finally:
            _winreg.CloseKey(key)
BITSInject.py 文件源码 项目:BITSInject 作者: SafeBreach-Labs 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _get_effective_state_index():
        """
        Get the state file index that's currently in use - deprecated
        :return: index of the current effective state file
        """
        hKey = OpenKey(HKEY_LOCAL_MACHINE, BITSStateFile.REG_BITS_KEY)
        return QueryValueEx(hKey, BITSStateFile.REG_STATE_INDEX_VALUE)[0]
win32timezone.py 文件源码 项目:purelove 作者: hucmosin 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _FindTimeZoneKey(self):
        """Find the registry key for the time zone name (self.timeZoneName)."""
        # for multi-language compatability, match the time zone name in the
        # "Std" key of the time zone key.
        zoneNames = dict(self._get_indexed_time_zone_keys('Std'))
        # Also match the time zone key name itself, to be compatible with
        # English-based hard-coded time zones.
        timeZoneName = zoneNames.get(self.timeZoneName, self.timeZoneName)
        key = _RegKeyDict.open(_winreg.HKEY_LOCAL_MACHINE, self.tzRegKey)
        try:
            result = key.subkey(timeZoneName)
        except:
            raise ValueError('Timezone Name %s not found.' % timeZoneName)
        return result
win32timezone.py 文件源码 项目:purelove 作者: hucmosin 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _get_time_zone_key(subkey=None):
        "Return the registry key that stores time zone details"
        key = _RegKeyDict.open(_winreg.HKEY_LOCAL_MACHINE, TimeZoneInfo.tzRegKey)
        if subkey:
            key = key.subkey(subkey)
        return key
firefox_binary.py 文件源码 项目:devsecops-example-helloworld 作者: boozallen 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _find_exe_in_registry(self):
        try:
            from _winreg import OpenKey, QueryValue, HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER
        except ImportError:
            from winreg import OpenKey, QueryValue, HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER
        import shlex
        keys = (
           r"SOFTWARE\Classes\FirefoxHTML\shell\open\command",
           r"SOFTWARE\Classes\Applications\firefox.exe\shell\open\command"
        )
        command = ""
        for path in keys:
            try:
                key = OpenKey(HKEY_LOCAL_MACHINE, path)
                command = QueryValue(key, "")
                break
            except OSError:
                try:
                    key = OpenKey(HKEY_CURRENT_USER, path)
                    command = QueryValue(key, "")
                    break
                except OSError:
                    pass
        else:
            return ""

        if not command:
            return ""

        return shlex.split(command)[0]
ietoolbar.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def DllRegisterServer():
    comclass = IEToolbar

    # register toolbar with IE
    try:
        print "Trying to register Toolbar.\n"
        hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        subKey = _winreg.SetValueEx( hkey, comclass._reg_clsid_, 0, _winreg.REG_BINARY, "\0" )
    except WindowsError:
        print "Couldn't set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    else:
        print "Set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    # TODO: implement reg settings for standard toolbar button

# unregister plugin
ietoolbar.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def DllUnregisterServer():
    comclass = IEToolbar

    # unregister toolbar from internet explorer
    try:
        print "Trying to unregister Toolbar.\n"
        hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        _winreg.DeleteValue( hkey, comclass._reg_clsid_ )
    except WindowsError:
        print "Couldn't delete registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    else:
        print "Deleting reg key succeeded.\n"

# entry point
listener.py 文件源码 项目:uac-a-mola 作者: ElevenPaths 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _listen(self):
        """ Listen for information from a client and performs
        actions related to the windows registry """
        registry = Registry()
        listener = Listener(('localhost', self.port), authkey=self.password)
        conn = listener.accept()
        msg = conn.recv()
        if type(msg) is list and len(msg) == 2:
            # Deleting debugger key
            debug_path = self.DEBUG_KEY + msg[0]
            k = registry.open_key(HKLM, debug_path)
            registry.del_value(k, "debugger")
            # Deleting the bad path
            k = registry.open_key(HKCU, msg[1])
            if k:
                self.brush.color("[!!] POSSIBLE UAC BYPASS IN YOUR SYSTEM\n", 'RED')
                registry.delete_key(HKCU, msg[1])
                ctypes.windll.user32.MessageBoxA(
                    None, "UAC BYPASS DETECTADO Y MITIGADO. EJECUCION SEGURA DEL BINARIO", "PELIGRO!", 0)
            os.system(msg[0])
            # Setting the debugger key before breaking connection
            k = registry.open_key(HKLM, debug_path)
            payload = self.build_payload(msg[0][:-3] + "pyw")            
            registry.create_value(k,
                                  "debugger",
                                  payload)
            print "[+] Closing the listener"
            conn.close()
            listener.close()
listener.py 文件源码 项目:uac-a-mola 作者: ElevenPaths 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def add_debugger(self, registry, binlist):
        """ Adds debugger registry key for 
        each of the processes in the list """
        for binary in binlist:
            path = self.DEBUG_KEY + binary
            k = registry.open_key(HKLM, path)
            if not(k):
                k = registry.create_key(HKLM, path)
            payload = self.build_payload(binary[:-3] + "pyw")
            registry.create_value(k,
                                  "debugger",
                                  payload)
listener.py 文件源码 项目:uac-a-mola 作者: ElevenPaths 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def del_debugger(self, registry, binlist):
        """ Deletes debugger registry key for 
        each of the processes in the list """
        for binary in binlist:
            path = self.DEBUG_KEY + binary
            k = registry.open_key(HKLM, path)
            if not(k):
                return
            registry.del_value(k, "debugger")
csm.py 文件源码 项目:csm 作者: gnzsystems 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, logCallback):
        MSstore = r"Software\Microsoft\SystemCertificates"
        GPstore = r"Software\Policy\Microsoft\SystemCertificates"
        self.regKeys = {
            "CU_STORE": [reg.HKEY_CURRENT_USER, MSstore],
            "LM_STORE": [reg.HKEY_LOCAL_MACHINE, MSstore],
            "USER_STORE": [reg.HKEY_USERS, MSstore],
            "CU_POLICY_STORE": [reg.HKEY_CURRENT_USER, GPstore],
            "LM_POLICY_STORE": [reg.HKEY_LOCAL_MACHINE, GPstore]
        }
        self.logCallback = logCallback
csm.py 文件源码 项目:csm 作者: gnzsystems 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _watch_thread_dispatcher(self):
        MSstore = r"Software\Microsoft\SystemCertificates"
        GPstore = r"Software\Policy\Microsoft\SystemCertificates"
        regKeys = {
            "CU_STORE": [win32con.HKEY_CURRENT_USER, MSstore],
            "LM_STORE": [win32con.HKEY_LOCAL_MACHINE, MSstore],
            "USER_STORE": [win32con.HKEY_USERS, MSstore],
            "CU_POLICY_STORE": [win32con.HKEY_CURRENT_USER, GPstore],
            "LM_POLICY_STORE": [win32con.HKEY_LOCAL_MACHINE, GPstore]
        }
        watchKeys = self.database.get_watch_keys()
        for regKey in watchKeys:
            self._log("Dispatcher preparing watch thread for key: %s" % regKey, messageType="DEBUG")
            key = regKey.split("/")
            storeName = key.pop(0)
            additionalValue = "\\%s" % "\\".join(key)
            keystore = regKeys[storeName]
            keyName = keystore[1] + additionalValue
            t = threading.Thread(target=self._watch_thread, args=(keystore[0], keyName, regKey,
                                                                  self._watch_thread_callback,))
            self.watchThreads.append(t)
            self._log("Thread prepared.", messageType="DEBUG")
        self._log("Launching %d threads..." % len(self.watchThreads), messageType="DEBUG")
        for t in self.watchThreads:
            t.start()
        self._log("Dispatcher completed.", messageType="DEBUG")
        return
img.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def _create_win(self):
        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                r'Software\Microsoft\Windows NT\CurrentVersion\Fonts')
        except EnvironmentError:
            try:
                key = _winreg.OpenKey(
                    _winreg.HKEY_LOCAL_MACHINE,
                    r'Software\Microsoft\Windows\CurrentVersion\Fonts')
            except EnvironmentError:
                raise FontNotFound('Can\'t open Windows font registry key')
        try:
            path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
            self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
            for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
                path = self._lookup_win(key, self.font_name, STYLES[style])
                if path:
                    self.fonts[style] = ImageFont.truetype(path, self.font_size)
                else:
                    if style == 'BOLDITALIC':
                        self.fonts[style] = self.fonts['BOLD']
                    else:
                        self.fonts[style] = self.fonts['NORMAL']
        finally:
            _winreg.CloseKey(key)
firefox_binary.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _find_exe_in_registry(self):
        try:
            from _winreg import OpenKey, QueryValue, HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER
        except ImportError:
            from winreg import OpenKey, QueryValue, HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER
        import shlex
        keys = (
           r"SOFTWARE\Classes\FirefoxHTML\shell\open\command",
           r"SOFTWARE\Classes\Applications\firefox.exe\shell\open\command"
        )
        command = ""
        for path in keys:
            try:
                key = OpenKey(HKEY_LOCAL_MACHINE, path)
                command = QueryValue(key, "")
                break
            except OSError:
                try:
                    key = OpenKey(HKEY_CURRENT_USER, path)
                    command = QueryValue(key, "")
                    break
                except OSError:
                    pass
        else:
            return ""

        if not command:
            return ""

        return shlex.split(command)[0]
img.py 文件源码 项目:macos-st-packages 作者: zce 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def _create_win(self):
        try:
            key = _winreg.OpenKey(
                _winreg.HKEY_LOCAL_MACHINE,
                r'Software\Microsoft\Windows NT\CurrentVersion\Fonts')
        except EnvironmentError:
            try:
                key = _winreg.OpenKey(
                    _winreg.HKEY_LOCAL_MACHINE,
                    r'Software\Microsoft\Windows\CurrentVersion\Fonts')
            except EnvironmentError:
                raise FontNotFound('Can\'t open Windows font registry key')
        try:
            path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
            self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
            for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
                path = self._lookup_win(key, self.font_name, STYLES[style])
                if path:
                    self.fonts[style] = ImageFont.truetype(path, self.font_size)
                else:
                    if style == 'BOLDITALIC':
                        self.fonts[style] = self.fonts['BOLD']
                    else:
                        self.fonts[style] = self.fonts['NORMAL']
        finally:
            _winreg.CloseKey(key)
klasses.py 文件源码 项目:pyVirtualize 作者: rocky1109 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, scope):
        self.scope = scope
        if scope == 'user':
            self.root = winreg.HKEY_CURRENT_USER
            self.subkey = 'Environment'
        else:
            self.root = winreg.HKEY_LOCAL_MACHINE
            self.subkey = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
ietoolbar.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def DllRegisterServer():
    comclass = IEToolbar

    # register toolbar with IE
    try:
        print "Trying to register Toolbar.\n"
        hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        subKey = _winreg.SetValueEx( hkey, comclass._reg_clsid_, 0, _winreg.REG_BINARY, "\0" )
    except WindowsError:
        print "Couldn't set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    else:
        print "Set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    # TODO: implement reg settings for standard toolbar button

# unregister plugin


问题


面经


文章

微信
公众号

扫码关注公众号