示例#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)
示例#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)
示例#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)
示例#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)
示例#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')
示例#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')
示例#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
示例#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)
示例#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
示例#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)
示例#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)
示例#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)
示例#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:])
示例#14
0
    def __init__(self, phdr):
        Page.__init__(self, phdr, phdr.p_offset, phdr.p_filesz)

        self.protected = True
示例#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:])
示例#16
0
    def __init__(self, phdr):
        Page.__init__(self, phdr, phdr.p_offset, phdr.p_filesz)

        self.protected = True