コード例 #1
0
    def update_registry(self):
        a = self._db.cursor().execute(
            "SELECT branch, value, data from registry WHERE selected='*'"
        ).fetchall()
        reg = Reg()
        success = []
        errors = []
        for (key, value, data) in a:
            _key = ''
            if key == 'HKCU':
                _key = r"HKCU\Environment"
            elif key == 'HKLM':
                _key = r"HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"

            try:
                reg.write_value(_key, value, data, 'REG_SZ')
            except WindowsError:
                errors.append(value)
            else:
                success.append(value)

                path = reg.read_value(_key, 'PATH')['data']
                # print(path)
                _path = ';' + path + ';'
                _path = _path.replace(';%' + value + '%;', ';')
                _path = _path + f';%{value}%;'
                path = _path[1:-1:]
                path = path.replace(';;', ';')
                path = path.replace(';;', ';')
                try:
                    reg.write_value(_key, 'PATH', path, 'REG_SZ')
                except WindowsError:
                    errors.append(f'PATH for {value}')

        return (success, errors)
コード例 #2
0
ファイル: main.py プロジェクト: ivyana/CyberSecurity
    def enforce(self):
        f = open("rollback.txt", "w")
        reg = Reg()

        for i in range(len(structure)):
            try:
                path = (reg_key[i])[2:-1]
                y = reg.read_value(path, (reg_item[i])[2:-1])['value']
                x = reg.read_value(path, y)['data']
                print(x, file=f)

            except:
                print('-1', file=f)
                pass  # doing nothing on exception

        f.close()

        global rb
        rb = []
        with open('rollback.txt') as my_file:
            for line in my_file:
                rb.append(line.rstrip())

        for i in self.list.curselection():

                z = (item_type[i])[1:]
                if z == 'REGISTRY_SETTING':
                    path = (reg_key[i])[2:-1]
                    y = reg.read_value(path, (reg_item[i])[2:-1])['value']
                    value_data = int((val_data[i])[2:-1])
                    x = reg.read_value(path, y)['data']

                    if x != value_data:
                        reg.write_value(path, y, value_data, 'REG_DWORD')
コード例 #3
0
ファイル: main.py プロジェクト: ivyana/CyberSecurity
    def openNewWindow(self):

        newWindow = Toplevel(self)
        newWindow.title("Security Test")
        newWindow.geometry("800x400")

        newWindow.columnconfigure(1, weight=1)
        newWindow.rowconfigure(1, weight=1)

        a_file = open("test.txt", "w")

        reg = Reg()

        for i in self.list.curselection():
            try:
                z = (item_type[i])[1:]
                if z == 'REGISTRY_SETTING':
                    path = (reg_key[i])[2:-1]
                    y = reg.read_value(path, (reg_item[i])[2:-1])['value']
                    value_data = int((val_data[i])[2:-1])
                    info = (output[i])[2:-1]
                    x = reg.read_value(path, y)['data']

                    print(i + 1, ')', info, '\nreg_item:', y, file=a_file)

                    if x == value_data:
                        print('Success\n', file=a_file)
                        self.list.itemconfig(i, {'bg': 'green'})

                    else:
                        print('value_data is set to:', x, file=a_file)
                        print('value_data must be set to:', value_data, file=a_file)
                        print('Failure\n', file=a_file)
                        self.list.itemconfig(i, {'bg': 'red'})

                if z == 'USER_RIGHTS_POLICY':
                    info = (output[i])[2:-1]
                    print(i + 1, ')', info, file=a_file)
                    print('Not implemented yet.\n', file=a_file)

            except:
                print(i + 1, ')', 'Path not found.', file=a_file)
                print(path, '\n', file=a_file)
                self.list.itemconfig(i, {'bg': 'light gray'})
                pass  # doing nothing on exception

        a_file.close()

        newWindow.textBox = Text(newWindow)
        newWindow.textBox.grid(row=0, column=0, columnspan=5, rowspan=4, sticky=E + W + S + N)

        newWindow.scrollbar = Scrollbar(newWindow)
        newWindow.textBox.config(yscrollcommand=newWindow.scrollbar.set)
        newWindow.scrollbar.config(command=newWindow.textBox.yview)
        newWindow.scrollbar.grid(column=5, row=0, rowspan=4, sticky=N + S + W)

        with open('test.txt', "r") as f:
            data = f.readlines()
        for x in data:
            newWindow.textBox.insert(END, x)
コード例 #4
0
ファイル: Reg.py プロジェクト: katw3ll/vk_parser
def initReg():
    reg = Reg()
    if "vkparser" in reg.read_key(r'HKEY_CURRENT_USER\SOFTWARE')['keys']:
        writeReg("none")
        return
    reg.create_key(r'HKEY_CURRENT_USER\SOFTWARE\vkparser')
    writeReg("none")
コード例 #5
0
ファイル: main.py プロジェクト: ivyana/CyberSecurity
    def rollback(self):
        reg = Reg()
        for i in self.list.curselection():
            z = (item_type[i])[1:]
            if z == 'REGISTRY_SETTING':
                path = (reg_key[i])[2:-1]
                y = reg.read_value(path, (reg_item[i])[2:-1])['value']

                reg.write_value(path, y, int(rb[i]), 'REG_DWORD')
コード例 #6
0
ファイル: SnipeAgent.py プロジェクト: kickchong/snipe-it
def getImageVersion():
    reg = Reg()
    path = r'HKLM\SOFTWARE\TheThirdfloor'
    try:
        reg.read_key(path)
        iv = reg.read_value(path, 'ImageVersion')
        return iv['data']
    except:
        return 0
コード例 #7
0
    def rollback(self):
        reg = Reg()
        for i in range(len(structure)):
            z = (item_type[i])[1:]
            if (z == 'REGISTRY_SETTING') & (int(rb[i]) != -1):
                path = (reg_key[i])[2:-1]
                y = reg.read_value(path, (reg_item[i])[2:-1])['value']

                reg.write_value(path, y, int(rb[i]), 'REG_DWORD')
コード例 #8
0
    def enforce(self):
        reg = Reg()

        for i in self.list.curselection():

            z = (item_type[i])[1:]
            if z == 'REGISTRY_SETTING':
                path = (reg_key[i])[2:-1]
                y = reg.read_value(path, (reg_item[i])[2:-1])['value']
                value_data = int((val_data[i])[2:-1])
                x = reg.read_value(path, y)['data']

                if x != value_data:
                    reg.write_value(path, y, value_data, 'REG_DWORD')
コード例 #9
0
 def _check_chrome_version():
     """
         利用產品註冊碼找尋Chrome的版本號,並去掉最後一碼
         :return: Chrome版本號 【String】
     """
     reg = Reg()
     path = r"HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon"
     chrome_version = None
     for reg_value in reg.read_key(path)["values"]:
         if reg_value["value"].lower() == "version":
             chrome_version = reg_value["data"]
     # 去掉未一碼的version
     chrome_version = chrome_version.split(".")
     del chrome_version[-1]
     chrome_version = ".".join(chrome_version)
     return chrome_version
コード例 #10
0
ファイル: common.py プロジェクト: RomanSolomatin/PyUE4Builder
def register_project_engine(config, prompt_path=True):
    """
    Register the projects engine
    :return: True on success
    """
    reg = Reg()
    try:
        registered_engines = reg.read_key(config.UE4EngineBuildsReg)['values']
        for engine in registered_engines:
            eng_val = engine['value']  # type:str
            if eng_val.startswith('{') and eng_val.endswith('}'):
                click.secho("Removing arbitrary Engine Association {0}".format(
                    eng_val))
                reg.delete_value(config.UE4EngineBuildsReg, engine['value'])
    except Exception:
        # No entries yet, all good!
        pass

    if check_engine_dir_valid(config.UE4EnginePath):
        click.secho('Setting engine registry key {0} to {1}'.format(
            config.UE4EngineKeyName, config.UE4EnginePath))

        try:
            reg.create_key(config.UE4EngineBuildsReg)
        except Exception:
            pass
        reg.write_value(config.UE4EngineBuildsReg, config.UE4EngineKeyName,
                        config.UE4EnginePath, 'REG_SZ')
    elif prompt_path:
        my_engine_path = input('Enter Engine Path: ')
        if check_engine_dir_valid(my_engine_path):
            click.secho('Setting engine registry key {0} to {1}'.format(
                config.UE4EngineKeyName, my_engine_path))
            reg.write_value(config.UE4EngineBuildsReg, config.UE4EngineKeyName,
                            my_engine_path, 'REG_SZ')
        else:
            print_error(
                "Could not find engine path, make sure you type the full path!"
            )
            return False
    else:
        print_error("Could not find engine path!")
        return False
    return True
コード例 #11
0
ファイル: main.py プロジェクト: abhishek-aar-zz/reset-trail
class CleanReg:
    # Call the Reg instance
    r = Reg()

    def resetTrail(self, software):
        try:
            # trying to delete the value from the registry
            self.r.delete_key(software)
            print("--- Congrats, your trail period has been reset")
        except:
            # if something comeuo, then the resetting was unsuccessful
            print(f"--- Sorry. The following could be the reason:"
                  "\n\t1. You dont have {software}"
                  "\n\t2. Already has been reset")

    # The below function is gonna delete every registry value which are given in the regValue class.
    def callMe(self):
        print("Resetting trail period of these softwares:")
        keys = [attr for attr in dir(regValue) if not attr.startswith("__")]
        for i in range(len(keys)):
            print(f"{i+1}. {keys[i]}")
            self.resetTrail(getattr(regValue(), keys[i]))
コード例 #12
0
def register_project_engine(config, prompt_path=True):
    """
    Register the projects engine
    :return: True on success
    """
    reg = Reg()
    # try:
    #     registered_engines = reg.read_key(config.UE4EngineBuildsReg)['values']
    #     for engine in registered_engines:
    #         eng_val = engine['value']  # type:str
    #         if eng_val.startswith('{') and eng_val.endswith('}'):
    #             click.secho("Removing arbitrary Engine Association {0}".format(eng_val))
    #             reg.delete_value(config.UE4EngineBuildsReg, engine['value'])
    # except Exception:
    #     # No entries yet, all good!
    #     pass

    if check_engine_dir_valid(config.UE4EnginePath):
        # Check if the engine is already registered
        try:
            registered_engines = reg.read_key(config.UE4EngineBuildsReg)['values']
            for engine in registered_engines:
                if engine['value'] == config.UE4EngineKeyName:
                    # Check if the data matches the engine path, if not, update the key
                    if engine['data'] != config.UE4EnginePath:
                        click.secho('Updating engine registry key {0}:{1} to {2}'.format(config.UE4EngineKeyName,
                                                                                         engine['data'],
                                                                                         config.UE4EnginePath))
                        click.secho('This is probably because the engine has been moved.')
                        reg.write_value(config.UE4EngineBuildsReg,
                                        config.UE4EngineKeyName,
                                        config.UE4EnginePath,
                                        'REG_SZ')
                    return True
        except Exception:
            pass

        click.secho('Setting engine registry key {0} to {1}'.format(config.UE4EngineKeyName, config.UE4EnginePath))
        try:
            reg.create_key(config.UE4EngineBuildsReg)
        except Exception:
            pass
        reg.write_value(config.UE4EngineBuildsReg,
                        config.UE4EngineKeyName,
                        config.UE4EnginePath,
                        'REG_SZ')
    elif prompt_path:
        my_engine_path = input('Enter Engine Path: ')
        if check_engine_dir_valid(my_engine_path):
            click.secho('Setting engine registry key {0} to {1}'.format(config.UE4EngineKeyName, my_engine_path))
            reg.write_value(config.UE4EngineBuildsReg,
                            config.UE4EngineKeyName,
                            my_engine_path,
                            'REG_SZ')
        else:
            print_error("Could not find engine path, make sure you type the full path!")
            return False
    else:
        print_error("Could not find engine path to register!")
        return False
    return True
コード例 #13
0
ファイル: main.py プロジェクト: ivyana/CyberSecurity
    def openNewWindow(self):

        newWindow = Toplevel(self)
        newWindow.title("Security Test")
        newWindow.geometry("800x400")

        newWindow.columnconfigure(1, weight=1)
        newWindow.rowconfigure(1, weight=1)

        a_file = open("test.txt", "w")

        desc = []
        val_data = []
        reg_key = []
        reg_item = []

        for struct in structure:
            if 'description' in struct:
                desc.append(struct['description'])

            else:
                desc.append(
                    'Tag (description) does not exist for current item.')

        for struct in structure:
            if 'value_data' in struct:
                val_data.append(struct['value_data'])

            else:
                val_data.append(
                    'Tag (value_data) does not exist for current item.')

        for struct in structure:
            if 'reg_key' in struct:
                reg_key.append(struct['reg_key'])

            else:
                reg_key.append(
                    'Tag (reg_key) does not exist for current item.')

        for struct in structure:
            if 'reg_item' in struct:
                reg_item.append(struct['reg_item'])

            else:
                reg_item.append(
                    'Tag (reg_item) does not exist for current item.')

        desc = desc[3:-1]
        val_data = val_data[3:-1]
        reg_key = reg_key[3:-1]
        reg_item = reg_item[3:-1]

        reg = Reg()

        for i in range(len(desc)):
            try:

                path = (reg_key[i])[2:-1]
                y = reg.read_value(path, (reg_item[i])[2:-1])['value']
                value_data = int((val_data[i])[2:-1])
                info = (desc[i])[2:-1]
                x = reg.read_value(path, y)['data']
                print(i + 1, ')', info, '\nreg_item:', y, file=a_file)

                if x == value_data:
                    print('Success\n', file=a_file)
                else:
                    print('value_data is set to:', x, file=a_file)
                    print('value_data must be set to:',
                          value_data,
                          file=a_file)
                    print('Failure\n', file=a_file)

            except:
                print(i + 1, ')', 'Path not found.', file=a_file)
                print(path, '\n', file=a_file)
                pass  # doing nothing on exception

        a_file.close()

        newWindow.textBox = Text(newWindow)
        newWindow.textBox.grid(row=0,
                               column=0,
                               columnspan=5,
                               rowspan=4,
                               sticky=E + W + S + N)

        newWindow.scrollbar = Scrollbar(newWindow)
        newWindow.textBox.config(yscrollcommand=newWindow.scrollbar.set)
        newWindow.scrollbar.config(command=newWindow.textBox.yview)
        newWindow.scrollbar.grid(column=5, row=0, rowspan=4, sticky=N + S + W)

        with open('test.txt', "r") as f:
            data = f.readlines()
        for x in data:
            newWindow.textBox.insert(END, x)
コード例 #14
0
 def __init__(self, host=None):
     self.reg = Reg(host)
コード例 #15
0
    def openFile(self):
        global output
        output = []
        global item_type
        item_type = []
        global val_data
        val_data = []
        global reg_key
        reg_key = []
        global reg_item
        reg_item = []

        file = filedialog.askopenfile(mode="r", filetypes=(("Audit files", "*.audit"), ("All files", "*.*")))

        if not file:
            return

        if file:
            output = []

        f = open(file.name, "r")

        global structure

        structure = []
        structure = parse_audit_file(f.read())

        structure = structure[3:]

        for struct in structure:
            if 'description' in struct:
                output.append(struct['description'])
            else:
                output.append('Tag (description) does not exist for current item.')

        for struct in structure:
            if 'type' in struct:
                item_type.append(struct['type'])
            else:
                item_type.append('Tag (type) does not exist for current item.')

        for struct in structure:
            if 'value_data' in struct:
                val_data.append(struct['value_data'])
            else:
                val_data.append('Tag (value_data) does not exist for current item.')

        for struct in structure:
            if 'reg_key' in struct:
                reg_key.append(struct['reg_key'])
            else:
                reg_key.append('Tag (reg_key) does not exist for current item.')

        for struct in structure:
            if 'reg_item' in struct:
                reg_item.append(struct['reg_item'])
            else:
                reg_item.append('Tag (reg_item) does not exist for current item.')
        '''
        output = output[3:-1]
        item_type = item_type[3:-1]
        val_data = val_data[3:-1]
        reg_key = reg_key[3:-1]
        reg_item = reg_item[3:-1]
        '''

        f = open("rollback.txt", "w")
        reg = Reg()

        for i in range(len(structure)):
            try:
                path = (reg_key[i])[2:-1]
                y = reg.read_value(path, (reg_item[i])[2:-1])['value']
                x = reg.read_value(path, y)['data']
                print(x, file=f)

            except:
                print('-1', file=f)
                pass  # doing nothing on exception

        f.close()

        global rb
        rb = []
        with open('rollback.txt') as my_file:
            for line in my_file:
                rb.append(line.rstrip())

        # print(rb)

        values = StringVar()
        values.set(output)

        form = '{}'

        self.list.delete(0, END)

        for (text) in output:
            self.list.insert(END, form.format(text))

        self.listContent = self.list.get(0, END)
コード例 #16
0
    def setup_engine_paths(self, custom_engine_path=''):
        # Assume the engine is just back from our project directory. Or check the registry to see where
        # it actually resides.
        if self.UE4EnginePath != '' and custom_engine_path == '':
            return True  # No need, already setup

        result = True
        # Initially do the obvious search, one path back from the project directory
        self.UE4EnginePath = os.path.abspath(
            os.path.join(self.uproject_dir_path, self.engine_path_name))
        if custom_engine_path != '':
            self.UE4EnginePath = custom_engine_path
        if self.UE4EngineKeyName != '' and not os.path.isdir(
                self.UE4EnginePath):
            # search the registry and see if the engine is registered elsewhere
            reg = Reg()
            try:
                registered_engines = reg.read_key(
                    self.UE4EngineBuildsReg)['values']
                for engine in registered_engines:
                    if engine['value'] == self.UE4EngineKeyName:
                        # this is it!
                        self.UE4EnginePath = engine['data']
                        break
                else:
                    self.UE4EnginePath = ''
                    result = False
            except Exception:
                # No keys exist, fresh install!
                self.UE4EnginePath = ''
                result = False
        else:
            result = check_engine_dir_valid(self.UE4EnginePath)

        if result:
            self.editor_running = is_editor_running(self.UE4EnginePath)

        # Set all absolute paths to unreal tools
        self.UE4GenProjFilesPath = str(
            Path(self.UE4EnginePath,
                 'Engine\\Build\\BatchFiles\\GenerateProjectFiles.bat'))
        self.UE4GitDependenciesPath = str(
            Path(self.UE4EnginePath,
                 'Engine\\Binaries\\DotNET\\GitDependencies.exe'))
        self.UE4EnginePrereqPath = str(
            Path(self.UE4EnginePath,
                 'Engine\\Extras\\Redist\\en-us\\UE4PrereqSetup_x64.exe'))
        self.UE4UBTPath = str(
            Path(self.UE4EnginePath,
                 'Engine\\Binaries\\DotNET\\UnrealBuildTool.exe'))
        self.UE4RunUATBatPath = str(
            Path(self.UE4EnginePath, 'Engine\\Build\\BatchFiles\\RunUAT.bat'))
        self.UE4BuildBatchPath = str(
            Path(self.UE4EnginePath, 'Engine\\Build\\BatchFiles\\Build.bat'))
        self.UE4CleanBatchPath = str(
            Path(self.UE4EnginePath, 'Engine\\Build\\BatchFiles\\Clean.bat'))
        self.UE4EditorPath = str(
            Path(self.UE4EnginePath, 'Engine\\Binaries\\Win64\\UE4Editor.exe'))
        self.UE4VersionSelectorPath = str(
            Path(
                self.UE4EnginePath,
                'Engine\\Binaries\\Win64\\UnrealVersionSelector-Win64-Shipping.exe'
            ))
        return result
コード例 #17
0
 def _load_from_windows(self):
     reg = Reg()
     path = r"HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
     self._reg_hklm = reg.read_key(path)['values']
     path = r"HKCU\Environment"
     self._reg_hkcu = reg.read_key(path)['values']
コード例 #18
0
ファイル: main.py プロジェクト: sgilissen/RevengeArcadeAPI
__license__ = 'MIT'
__version__ = '0.0.1'

# ---------------------------------------------------------
# MODULE IMPORTS
# ---------------------------------------------------------
import os
import threading

from PIL import Image
from winregistry import WinRegistry as Reg
from tornado.web import Application, RequestHandler
from tornado.ioloop import IOLoop
from pystray import Icon, Menu, MenuItem

registry = Reg()
reg_path = r'HKCU\Software\ONIROS\Revenge'
image = Image.open("trayicon.png")

# ---------------------------------------------------------
# THREADS
# ---------------------------------------------------------
thread = threading.Thread(daemon=True, target=lambda: Icon(
    'Brixel Revenge API',
    image,
    title='Brixel Revenge API',
    menu=Menu(
        MenuItem(
            'Exit',
            lambda icon, item: kill_app(icon)))).run())
thread.start()
コード例 #19
0
 def __init__(self):
     self._reg: Reg = Reg()
コード例 #20
0
ファイル: truerng_test.py プロジェクト: euler357/TrueRNG
    def get_Truerngs_from_registry():
        reg = Reg()

        usb_serial_devices = reg.read_key(
            r'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbser\Enum'
        )

        devices_values = usb_serial_devices["values"]

        serialNumber = 'None'

        index = 0
        devicesFound = []

        # Loop through
        for x in devices_values:
            try:
                serialNumber = 'None'
                # TrueRNG V1/V2/V3
                if 'VID_04D8&PID_F5FE' in x["data"]:
                    temp = x["data"].split('\\')
                    vidpid = temp[1]
                    keyid = temp[2]
                    newkey = 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\' + str(
                        vidpid) + '\\' + str(keyid)
                    device_info = reg.read_key(newkey)["values"]
                    deviceType = 'TrueRNG V1/V2/V3'
                    for k in device_info:
                        if k['value'] == "FriendlyName":
                            FriendlyName = k['data']
                        if k['value'] == "HardwareID":
                            vidpidrev = k['data'][0].split('\\')[1].split('&')
                    devicesFound.append(deviceType + ' : ' + \
                        vidpidrev[2] + ' : No SN : ' + FriendlyName)

                # TrueRNGpro (FW > 1.39)
                # USB Class 0A
                if 'VID_16D0&PID_0AA0\\' in x["data"]:
                    temp = x["data"].split('\\')
                    vidpid = temp[1]
                    keyid = temp[2]
                    newkey = 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\' + str(
                        vidpid) + '\\' + str(keyid)
                    device_info = reg.read_key(newkey)["values"]
                    deviceType = 'TrueRNGpro (V1) '
                    for k in device_info:
                        if k['value'] == "FriendlyName":
                            FriendlyName = k['data']
                        if k['value'] == "HardwareID":
                            vidpidrev = k['data'][0].split('\\')[1].split('&')
                    devicesFound.append(deviceType + ' : ' + \
                        vidpidrev[2] + ' : ' + keyid + ' : ' + FriendlyName)

                # TrueRNGpro (FW <= 1.39)
                # USB Class 02
                if 'VID_16D0&PID_0AA0&MI_00\\' in x["data"]:
                    temp = x["data"].split('\\')
                    vidpid = temp[1]
                    keyid = temp[2]
                    newkey = 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\' + str(
                        vidpid) + '\\' + str(keyid)
                    device_info = reg.read_key(newkey)["values"]
                    deviceType = 'TrueRNGpro (V1) '
                    for k in device_info:
                        if k['value'] == "FriendlyName":
                            FriendlyName = k['data']
                        if k['value'] == "HardwareID":
                            vidpidrev = k['data'][0].split('\\')[1].split('&')

                    # Find the info of the parent device since Windows doesn't populate the serial number into the child
                    newkey = 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_16D0&PID_0AA0'
                    device_keys = reg.read_key(newkey)['keys']
                    # Iterate through the keys to find our device by it's key id
                    for j in device_keys:
                        newkey = 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_16D0&PID_0AA0\\' + j
                        temp_device = reg.read_key(newkey)['values']
                        for a in temp_device:
                            if 'ParentIdPrefix' in a['value']:
                                # If we have the right key entry
                                if a['data'] in keyid:
                                    serialNumber = j
                    if serialNumber != 'None':
                        devicesFound.append(deviceType + ' : ' + \
                            vidpidrev[2] + ' : ' + serialNumber + ' : ' + FriendlyName)
                    else:
                        devicesFound.append(deviceType + ' : ' + \
                            vidpidrev[2] + ' : ' + keyid + ' : ' + FriendlyName)

                # TrueRNGpro V2 (FW > 1.39)
                # USB Class 0A
                if 'VID_04D8&PID_EBB5' in x["data"]:
                    temp = x["data"].split('\\')
                    vidpid = temp[1]
                    keyid = temp[2]
                    newkey = 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\' + str(
                        vidpid) + '\\' + str(keyid)
                    device_info = reg.read_key(newkey)["values"]
                    deviceType = 'TrueRNGpro (V2) '
                    for k in device_info:
                        if k['value'] == "FriendlyName":
                            FriendlyName = k['data']
                        if k['value'] == "HardwareID":
                            vidpidrev = k['data'][0].split('\\')[1].split('&')
                    devicesFound.append(deviceType + ' : ' + \
                        vidpidrev[2] + ' : ' + keyid + ' : ' + FriendlyName)

            except:
                i = 1
        return devicesFound
コード例 #21
0
#
from winregistry import WinRegistry as Reg
from pprint import pprint
reg = Reg()

print("-" * 10)

path = r'HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0'
try:
    print(f"Attempting to read {path}")
    pprint(reg.read_key(path), width=100)
except:
    pass

print("-" * 10)

path = r'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\4.0'
try:
    print(f"Attempting to read {path}")
    pprint(reg.read_key(path), width=100)
except:
    pass

print("-" * 10)