def PrintSEMResults(filepath): if (filepath and os.path.isfile(filepath)): s = open(filepath, "rb") SEM = SecureSettingsResultVariable(s) s.close() #now print it out. SEM.Print(True)
def get_payload_from_settings_results(self, resultfile, payloadfile): f = open(resultfile, 'rb') rslt = SecureSettingsResultVariable(f) rslt.Print() f.close() if rslt.Payload != None: f = open(payloadfile, "w") f.write(rslt.Payload) f.close return 0
def get_status_and_sessionid_from_settings_results(self, resultfile): f = open(resultfile, 'rb') rslt = SecureSettingsResultVariable(f) rslt.Print() f.close() RsltRc = rslt.Status if RsltRc == 0: try: tree = ET.fromstring(rslt.Payload) for elem in tree.findall('./Settings/SettingResult'): rc = int(elem.find('Result').text, 0) if rc != 0: RsltRc = rc print('Setting %s - Code %s' % (elem.find('Id').text, elem.find('Result').text)) except: traceback.print_exc() return RsltRc, rslt.SessionId
def get_status_and_sessionid_from_settings_results(self, resultfile, checktype): f = open(resultfile, 'rb') rslt = SecureSettingsResultVariable(f) rslt.Print() f.close() if (checktype != "FULL") and (checktype != "BASIC"): print('checktype invalid') return 0x8000000000000007, 0 # EFI_DEVICE_ERROR RsltRc = rslt.Status if RsltRc == 0 and checktype == "FULL": try: tree = ET.fromstring(rslt.Payload) for elem in tree.findall('./Settings/SettingResult'): rc = int (elem.find('Result').text,0) if rc != 0: RsltRc = rc print('Setting %s - Code %s' % (elem.find('Id').text,elem.find('Result').text)) except: traceback.print_exc() return RsltRc, rslt.SessionId
def extract_payload_from_settings_results(self, resultfile, payloadfile): try: tree = ET.parse(resultfile) elem = tree.find('./SyncBody/Results/Item/Data') except: elem = None if elem is None: return 0x8000000000000007 # EFI_DEVICE_ERROR bindata = binascii.a2b_base64(elem.text) #.decode('utf-16') f = BytesIO(bindata) rslt = SecureSettingsResultVariable(f) f.close() f = open(payloadfile, "wb") f.write(rslt.Payload) f.close() return 0