Exemple #1
0
    def login_msg(self, username, ip=None):
        data = dict()
        data['type'] = 'LOGIN'
        data['username'] = username
        data['ipAddresses'] = str(
            System.Hardware.Network.ip_addresses()).replace('[', '').replace(
                ']', '')
        data['timestamp'] = Util.timestamp()
        data['userIp'] = ip
        data['osVersion'] = System.Os.version()
        data['diskTotal'] = System.Hardware.Disk.total()
        data['diskUsed'] = System.Hardware.Disk.used()
        data['diskFree'] = System.Hardware.Disk.free()
        data['memory'] = System.Hardware.Memory.total()
        data['hostname'] = str(System.Os.hostname())
        data['agentVersion'] = str(Util.get_agent_version())

        self.logger.debug('USER IP : ' + str(ip) + ' IPADDRESSES : ' +
                          str(System.Hardware.Network.ip_addresses()).replace(
                              '[', '').replace(']', ''))

        data['hardware.monitors'] = str(System.Hardware.monitors()),
        data['hardware.screens'] = str(System.Hardware.screens()),
        data['hardware.usbDevices'] = str(System.Hardware.usb_devices()),
        data['hardware.printers'] = str(System.Hardware.printers()),
        data['hardware.systemDefinitions'] = str(
            System.Hardware.system_definitions()),

        json_data = json.dumps(data)
        self.logger.debug('Login message was created')
        return json_data
Exemple #2
0
    def get_registration_params(self):
        parts = []
        for part in System.Hardware.Disk.partitions():
            parts.append(part[0])

        params = {
            'ipAddresses':
            str(System.Hardware.Network.ip_addresses()).replace('[',
                                                                '').replace(
                                                                    ']', ''),
            'macAddresses':
            str(System.Hardware.Network.mac_addresses()).replace('[',
                                                                 '').replace(
                                                                     ']', ''),
            'hostname':
            System.Os.hostname(),
            'os.name':
            System.Os.name(),
            'os.version':
            System.Os.version(),
            'os.kernel':
            System.Os.kernel_release(),
            'os.distributionName':
            System.Os.distribution_name(),
            'os.distributionId':
            System.Os.distribution_id(),
            'os.distributionVersion':
            System.Os.distribution_version(),
            'os.architecture':
            System.Os.architecture(),
            'hardware.cpu.architecture':
            System.Hardware.Cpu.architecture(),
            'hardware.cpu.logicalCoreCount':
            System.Hardware.Cpu.logical_core_count(),
            'hardware.cpu.physicalCoreCount':
            System.Hardware.Cpu.physical_core_count(),
            'hardware.disk.total':
            System.Hardware.Disk.total(),
            'hardware.disk.used':
            System.Hardware.Disk.used(),
            'hardware.disk.free':
            System.Hardware.Disk.free(),
            'hardware.disk.partitions':
            str(parts),
            'hardware.monitors':
            str(System.Hardware.monitors()),
            'hardware.screens':
            str(System.Hardware.screens()),
            'hardware.usbDevices':
            str(System.Hardware.usb_devices()),
            'hardware.printers':
            str(System.Hardware.printers()),
            'hardware.systemDefinitions':
            str(System.Hardware.system_definitions()),
            'hardware.model.version':
            str(System.Hardware.machine_model()),
            'hardware.memory.total':
            System.Hardware.Memory.total(),
            'hardware.network.ipAddresses':
            str(System.Hardware.Network.ip_addresses()),
            'sessions.userNames':
            str(System.Sessions.user_name()),
            'bios.releaseDate':
            System.BIOS.release_date()[1].replace('\n', '')
            if System.BIOS.release_date()[0] == 0 else 'n/a',
            'bios.version':
            System.BIOS.version()[1].replace('\n', '')
            if System.BIOS.version()[0] == 0 else 'n/a',
            'bios.vendor':
            System.BIOS.vendor()[1].replace('\n', '')
            if System.BIOS.vendor()[0] == 0 else 'n/a',
            'hardware.baseboard.manufacturer':
            System.Hardware.BaseBoard.manufacturer()[1].replace('\n', '')
            if System.Hardware.BaseBoard.manufacturer()[0] == 0 else 'n/a',
            'hardware.baseboard.version':
            System.Hardware.BaseBoard.version()[1].replace('\n', '')
            if System.Hardware.BaseBoard.version()[0] == 0 else 'n/a',
            'hardware.baseboard.assetTag':
            System.Hardware.BaseBoard.asset_tag()[1].replace('\n', '')
            if System.Hardware.BaseBoard.asset_tag()[0] == 0 else 'n/a',
            'hardware.baseboard.productName':
            System.Hardware.BaseBoard.product_name()[1].replace('\n', '')
            if System.Hardware.BaseBoard.product_name()[0] == 0 else 'n/a',
            'hardware.baseboard.serialNumber':
            System.Hardware.BaseBoard.serial_number()[1].replace('\n', '')
            if System.Hardware.BaseBoard.serial_number()[0] == 0 else 'n/a',
            'processor':
            System.Hardware.Cpu.brand(),
            'agentVersion':
            Util.get_agent_version(),
        }

        return json.dumps(params)