Ejemplo n.º 1
0
    def run(self):
        conn = self.frmwk.serial_connection

        data = self.options['PARAMS']
        if self.options['USE_HEX']:
            data = data.replace(' ', '')
            hex_regex = re.compile('^([0-9a-fA-F]{2})+$')
            if hex_regex.match(data) is None:
                self.frmwk.print_error(
                    'Non-hex characters found in \'PARAMS\'')
                return
            data = binascii.a2b_hex(data)
        else:
            data = data.encode('utf-8')

        self.frmwk.print_status('Initiating procedure ' + (
            C1219_PROCEDURE_NAMES.get(self.options['PROC_NUMBER']) or '#' +
            str(self.options['PROC_NUMBER'])))

        error_code, data = conn.run_procedure(
            self.options['PROC_NUMBER'], self.advanced_options['STD_VS_MFG'],
            data)

        self.frmwk.print_status('Finished running procedure #' +
                                str(self.options['PROC_NUMBER']))
        self.frmwk.print_status('Received response from procedure: ' + (
            C1219_PROC_RESULT_CODES.get(error_code) or 'UNKNOWN'))
        if len(data):
            self.frmwk.print_status('Received data output from procedure: ')
            self.frmwk.print_hexdump(data)
Ejemplo n.º 2
0
    def run(self):
        conn = self.frmwk.serial_connection
        if not self.frmwk.serial_login():  # don't alert on failed logins
            self.logger.warning('meter login failed')
            self.frmwk.print_error('Meter login failed, procedure may fail')

        data = self.options['PARAMS']
        if self.options['USEHEX']:
            data = unhexlify(data)

        self.frmwk.print_status('Initiating procedure ' + (
            C1219_PROCEDURE_NAMES.get(self.options['PROCNBR']) or '#' +
            str(self.options['PROCNBR'])))

        errCode, data = conn.run_procedure(self.options['PROCNBR'],
                                           self.advanced_options['STDVSMFG'],
                                           data)
        conn.stop()

        self.frmwk.print_status('Finished running procedure #' +
                                str(self.options['PROCNBR']))
        self.frmwk.print_status('Received respose from procedure: ' + (
            C1219_PROC_RESULT_CODES.get(errCode) or 'UNKNOWN'))
        if len(data):
            self.frmwk.print_status('Received data output from procedure: ')
            self.frmwk.print_hexdump(data)
        return
	def run(self):
		conn = self.frmwk.serial_connection
		logger = self.logger
		if not self.frmwk.serial_login():	# don't alert on failed logins
			logger.warning('meter login failed')

		try:
			securityCtl = C1219SecurityAccess(conn)
		except C1218ReadTableError:
			self.frmwk.print_error('Could not read necessary tables')
			return
		conn.stop()

		security_info = {}
		security_info['Number of Passwords'] = securityCtl.nbr_passwords
		security_info['Max Password Length'] = securityCtl.password_len
		security_info['Number of Keys'] = securityCtl.nbr_keys
		security_info['Number of Permissions'] = securityCtl.nbr_perm_used

		self.frmwk.print_status('Security Information:')
		fmt_string = "    {0:.<38}.{1}"
		keys = security_info.keys()
		keys.sort()
		for key in keys:
			self.frmwk.print_status(fmt_string.format(key, security_info[key]))

		self.frmwk.print_status('Passwords and Permissions:')
		fmt_string = "    {0:<5} {1:<40} {2}"
		self.frmwk.print_status(fmt_string.format('Index', 'Password (In Hex)', 'Group Flags'))
		self.frmwk.print_status(fmt_string.format('-----', '-----------------', '-----------'))
		for idx, entry in securityCtl.passwords.items():
			self.frmwk.print_status(fmt_string.format(idx, entry['password'].encode('hex'), entry['groups']))

		self.frmwk.print_status('Table Permissions:')
		fmt_string = "    {0:<64} {1:<14} {2:<14}"
		self.frmwk.print_status(fmt_string.format('Table Number', 'World Readable', 'World Writable'))
		self.frmwk.print_status(fmt_string.format('------------', '--------------', '--------------'))
		fmt_string = "    {0:.<64} {1:<14} {2:<14}"
		for idx, entry in securityCtl.table_permissions.items():
			self.frmwk.print_status(fmt_string.format('#' + str(idx) + ' ' + (C1219_TABLES.get(idx) or 'Unknown'), str(entry['anyread']), str(entry['anywrite'])))

		self.frmwk.print_status('Procedure Permissions:')
		fmt_string = "    {0:<64} {1:<14} {2:<16}"
		self.frmwk.print_status(fmt_string.format('Procedure Number', 'World Readable', 'World Executable'))
		self.frmwk.print_status(fmt_string.format('----------------', '--------------', '----------------'))
		fmt_string = "    {0:.<64} {1:<14} {2:<16}"
		for idx, entry in securityCtl.procedure_permissions.items():
			self.frmwk.print_status(fmt_string.format('#' + str(idx) + ' ' + (C1219_PROCEDURE_NAMES.get(idx) or 'Unknown'), str(entry['anyread']), str(entry['anywrite'])))

		if len(securityCtl.keys):
			self.frmwk.print_status('Stored Keys:')
			fmt_string = "    {0:<5} {1}"
			self.frmwk.print_status(fmt_string.format('Index', 'Hex Value'))
			self.frmwk.print_status(fmt_string.format('-----', '---------'))
			for idx, entry in securityCtl.keys.items():
				self.frmwk.print_status(fmt_string.format(idx, entry.encode('hex')))
		return
Ejemplo n.º 4
0
	def run(self):
		conn = self.frmwk.serial_connection
		logger = self.logger
		if not self.frmwk.serial_login():	# don't alert on failed logins
			logger.warning('meter login failed')

		try:
			securityCtl = C1219SecurityAccess(conn)
		except C1218ReadTableError:
			self.frmwk.print_error('Could not read necessary tables')
			return
		conn.stop()

		security_info = {}
		security_info['Number of Passwords'] = securityCtl.nbr_passwords
		security_info['Max Password Length'] = securityCtl.password_len
		security_info['Number of Keys'] = securityCtl.nbr_keys
		security_info['Number of Permissions'] = securityCtl.nbr_perm_used

		self.frmwk.print_status('Security Information:')
		fmt_string = "    {0:.<38}.{1}"
		keys = security_info.keys()
		keys.sort()
		for key in keys:
			self.frmwk.print_status(fmt_string.format(key, security_info[key]))

		self.frmwk.print_status('Passwords and Permissions:')
		fmt_string = "    {0:<5} {1:<40} {2}"
		self.frmwk.print_status(fmt_string.format('Index', 'Password (In Hex)', 'Group Flags'))
		self.frmwk.print_status(fmt_string.format('-----', '-----------------', '-----------'))
		for idx, entry in securityCtl.passwords.items():
			self.frmwk.print_status(fmt_string.format(idx, entry['password'].encode('hex'), entry['groups']))

		self.frmwk.print_status('Table Permissions:')
		fmt_string = "    {0:<64} {1:<14} {2:<14}"
		self.frmwk.print_status(fmt_string.format('Table Number', 'World Readable', 'World Writable'))
		self.frmwk.print_status(fmt_string.format('------------', '--------------', '--------------'))
		fmt_string = "    {0:.<64} {1:<14} {2:<14}"
		for idx, entry in securityCtl.table_permissions.items():
			self.frmwk.print_status(fmt_string.format('#' + str(idx) + ' ' + (C1219_TABLES.get(idx) or 'Unknown'), str(entry['anyread']), str(entry['anywrite'])))

		self.frmwk.print_status('Procedure Permissions:')
		fmt_string = "    {0:<64} {1:<14} {2:<16}"
		self.frmwk.print_status(fmt_string.format('Procedure Number', 'World Readable', 'World Executable'))
		self.frmwk.print_status(fmt_string.format('----------------', '--------------', '----------------'))
		fmt_string = "    {0:.<64} {1:<14} {2:<16}"
		for idx, entry in securityCtl.procedure_permissions.items():
			self.frmwk.print_status(fmt_string.format('#' + str(idx) + ' ' + (C1219_PROCEDURE_NAMES.get(idx) or 'Unknown'), str(entry['anyread']), str(entry['anywrite'])))

		if len(securityCtl.keys):
			self.frmwk.print_status('Stored Keys:')
			fmt_string = "    {0:<5} {1}"
			self.frmwk.print_status(fmt_string.format('Index', 'Hex Value'))
			self.frmwk.print_status(fmt_string.format('-----', '---------'))
			for idx, entry in securityCtl.keys.items():
				self.frmwk.print_status(fmt_string.format(idx, entry.encode('hex')))
		return
Ejemplo n.º 5
0
	def run(self):
		conn = self.frmwk.serial_connection
		if not self.frmwk.serial_login():	# don't alert on failed logins
			self.logger.warning('meter login failed')
			self.frmwk.print_error('Meter login failed, procedure may fail')

		data = self.options['PARAMS']
		if self.options['USEHEX']:
			data = data.decode('hex')

		self.frmwk.print_status('Initiating procedure ' + (C1219_PROCEDURE_NAMES.get(self.options['PROCNBR']) or '#' + str(self.options['PROCNBR'])))

		errCode, data = conn.run_procedure(self.options['PROCNBR'], self.advanced_options['STDVSMFG'], data)
		conn.stop()

		self.frmwk.print_status('Finished running procedure #' + str(self.options['PROCNBR']))
		self.frmwk.print_status('Received respose from procedure: ' + (C1219_PROC_RESULT_CODES.get(errCode) or 'UNKNOWN'))
		if len(data):
			self.frmwk.print_status('Received data output from procedure: ')
			self.frmwk.print_hexdump(data)
		return
Ejemplo n.º 6
0
	def run(self):
		conn = self.frmwk.serial_connection

		data = self.options['PARAMS']
		if self.options['USE_HEX']:
			data = data.replace(' ', '')
			hex_regex = re.compile('^([0-9a-fA-F]{2})+$')
			if hex_regex.match(data) is None:
				self.frmwk.print_error('Non-hex characters found in \'PARAMS\'')
				return
			data = binascii.a2b_hex(data)
		else:
			data = data.encode('utf-8')

		self.frmwk.print_status('Initiating procedure ' + (C1219_PROCEDURE_NAMES.get(self.options['PROC_NUMBER']) or '#' + str(self.options['PROC_NUMBER'])))

		error_code, data = conn.run_procedure(self.options['PROC_NUMBER'], self.advanced_options['STD_VS_MFG'], data)

		self.frmwk.print_status('Finished running procedure #' + str(self.options['PROC_NUMBER']))
		self.frmwk.print_status('Received response from procedure: ' + (C1219_PROC_RESULT_CODES.get(error_code) or 'UNKNOWN'))
		if len(data):
			self.frmwk.print_status('Received data output from procedure: ')
			self.frmwk.print_hexdump(data)
Ejemplo n.º 7
0
    def run(self):
        conn = self.frmwk.serial_connection

        try:
            security_ctl = C1219SecurityAccess(conn)
        except C1218ReadTableError:
            self.frmwk.print_error("Could not read necessary tables")
            return

        security_info = {}
        security_info["Number of Passwords"] = security_ctl.nbr_passwords
        security_info["Max Password Length"] = security_ctl.password_len
        security_info["Number of Keys"] = security_ctl.nbr_keys
        security_info["Number of Permissions"] = security_ctl.nbr_perm_used

        self.frmwk.print_status("Security Information:")
        fmt_string = "    {0:.<38}.{1}"
        keys = security_info.keys()
        keys.sort()
        for key in keys:
            self.frmwk.print_status(fmt_string.format(key, security_info[key]))

        self.frmwk.print_status("Passwords and Permissions:")
        fmt_string = "    {0:<5} {1:<40} {2}"
        self.frmwk.print_status(fmt_string.format("Index", "Password (In Hex)", "Group Flags"))
        self.frmwk.print_status(fmt_string.format("-----", "-----------------", "-----------"))
        for idx, entry in security_ctl.passwords.items():
            self.frmwk.print_status(fmt_string.format(idx, entry["password"].encode("hex"), entry["groups"]))

        self.frmwk.print_status("Table Permissions:")
        fmt_string = "    {0:<64} {1:<14} {2:<14}"
        self.frmwk.print_status(fmt_string.format("Table Number", "World Readable", "World Writable"))
        self.frmwk.print_status(fmt_string.format("------------", "--------------", "--------------"))
        fmt_string = "    {0:.<64} {1:<14} {2:<14}"
        for idx, entry in security_ctl.table_permissions.items():
            self.frmwk.print_status(
                fmt_string.format(
                    "#" + str(idx) + " " + (C1219_TABLES.get(idx) or "Unknown"),
                    str(entry["anyread"]),
                    str(entry["anywrite"]),
                )
            )

        self.frmwk.print_status("Procedure Permissions:")
        fmt_string = "    {0:<64} {1:<14} {2:<16}"
        self.frmwk.print_status(fmt_string.format("Procedure Number", "World Readable", "World Executable"))
        self.frmwk.print_status(fmt_string.format("----------------", "--------------", "----------------"))
        fmt_string = "    {0:.<64} {1:<14} {2:<16}"
        for idx, entry in security_ctl.procedure_permissions.items():
            self.frmwk.print_status(
                fmt_string.format(
                    "#" + str(idx) + " " + (C1219_PROCEDURE_NAMES.get(idx) or "Unknown"),
                    str(entry["anyread"]),
                    str(entry["anywrite"]),
                )
            )

        if len(security_ctl.keys):
            self.frmwk.print_status("Stored Keys:")
            fmt_string = "    {0:<5} {1}"
            self.frmwk.print_status(fmt_string.format("Index", "Hex Value"))
            self.frmwk.print_status(fmt_string.format("-----", "---------"))
            for idx, entry in security_ctl.keys.items():
                self.frmwk.print_status(fmt_string.format(idx, entry.encode("hex")))
        return