Ejemplo n.º 1
0
    def __init__(self, nhdr):
        self.name = ''
        self.desc = ''

        Page.__init__(self, nhdr,
                      nhdr.offset_start + calcsize(''.join(nhdr.format)),
                      nhdr.n_namesz + nhdr.n_descz)
Ejemplo n.º 2
0
    def __init__(self, nhdr):
        self.name = ''
        self.desc = ''

        Page.__init__(self, nhdr,
                      nhdr.offset_start+calcsize(''.join(nhdr.format)),
                      nhdr.n_namesz+nhdr.n_descz)
Ejemplo n.º 3
0
    def __init__(self, shdr):
        self.name = 'null'

        self.strtab = {}
        self.symtab = []
        self.relocs = []
        self.dynamic = []
        self.note = []

        Page.__init__(self, shdr, shdr.sh_offset, shdr.sh_size)
Ejemplo n.º 4
0
    def __init__(self, shdr):
        self.name = 'null'

        self.strtab = {}
        self.symtab = []
        self.relocs = []
        self.dynamic = []
        self.note = []

        Page.__init__(self, shdr, shdr.sh_offset, shdr.sh_size)
Ejemplo n.º 5
0
    def loadStrTab(self):
        """ Load a string table """

        if self.size <= 0:
            return

        format = self.prop.endian + ('s' * self.size)

        Page.load(self)

        self.strtab = list(unpack_from(format, self.data))
        if self.strtab[len(self.strtab) - 1] != '\0':
            self.strtab.append('\0')
Ejemplo n.º 6
0
    def loadStrTab(self):
        """ Load a string table """

        if self.size <= 0:
            return

        format = self.prop.endian+('s'*self.size)

        Page.load(self)

        self.strtab = list(unpack_from(format, self.data))
        if self.strtab[len(self.strtab)-1] != '\0':
            self.strtab.append('\0')
Ejemplo n.º 7
0
    def chunks(self):
        c_lst = Page.chunks(self)

        c_lst.extend(self.symtab)
        c_lst.extend(self.relocs)
        c_lst.extend(self.dynamic)

        for c in self.note:
            c_lst.extend(c.chunks())

        return c_lst
Ejemplo n.º 8
0
    def load(self, offset=None, filemap=None):
        """ Load proper elements depending on section's type """

        # Call specific loading func, depending on sh_type
        if self.header.sh_type == shdr_type['SHT_SYMTAB']:
            self.loadSymTab()
        elif self.header.sh_type == shdr_type['SHT_DYNSYM']:
            self.loadSymTab()
        elif self.header.sh_type == shdr_type['SHT_STRTAB']:
            self.loadStrTab()
        elif self.header.sh_type == shdr_type['SHT_REL']:
            self.loadRelocs()
        elif self.header.sh_type == shdr_type['SHT_RELA']:
            self.loadRelocs(True)
        elif self.header.sh_type == shdr_type['SHT_DYNAMIC']:
            self.loadDynamic()
        elif self.header.sh_type == shdr_type['SHT_NOTE']:
            self.loadNote()
        else:
            Page.load(self)
Ejemplo n.º 9
0
    def chunks(self):
        c_lst = Page.chunks(self)

        c_lst.extend(self.symtab)
        c_lst.extend(self.relocs)
        c_lst.extend(self.dynamic)

        for c in self.note:
            c_lst.extend(c.chunks())

        return c_lst
Ejemplo n.º 10
0
    def load(self, offset=None, filemap=None):
        """ Load proper elements depending on section's type """

        # Call specific loading func, depending on sh_type
        if self.header.sh_type == shdr_type['SHT_SYMTAB']:
            self.loadSymTab()
        elif self.header.sh_type == shdr_type['SHT_DYNSYM']:
            self.loadSymTab()
        elif self.header.sh_type == shdr_type['SHT_STRTAB']:
             self.loadStrTab()
        elif self.header.sh_type == shdr_type['SHT_REL']:
            self.loadRelocs()
        elif self.header.sh_type == shdr_type['SHT_RELA']:
            self.loadRelocs(True)
        elif self.header.sh_type == shdr_type['SHT_DYNAMIC']:
            self.loadDynamic()
        elif self.header.sh_type == shdr_type['SHT_NOTE']:
            self.loadNote()
        else:
            Page.load(self)
Ejemplo n.º 11
0
    def remove(self, force=False, forward=True):
        if forward == True:
            for s in self.symtab:
                s.remove(force)
            for r in self.relocs:
                r.remove(force)
            for d in self.dynamic:
                d.remove(force)
            for n in self.note:
                n.remove(force, forward)

        return Page.remove(self, force, forward)
Ejemplo n.º 12
0
    def remove(self, force = False, forward = True):
        if forward == True:
            for s in self.symtab:
                s.remove(force)
            for r in self.relocs:
                r.remove(force)
            for d in self.dynamic:
                d.remove(force)
            for n in self.note:
                n.remove(force, forward)

        return Page.remove(self, force, forward)
Ejemplo n.º 13
0
    def load(self, offset=None, filemap=None):
        Page.load(self, offset, filemap)

        self.name = str(self.data[:self.header.n_namesz])
        self.desc = str(self.data[self.header.n_namesz:])
Ejemplo n.º 14
0
    def __init__(self, phdr):
        Page.__init__(self, phdr, phdr.p_offset, phdr.p_filesz)

        self.protected = True
Ejemplo n.º 15
0
    def load(self, offset=None, filemap=None):
        Page.load(self, offset, filemap)

        self.name = str(self.data[:self.header.n_namesz])
        self.desc = str(self.data[self.header.n_namesz:])
Ejemplo n.º 16
0
    def __init__(self, phdr):
        Page.__init__(self, phdr, phdr.p_offset, phdr.p_filesz)

        self.protected = True