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