Beispiel #1
0
 def hide_user(self, username):
     keypath = ("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
                "\\Winlogon\\SpecialAccounts")
     winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, keypath)
     keypath = keypath + "\\UserList"
     with winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, keypath) as key:
         winreg.SetValueEx(key, username, 0, winreg.REG_DWORD, 0)
Beispiel #2
0
    def set_config_value(self, name, value, section=None):
        key_name = self._get_config_key_name(section)

        with winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, key_name) as key:
            if type(value) == int:
                regtype = winreg.REG_DWORD
            else:
                regtype = winreg.REG_SZ
            winreg.SetValueEx(key, name, 0, regtype, value)
Beispiel #3
0
    def _set_registry_ga_params(install_version, install_timestamp):
        with winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE,
                              "SOFTWARE\\Microsoft\\GuestAgent") as key:

            install_version_str = "%s.%s.%s.%s" % install_version
            winreg.SetValueEx(key, "Incarnation", 0, winreg.REG_SZ,
                              install_version_str)

            install_timestamp_str = install_timestamp.strftime(
                '%m/%d/%Y %I:%M:%S %p')
            winreg.SetValueEx(key, "VmProvisionedAt", 0, winreg.REG_SZ,
                              install_timestamp_str)
Beispiel #4
0
    def set_password(self, service, username, password):
        """Write the password to the registry
        """
        # encrypt the password
        password_encrypted = _win_crypto.encrypt(password.encode('utf-8'))
        # encode with base64
        password_base64 = base64.encodestring(password_encrypted)
        # encode again to unicode
        password_saved = password_base64.decode('ascii')

        # store the password
        key_name = self._key_for_service(service)
        hkey = winreg.CreateKey(winreg.HKEY_CURRENT_USER, key_name)
        winreg.SetValueEx(hkey, username, 0, winreg.REG_SZ, password_saved)
Beispiel #5
0
 def _set_registry_vm_type(vm_type="IAAS"):
     with winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE,
                           "SOFTWARE\\Microsoft\\Windows Azure") as key:
         winreg.SetValueEx(key, "VMType", 0, winreg.REG_SZ, vm_type)
Beispiel #6
0
 def set_uac_remote_restrictions(self, enable=True):
     with winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE,
                           self._SYSTEM_POLICIES_KEY) as key_name:
         winreg.SetValueEx(key_name, self._LATFP_VALUE_NAME, 0,
                           winreg.REG_DWORD, int(not enable))