示例#1
0
    def display_notes(self):
        """ Display the notes contained in the file
		"""
        result = []
        for segment in self.elffile.iter_segments():
            if isinstance(segment, NoteSegment):
                for note in segment.iter_notes():
                    pairNote = (note['n_name'], describe_note(note))
                    # sys.stdout.write('n=%s d=%s\n' % pairNote )
                    result.append(pairNote)
        return result
示例#2
0
 def _get_notes(self):
     notes = []
     for segment in self.elf.iter_segments():
         if not isinstance(segment, NoteSegment):
             continue
         for note in segment.iter_notes():
             notes.append({
                 "owner": note["n_name"],
                 "size": self._print_addr(note["n_descsz"]),
                 "note": describe_note(note),
                 "name": note["n_name"],
             })
     return notes
示例#3
0
文件: static.py 项目: ptcNOP/cuckoo
 def _get_notes(self):
     notes = []
     for segment in self.elf.iter_segments():
         if not isinstance(segment, NoteSegment):
             continue
         for note in segment.iter_notes():
             notes.append({
                 "owner": note["n_name"],
                 "size": self._print_addr(note["n_descsz"]),
                 "note": describe_note(note),
                 "name": note["n_name"],
             })
     return notes
示例#4
0
    def get_program_header(self):
        header = []
        if self._elf.num_segments() == 0:
            return []

        for segment in self._elf.iter_segments():
            result = {}
            result['p_type'] = describe_p_type(segment['p_type'])

            if self._elf.elfclass == 32:
                result['p_offset'] = segment['p_offset']
                result['p_vaddr'] = segment['p_vaddr']
                result['p_paddr'] = segment['p_paddr']
                result['p_filesz'] = segment['p_filesz']
                result['p_memsz'] = segment['p_memsz']
                result['p_flags'] = describe_p_flags(segment['p_flags'])
                result['p_align'] = segment['p_align']
            else:  # 64
                result['p_offset'] = segment['p_offset']
                result['p_vaddr'] = segment['p_vaddr']
                result['p_paddr'] = segment['p_paddr']
                result['p_filesz'] = segment['p_filesz']
                result['p_memsz'] = segment['p_memsz']
                result['p_flags'] = describe_p_flags(segment['p_flags'])
                result['p_align'] = segment['p_align']
            if isinstance(segment, InterpSegment):
                result['interp_name'] = segment.get_interp_name()
            result['include_section'] = []
            for section in self._elf.iter_sections():
                if (not section.is_null()
                        and segment.section_in_segment(section)):
                    result['include_section'].append(section.name)

            #NoteSegment
            if isinstance(segment, NoteSegment):
                result['special_type'] = 'note'
                result['note'] = []
                for note in segment.iter_notes():
                    note_dic = {}
                    note_dic['n_offset'] = note['n_offset']
                    note_dic['n_size'] = note['n_size']
                    note_dic['n_name'] = note['n_name']
                    note_dic['n_descsz'] = note['n_descsz']
                    note_dic['note'] = describe_note(note)
                    result['note'].append(note_dic)

            header.append(result)

        return header
示例#5
0
    def _get_notes(self) -> List[Dict[str, str]]:
        notes = []
        for segment in self.elf.iter_segments():
            if not isinstance(segment, NoteSegment):
                continue
            notes.extend(
                {
                    "owner": note["n_name"],
                    "size": self._print_addr(note["n_descsz"]),
                    "note": describe_note(note),
                    "name": note["n_name"],
                }
                for note in segment.iter_notes()
            )

        return notes
示例#6
0
 def display_notes(self):
     """ Display the notes contained in the file
     """
     for segment in self.elffile.iter_segments():
         if isinstance(segment, NoteSegment):
             for note in segment.iter_notes():
                   self._emitline(
                       "\nDisplaying notes found at file offset "
                       "%s with length %s:" % (
                           self._format_hex(note['n_offset'], fieldsize=8),
                           self._format_hex(note['n_size'], fieldsize=8)))
                   self._emitline('  Owner                 Data size	Description')
                   self._emitline('  %s%s %s\t%s' % (
                       note['n_name'], ' ' * (20 - len(note['n_name'])),
                       self._format_hex(note['n_descsz'], fieldsize=8),
                       describe_note(note)))