コード例 #1
0
    def setup_notes(self):
        for seg in self.elf.iter_segments():
            notes = Attributize(seg)
            if notes.p_type != 'PT_NOTE':
                continue
            for note_ in notes.iter_notes():
                note = Attributize(note_)
                self.notes.append(note)
                typ = note.n_type

                st = note.n_offset
                st += self.elf.structs.Elf_Nhdr.sizeof()
                st += align(note.n_namesz, 4)
                st = st - notes.p_offset
                nd = st + note.n_descsz
                orig = self.get_seg_content(seg)
                note.data = orig[st:nd]

                from chdrft.emu.code_db import code
                if self.core:

                    #print(code.g_code.cats.elf.NT_GNU_.values())
                    if typ in code.g_code.cats.elf.NT_GNU_.values(
                    ):  # thanks elfutils!
                        typ = code.g_code.consts[typ]

                    if isinstance(typ, int):
                        typ = code.g_code.cats.elf.NT_[typ]
                    else:
                        if isinstance(typ, int):
                            typ = code.g_code.cats.elf.NT_GNU_[typ]
                note.n_type = typ

                if note.n_type == 'NT_PRSTATUS':
                    sx = Structure(code.g_code.typs.prstatus_t)
                    sx.backend.buf.write(0, note.data)
                    note.status = sx
                elif note.n_type == 'NT_SIGINFO':
                    print('laaa', len(note.data))
コード例 #2
0
ファイル: solve.py プロジェクト: unjambonakap/ctf
def get1(a):
    x = Attributize()
    x.data = base64.b64decode(a['Data'])
    x.offset = a['Offset']
    return x