Python _winreg 模块,KEY_ALL_ACCESS 实例源码

我们从Python开源项目中,提取了以下39个代码示例,用于说明如何使用_winreg.KEY_ALL_ACCESS

项目:purelove    作者:hucmosin    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        run_key = r'Software\Microsoft\Windows\CurrentVersion\Run'

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    # self delete 
    os.remove(sys.argv[0])
    sys.exit(0)
项目:purelove    作者:hucmosin    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        run_key = r'Software\Microsoft\Windows\CurrentVersion\Run'

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    os.remove(sys.argv[0])
    sys.exit(0)
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def __init__(self):
        icon_path = os.path.join(os.path.dirname(__file__), "web_ui", "favicon.ico")
        self.systray = SysTrayIcon(icon_path, "XX-Net", 
            self.make_menu(), self.on_quit, left_click=self.on_show, right_click=self.on_right_click)

        reg_path = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
        self.INTERNET_SETTINGS = winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_path, 0, winreg.KEY_ALL_ACCESS)

        proxy_setting = config.get(["modules", "launcher", "proxy"], "pac")
        if proxy_setting == "pac":
            self.on_enable_pac()
        elif proxy_setting == "gae":
            self.on_enable_gae_proxy()
        elif proxy_setting == "disable":
            # Don't disable proxy setting, just do nothing.
            pass
        else:
            xlog.warn("proxy_setting:%r", proxy_setting)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def __init__(self):
        icon_path = os.path.join(os.path.dirname(__file__), "web_ui", "favicon.ico")
        self.systray = SysTrayIcon(icon_path, "XX-Net", 
            self.make_menu(), self.on_quit, left_click=self.on_show, right_click=self.on_right_click)

        reg_path = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
        self.INTERNET_SETTINGS = winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_path, 0, winreg.KEY_ALL_ACCESS)

        proxy_setting = config.get(["modules", "launcher", "proxy"], "pac")
        if proxy_setting == "pac":
            self.on_enable_pac()
        elif proxy_setting == "gae":
            self.on_enable_gae_proxy()
        elif proxy_setting == "disable":
            # Don't disable proxy setting, just do nothing.
            pass
        else:
            xlog.warn("proxy_setting:%r", proxy_setting)
项目:cuckoo-headless    作者:evandowning    | 项目源码 | 文件源码
def rename_regkey(skey, ssubkey, dsubkey):
    """Rename an entire tree of values in the registry.
    Function by Thorsten Sick."""
    res_handle = HANDLE()
    options = DWORD(0)
    res = RegOpenKeyExW(
        skey, ssubkey, options, _winreg.KEY_ALL_ACCESS, byref(res_handle)
    )
    if not res:
        bsize = c_ushort(len(dsubkey) * 2)
        us = UNICODE_STRING()
        us.Buffer = c_wchar_p(dsubkey)
        us.Length = bsize
        us.MaximumLength = bsize

        res = NtRenameKey(res_handle, pointer(us))
        if res:
            log.warning("Error renaming %s\\%s to %s (0x%x)",
                        skey, ssubkey, dsubkey, res % 2**32)

    if res_handle:
        RegCloseKey(res_handle)
项目:cuckoo-headless    作者:evandowning    | 项目源码 | 文件源码
def set_regkey(rootkey, subkey, name, type_, value):
    if type_ == _winreg.REG_SZ:
        value = unicode(value)
        length = len(value) * 2 + 2
    elif type_ == _winreg.REG_MULTI_SZ:
        value = u"\u0000".join(value) + u"\u0000\u0000"
        length = len(value) * 2 + 2
    elif type_ == _winreg.REG_DWORD:
        value = struct.pack("I", value)
        length = 4
    else:
        length = len(value)

    res_handle = HANDLE()
    res = RegCreateKeyExW(
        rootkey, subkey, 0, None, 0, _winreg.KEY_ALL_ACCESS,
        0, byref(res_handle), None
    )
    if not res:
        RegSetValueExW(res_handle, name, 0, type_, value, length)
        RegCloseKey(res_handle)
项目:MrRAT    作者:user696    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    # self delete basicRAT
    os.remove(sys.argv[0])
    sys.exit(0)
项目:bloodyshell    作者:deadPix3l    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        run_key = r'Software\Microsoft\Windows\CurrentVersion\Run'

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    # self delete basicRAT
    os.remove(sys.argv[0])
    sys.exit(0)
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def __init__(self):
        icon_path = os.path.join(os.path.dirname(__file__), "web_ui", "favicon.ico")
        self.systray = SysTrayIcon(icon_path, "XX-Net", 
            self.make_menu(), self.on_quit, left_click=self.on_show, right_click=self.on_right_click)

        reg_path = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
        self.INTERNET_SETTINGS = winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_path, 0, winreg.KEY_ALL_ACCESS)

        proxy_setting = config.get(["modules", "launcher", "proxy"], "pac")
        if proxy_setting == "pac":
            self.on_enable_pac()
        elif proxy_setting == "gae":
            self.on_enable_gae_proxy()
        elif proxy_setting == "disable":
            # Don't disable proxy setting, just do nothing.
            pass
        else:
            xlog.warn("proxy_setting:%r", proxy_setting)
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def __getitem__(self, key):
        bReturnType=False
        if (type(key) is tuple) and (len(key)==1):
            key = key[0]
            bReturnType=True
            # is it data?
        try:
            return self.massageIncomingRegistryValue(_winreg.QueryValueEx(self.keyhandle, key),bReturnType)
        except:
            if key == '':
                # Special case: this dictionary key means "default value"
                raise KeyError, key
            pass
            # it's probably a registry key then
        try:
            return RegistryDict(self.keyhandle, key, _winreg.KEY_ALL_ACCESS)
        except:
            pass
            # must not be there
        raise KeyError, key
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def __init__(self):
        icon_path = os.path.join(os.path.dirname(__file__), "web_ui", "favicon.ico")
        self.systray = SysTrayIcon(icon_path, "XX-Net", 
            self.make_menu(), self.on_quit, left_click=self.on_show, right_click=self.on_right_click)

        reg_path = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
        self.INTERNET_SETTINGS = winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_path, 0, winreg.KEY_ALL_ACCESS)

        proxy_setting = config.get(["modules", "launcher", "proxy"], "pac")
        if proxy_setting == "pac":
            self.on_enable_pac()
        elif proxy_setting == "gae":
            self.on_enable_gae_proxy()
        elif proxy_setting == "disable":
            # Don't disable proxy setting, just do nothing.
            pass
        else:
            xlog.warn("proxy_setting:%r", proxy_setting)
项目:depot_tools    作者:webrtc-uwp    | 项目源码 | 文件源码
def EnableCrashDumpCollection():
  """Tell Windows Error Reporting to record crash dumps so that we can diagnose
  linker crashes and other toolchain failures. Documented at:
  https://msdn.microsoft.com/en-us/library/windows/desktop/bb787181.aspx
  """
  if sys.platform == 'win32' and os.environ.get('CHROME_HEADLESS') == '1':
    key_name = r'SOFTWARE\Microsoft\Windows\Windows Error Reporting'
    try:
      key = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, key_name, 0,
                               winreg.KEY_WOW64_64KEY | winreg.KEY_ALL_ACCESS)
      # Merely creating LocalDumps is sufficient to enable the defaults.
      winreg.CreateKey(key, "LocalDumps")
      # Disable the WER UI, as documented here:
      # https://msdn.microsoft.com/en-us/library/windows/desktop/bb513638.aspx
      winreg.SetValueEx(key, "DontShowUI", 0, winreg.REG_DWORD, 1)
    # Trap OSError instead of WindowsError so pylint will succeed on Linux.
    # Catching errors is important because some build machines are not elevated
    # and writing to HKLM requires elevation.
    except OSError:
      pass
项目:basicRAT    作者:vesche    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        run_key = r'Software\Microsoft\Windows\CurrentVersion\Run'

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    # self delete basicRAT
    os.remove(sys.argv[0])
    sys.exit(0)
项目:keyrings.alt    作者:jaraco    | 项目源码 | 文件源码
def _delete_key_if_empty(self, service):
        key_name = r'Software\%s\Keyring' % service
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_name, 0,
            winreg.KEY_ALL_ACCESS)
        try:
            winreg.EnumValue(key, 0)
            return
        except WindowsError:
            pass
        winreg.CloseKey(key)

        # it's empty; delete everything
        while key_name != 'Software':
            parent, sep, base = key_name.rpartition('\\')
            key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, parent, 0,
                winreg.KEY_ALL_ACCESS)
            winreg.DeleteKey(key, base)
            winreg.CloseKey(key)
            key_name = parent
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self, parent, name):
        self.parent, self.name = parent, name
        self.level=parent.level+1
        # ! ! ! opens keys in read/write mode ! ! !
        self.wrk=reg.OpenKey(parent.wrk, self.name, 0, reg.KEY_ALL_ACCESS)
        self._keys = self._vals = None
项目:NinjaRipperMayaImportTools    作者:T-Maxxx    | 项目源码 | 文件源码
def setupRegister():
    global RegisterKey
    try:
        RegisterKey = reg.OpenKey(
            reg.HKEY_CURRENT_USER,
            "SOFTWARE\\Autodesk\\MayaPlugins\\NinjaRipperMayaImportTools",
            0,
            reg.KEY_ALL_ACCESS
        )
    except WindowsError:
        RegisterKey = reg.CreateKey(
            reg.HKEY_CURRENT_USER,
            "SOFTWARE\\Autodesk\\MayaPlugins\\NinjaRipperMayaImportTools"
        )
        regSetBool("NR_AutoMode", True)
        regSetString("InitialDirectory", "")
        # regSetDword("NR_VertexLayout_PosX", 0)
        # regSetDword("NR_VertexLayout_PosY", 1)
        # regSetDword("NR_VertexLayout_PosZ", 2)
        regSetDword("NR_VertexLayout_NmlX", 3)
        regSetDword("NR_VertexLayout_NmlY", 4)
        regSetDword("NR_VertexLayout_NmlZ", 5)
        regSetDword("NR_VertexLayout_TCU", 6)
        regSetDword("NR_VertexLayout_TCV", 7)
        regSetFloat("NR_TransformScale", 100.0)
        regSetFloat("NR_TransformRotateX", 90.0)
        regSetFloat("NR_TransformRotateY", 0.0)
        regSetFloat("NR_TransformRotateZ", 0.0)
        regSetFloat("NR_TransformUVScale", 1.0)
        regSetDword("NR_MiscTextureNumber", 0)
        regSetDword("NR_MiscFlipUV", 0)
        regSetBool("NR_MiscNormalizeUV", False)
        regSetBool("NR_MiscReverseNormals", False)
        regSetBool('NR_MiscImportAnything', False)
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def get_runonce():
        return _winreg.OpenKey(_registry,
                r"Software\Microsoft\Windows\CurrentVersion\Run", 0,
        _winreg.KEY_ALL_ACCESS)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def get_runonce():
        return _winreg.OpenKey(_registry,
                r"Software\Microsoft\Windows\CurrentVersion\Run", 0,
        _winreg.KEY_ALL_ACCESS)
项目:pyVirtualize    作者:rocky1109    | 项目源码 | 文件源码
def setenv(self, name, value):
        # Note: for 'system' scope, you must run this as Administrator
        key = winreg.OpenKey(self.root, self.subkey, 0, winreg.KEY_ALL_ACCESS)
        winreg.SetValueEx(key, name, 0, winreg.REG_EXPAND_SZ, value)
        winreg.CloseKey(key)
        # For some strange reason, calling SendMessage from the current process
        # doesn't propagate environment changes at all.
        # TODO: handle CalledProcessError (for assert)
        check_call('''\
"%s" -c "import win32api, win32con; assert win32api.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, 'Environment')"''' % sys.executable)
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def regload(path, leaf):
    key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path, 0,
                          _winreg.KEY_ALL_ACCESS)
    try:
        value = _winreg.QueryValueEx(key, leaf)[0]
    except WindowsError:
        value = None
    return value
项目:plugin.video.streamondemand-pureita    作者:orione7    | 项目源码 | 文件源码
def regload(path, leaf):
    key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path, 0,
                          _winreg.KEY_ALL_ACCESS)
    try:
        value = _winreg.QueryValueEx(key, leaf)[0]
    except WindowsError:
        value = None
    return value
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def get_runonce():
        return _winreg.OpenKey(_registry,
                r"Software\Microsoft\Windows\CurrentVersion\Run", 0,
        _winreg.KEY_ALL_ACCESS)
项目:wpkg-gp-client    作者:sonicnkt    | 项目源码 | 文件源码
def SetRebootPendingTime(reset=False):
    if reset:
        now = "None"
    else:
        now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    with _winreg.CreateKeyEx(_winreg.HKEY_LOCAL_MACHINE, R"SOFTWARE\Wpkg-GP-Client", 0,
                             _winreg.KEY_ALL_ACCESS | _winreg.KEY_WOW64_64KEY) as key:
        _winreg.SetValueEx(key, "RebootPending", 0, _winreg.REG_EXPAND_SZ, now)
项目:wpkg-gp-client    作者:sonicnkt    | 项目源码 | 文件源码
def ReadRebootPendingTime():
    with _winreg.CreateKeyEx(_winreg.HKEY_LOCAL_MACHINE, R"SOFTWARE\Wpkg-GP-Client", 0,
                             _winreg.KEY_ALL_ACCESS | _winreg.KEY_WOW64_64KEY) as key:
        try:
            reboot_pending_value = _winreg.QueryValueEx(key, "RebootPending")[0]
        except WindowsError:
            return None
    try:
        reboot_pending_time = datetime.datetime.strptime(reboot_pending_value, '%Y-%m-%d %H:%M:%S')
    except (ValueError, TypeError):
        return None
    return reboot_pending_time
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def iteritems_children(self, access=_winreg.KEY_ALL_ACCESS):
        i = 0
        try:
            while 1:
                s = _winreg.EnumKey(self.keyhandle, i)
                yield s, RegistryDict(self.keyhandle, [s], access)
                i += 1
        except:
            pass
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def iteritems(self, access=_winreg.KEY_ALL_ACCESS):
    # yield children
        for item in self.iteritems_data():
            yield item
        for item in self.iteritems_children(access):
            yield item
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def iterkeys_children(self, access=_winreg.KEY_ALL_ACCESS):
        for key, value in self.iteritems_children(access):
            yield key
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def itervalues_children(self, access=_winreg.KEY_ALL_ACCESS):
        for key, value in self.iteritems_children(access):
            yield value
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def items(self, access=_winreg.KEY_ALL_ACCESS):
        return list(self.iteritems())
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def values(self, access=_winreg.KEY_ALL_ACCESS):
        return list(self.itervalues(access))
项目:kodi-tk_del    作者:hubsif    | 项目源码 | 文件源码
def regload(path, leaf):
    key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path, 0,
                          _winreg.KEY_ALL_ACCESS)
    try:
        value = _winreg.QueryValueEx(key, leaf)[0]
    except WindowsError:
        value = None
    return value
项目:TC2017    作者:G4lB1t    | 项目源码 | 文件源码
def create_reg_val(k, v_name, v_data):
    """
    create and set registry value
    currently supports only 32bit machines and HKLM registry keys and values
    """
    print "\t+ creating {0}".format(k, "\\", v_name)
    try:
        kh = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, k, 0, wreg.KEY_ALL_ACCESS)
        wreg.SetValueEx(kh, v_name, 0, wreg.REG_SZ, v_data)
        print "\t+ {0} was created!\n".format(k, "\\", v_name)
    except Exception as e:
        error_on_create(k + "\\" + v_name, e)
项目:Python-Rootkit    作者:islamTaha12    | 项目源码 | 文件源码
def set_reg_key_value(REG_PATH, name, value):
    try:
        registry_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, REG_PATH, 0,_winreg.KEY_ALL_ACCESS)
        _winreg.SetValueEx(registry_key, name, 0, _winreg.REG_SZ, value)
    except WindowsError:
        pass
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def setEnvironment(scope, name, value):
    assert scope in ('user', 'system')
    #INFO_MSG('set environment: name=%s, value=%s' % (name, value))

    if platform.system() == 'Windows':
        root, subkey = getWindowsEnvironmentKey(scope)
        # Note: for 'system' scope, you must run this as Administrator
        key = winreg.OpenKey(root, subkey, 0, winreg.KEY_ALL_ACCESS)
        winreg.SetValueEx(key, name, 0, winreg.REG_EXPAND_SZ, value)
        winreg.CloseKey(key)
    else:
        if name.lower() == 'uid':
            uid, username = value
            if uid != str(os.geteuid()):
                ret, cret = syscommand('bash -c \'usermod -d /home/%s/ -u %s %s\'' % (pwd.getpwnam(username).pw_dir, uid, username), True)
                INFO_MSG(ret)
                INFO_MSG(cret)
            return

        userhome = "~"
        if len(os_user_name) > 0:
            userhome = pwd.getpwnam(os_user_name).pw_dir 

        f = open('%s/.bashrc' % userhome, 'a')
        f.write("export %s=%s\n\n" % (name, value))
        f.close()

        if os.geteuid() > 0:
            syscommand('bash -c \'source %s/.bashrc\'' % userhome, False)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def remmoveEnvironment(scope, name):
    assert scope in ('user', 'system')

    if platform.system() == 'Windows':
        root, subkey = getWindowsEnvironmentKey(scope)
        key = winreg.OpenKey(root, subkey, 0, winreg.KEY_ALL_ACCESS)

        try:
            winreg.DeleteValue(key, name)
        except WindowsError:
            pass
    else:
        removeLinuxEnvironment(scope, name)
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def get_runonce():
        return _winreg.OpenKey(_registry,
                r"Software\Microsoft\Windows\CurrentVersion\Run", 0,
        _winreg.KEY_ALL_ACCESS)
项目:addon    作者:alfa-addon    | 项目源码 | 文件源码
def regload(path, leaf):
    key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path, 0,
                          _winreg.KEY_ALL_ACCESS)
    try:
        value = _winreg.QueryValueEx(key, leaf)[0]
    except WindowsError:
        value = None
    return value
项目:BruteXSS    作者:rajeshmajumdar    | 项目源码 | 文件源码
def regload(path, leaf):
    key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path, 0,
                          _winreg.KEY_ALL_ACCESS)
    try:
        value = _winreg.QueryValueEx(key, leaf)[0]
    except WindowsError:
        value = None
    return value
项目:keyrings.alt    作者:jaraco    | 项目源码 | 文件源码
def delete_password(self, service, username):
        """Delete the password for the username of the service.
        """
        try:
            key_name = r'Software\%s\Keyring' % service
            hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_name, 0,
                winreg.KEY_ALL_ACCESS)
            winreg.DeleteValue(hkey, username)
            winreg.CloseKey(hkey)
        except WindowsError:
            e = sys.exc_info()[1]
            raise PasswordDeleteError(e)
        self._delete_key_if_empty(service)