diff --git a/manticore/binary/__init__.py b/manticore/binary/__init__.py index 6d71113..f662225 100644 --- a/manticore/binary/__init__.py +++ b/manticore/binary/__init__.py @@ -130,53 +130,6 @@ class Elf(Binary): def threads(self): yield(('Running', {'EIP': self.elf.header.e_entry})) -from grr.snapshot import Grr -class CGCGrr(Binary): - def __init__(self, filename): - HEADERSIZE = 16384 - self.grr = Grr.from_buf(file(filename).read(HEADERSIZE)) - self.arch = 'i386' - assert ''.join(self.grr.magic) == 'GRRS' - assert self.grr.exe_num <= 16 - assert self.grr.ranges[0].fd_offs == 16384 - #TODO more asserts - super(CGCGrr, self).__init__(filename) - - def maps(self): - for r in self.grr.ranges: - assert r.end>=r.begin - assert (r.end-r.begin)&0xfff == 0 - assert r.fd_offs&0xfff == 0 - if r.end-r.begin == 0: - continue - perms = '' - perms += r.is_r and 'r'or' ' - perms += r.is_w and 'w'or' ' - perms += r.is_x and 'x'or' ' - if 'r' not in perms: - raise Exception("Not readable map from grr snapshot elf not supported") - - yield((r.begin, r.end-r.begin, perms, self.path, r.fd_offs, r.end-r.begin)) - - def threads(self): - #Basic - regs = ['r15','r14','r13','r12','rbp','rbx','r11','r10','r9','r8','rax', - 'rcx','rdx','rsi','rdi','rip','cs','eflags','rsp','ss','ds','es','fs','gs'] - registers = dict([(name.upper(), getattr(self.grr.gregs, name)) for name in regs]) - - #XMM - for name in ['xmm0', 'xmm1', 'xmm2', 'xmm3', 'xmm4', 'xmm5', 'xmm6', 'xmm7', 'xmm8', - 'xmm9', 'xmm10', 'xmm11', 'xmm12', 'xmm13', 'xmm14', 'xmm15' ]: - registers[name.upper()] = getattr(self.grr.fpregs.xmm_space, name).high << 64 | \ - getattr(self.grr.fpregs.xmm_space, name).low - - #FPU - for i in xrange(8): - registers['FP%d'%i] = ( getattr(self.grr.fpregs.st_space,'st%d'%i).mantissa, - getattr(self.grr.fpregs.st_space,'st%d'%i).exponent ) - - yield ('Running', registers) - class Minidump(Binary): def __init__(self, filename): self.md = minidump.MiniDump(path) @@ -235,7 +188,6 @@ class Minidump(Binary): Binary.magics= { '\x7fCGC': CGCElf, '\x7fELF': Elf, - 'GRRS': CGCGrr, 'MDMP': Minidump} diff --git a/manticore/binary/grr/__init__.py b/manticore/binary/grr/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/manticore/binary/grr/snapshot.py b/manticore/binary/grr/snapshot.py deleted file mode 100644 index 353091d..0000000 --- a/manticore/binary/grr/snapshot.py +++ /dev/null @@ -1,191 +0,0 @@ -import itertools, struct - -class BinaryObject(object): - _fields_ = [] - - def __init__(self): - self._total_size = 0 - - def __len__(self): - return self._total_size - - def __repr__(self): - result = ['{'] - for slot, fmt in self._fields_: - if slot is None: - continue - if '[' in slot: - slot = slot.split('[')[0] - result.append(repr(slot)+':') - result.append(repr(getattr(self,slot))) - result.append('}') - return ' '.join(result) - - - def _initialize_slots(self, buf, offset, field_specs): - total = self._total_size - for slot, fmt in field_specs: - reps = 1 - try: - if '[' in slot: - reps = slot.split('[')[1][:-1] - slot = slot.split('[')[0] - try: - reps = int(reps) - except Exception,e: - reps = getattr(self, reps) - except Exception,e: - pass - - x = [] - size = 0 - for i in range(reps): - if isinstance(fmt, type): - val = fmt.from_buf(buf, offset + total + size) - assert isinstance(val, BinaryObject) - x.append(val) - size += len(val) - else: - try: - x += struct.unpack_from(fmt, buf, offset + total+ size) - except: - raise Exception("Failed parsing %s from offset %d"%(fmt,offset + total)) - size += struct.calcsize(fmt) - - #print "PARSING %s of type %s REP %d at offset %d of size %d"%(slot, fmt, i, offset + total, size) - total += size - - if reps == 1 and len(x) ==1: - x = x[0] - if slot is not None: - setattr(self, slot, x) - - self._total_size = total - - @classmethod - def from_buf(cls, buf, offset=0): - # Determine our inheritance path back to BinaryObject - inheritance_chain = [] - pos = cls - while pos != BinaryObject: - inheritance_chain.append(pos) - bases = pos.__bases__ - assert len(bases) == 1 - pos = bases[0] - inheritance_chain.reverse() - - # Determine all the field names and specs that we need to read. - all_field_specs = itertools.chain(*[c._fields_ - for c in inheritance_chain]) - - # Create the actual object and populate its fields. - obj = cls() - obj._initialize_slots(buf, offset, all_field_specs) - return obj - - -class UserRegsStruct(BinaryObject): - _fields_ = [('r15', '