예제 #1
0
	def _set_current_binary_view(self, ctxt, view):
		try:
			if view:
				view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
			else:
				view = None
			self.perform_set_current_binary_view(view)
		except:
			log.log_error(traceback.format_exc())
예제 #2
0
	def _show_html_report(self, ctxt, view, title, contents, plaintext):
		try:
			if view:
				view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
			else:
				view = None
			self.show_html_report(view, title, contents, plaintext)
		except:
			log.log_error(traceback.format_exc())
예제 #3
0
 def _address_action(cls, view, addr, action):
     try:
         file_metadata = filemetadata.FileMetadata(
             handle=core.BNGetFileForView(view))
         view_obj = binaryview.BinaryView(
             file_metadata=file_metadata,
             handle=core.BNNewViewReference(view))
         action(view_obj, addr)
     except:
         log.log_error(traceback.format_exc())
예제 #4
0
 def _function_action(cls, view, func, action):
     try:
         file_metadata = filemetadata.FileMetadata(
             handle=core.BNGetFileForView(view))
         view_obj = binaryview.BinaryView(
             file_metadata=file_metadata,
             handle=core.BNNewViewReference(view))
         func_obj = function.Function(view_obj,
                                      core.BNNewFunctionReference(func))
         action(view_obj, func_obj)
     except:
         log.log_error(traceback.format_exc())
예제 #5
0
	def _get_address_input(self, ctxt, result, prompt, title, view, current_address):
		try:
			if view:
				view = binaryview.BinaryView(handle = core.BNNewViewReference(view))
			else:
				view = None
			value = self.get_address_input(prompt, title, view, current_address)
			if value is None:
				return False
			result[0] = value
			return True
		except:
			log.log_error(traceback.format_exc())
예제 #6
0
 def _range_is_valid(cls, view, addr, length, is_valid):
     try:
         if is_valid is None:
             return True
         file_metadata = filemetadata.FileMetadata(
             handle=core.BNGetFileForView(view))
         view_obj = binaryview.BinaryView(
             file_metadata=file_metadata,
             handle=core.BNNewViewReference(view))
         return is_valid(view_obj, addr, length)
     except:
         log.log_error(traceback.format_exc())
         return False
예제 #7
0
 def _get_form_input(self, ctxt, fields, count, title):
     try:
         field_objs = []
         for i in xrange(0, count):
             if fields[i].type == FormInputFieldType.LabelFormField:
                 field_objs.append(LabelField(fields[i].prompt))
             elif fields[i].type == FormInputFieldType.SeparatorFormField:
                 field_objs.append(SeparatorField())
             elif fields[i].type == FormInputFieldType.TextLineFormField:
                 field_objs.append(TextLineField(fields[i].prompt))
             elif fields[
                     i].type == FormInputFieldType.MultilineTextFormField:
                 field_objs.append(MultilineTextField(fields[i].prompt))
             elif fields[i].type == FormInputFieldType.IntegerFormField:
                 field_objs.append(IntegerField(fields[i].prompt))
             elif fields[i].type == FormInputFieldType.AddressFormField:
                 view = None
                 if fields[i].view:
                     view = binaryview.BinaryView(
                         handle=core.BNNewViewReference(fields[i].view))
                 field_objs.append(
                     AddressField(fields[i].prompt, view,
                                  fields[i].currentAddress))
             elif fields[i].type == FormInputFieldType.ChoiceFormField:
                 choices = []
                 for j in xrange(0, fields[i].count):
                     choices.append(fields[i].choices[j])
                 field_objs.append(ChoiceField(fields[i].prompt, choices))
             elif fields[
                     i].type == FormInputFieldType.OpenFileNameFormField:
                 field_objs.append(
                     OpenFileNameField(fields[i].prompt, fields[i].ext))
             elif fields[
                     i].type == FormInputFieldType.SaveFileNameFormField:
                 field_objs.append(
                     SaveFileNameField(fields[i].prompt, fields[i].ext,
                                       fields[i].defaultName))
             elif fields[
                     i].type == FormInputFieldType.DirectoryNameFormField:
                 field_objs.append(
                     DirectoryNameField(fields[i].prompt,
                                        fields[i].defaultName))
             else:
                 field_objs.append(LabelField(fields[i].prompt))
         if not self.get_form_input(field_objs, title):
             return False
         for i in xrange(0, count):
             field_objs[i]._fill_core_result(fields[i])
         return True
     except:
         log.log_error(traceback.format_exc())
예제 #8
0
 def _recognize_medium_level_il(self, ctxt, data, func, il):
     try:
         file_metadata = filemetadata.FileMetadata(
             handle=core.BNGetFileForView(data))
         view = binaryview.BinaryView(file_metadata=file_metadata,
                                      handle=core.BNNewViewReference(data))
         func = function.Function(view,
                                  handle=core.BNNewFunctionReference(func))
         il = mediumlevelil.MediumLevelILFunction(
             func.arch, handle=core.BNNewMediumLevelILFunctionReference(il))
         return self.recognize_medium_level_il(view, func, il)
     except:
         log.log_error(traceback.format_exc())
         return False
예제 #9
0
 def _low_level_il_instruction_action(cls, view, func, instr, action):
     try:
         file_metadata = filemetadata.FileMetadata(
             handle=core.BNGetFileForView(view))
         view_obj = binaryview.BinaryView(
             file_metadata=file_metadata,
             handle=core.BNNewViewReference(view))
         owner = function.Function(view_obj,
                                   core.BNGetLowLevelILOwnerFunction(func))
         func_obj = lowlevelil.LowLevelILFunction(
             owner.arch, core.BNNewLowLevelILFunctionReference(func), owner)
         action(view_obj, func_obj[instr])
     except:
         log.log_error(traceback.format_exc())
예제 #10
0
 def _function_is_valid(cls, view, func, is_valid):
     try:
         if is_valid is None:
             return True
         file_metadata = filemetadata.FileMetadata(
             handle=core.BNGetFileForView(view))
         view_obj = binaryview.BinaryView(
             file_metadata=file_metadata,
             handle=core.BNNewViewReference(view))
         func_obj = function.Function(view_obj,
                                      core.BNNewFunctionReference(func))
         return is_valid(view_obj, func_obj)
     except:
         log.log_error(traceback.format_exc())
         return False
예제 #11
0
 def _medium_level_il_function_action(cls, view, func, action):
     try:
         file_metadata = filemetadata.FileMetadata(
             handle=core.BNGetFileForView(view))
         view_obj = binaryview.BinaryView(
             file_metadata=file_metadata,
             handle=core.BNNewViewReference(view))
         owner = function.Function(
             view_obj, core.BNGetMediumLevelILOwnerFunction(func))
         func_obj = mediumlevelil.MediumLevelILFunction(
             owner.arch, core.BNNewMediumLevelILFunctionReference(func),
             owner)
         action(view_obj, func_obj)
     except:
         log.log_error(traceback.format_exc())
예제 #12
0
 def _low_level_il_function_is_valid(cls, view, func, is_valid):
     try:
         if is_valid is None:
             return True
         file_metadata = filemetadata.FileMetadata(
             handle=core.BNGetFileForView(view))
         view_obj = binaryview.BinaryView(
             file_metadata=file_metadata,
             handle=core.BNNewViewReference(view))
         owner = function.Function(view_obj,
                                   core.BNGetLowLevelILOwnerFunction(func))
         func_obj = lowlevelil.LowLevelILFunction(
             owner.arch, core.BNNewLowLevelILFunctionReference(func), owner)
         return is_valid(view_obj, func_obj)
     except:
         log.log_error(traceback.format_exc())
         return False