def get_injectable_tracepoints(self, iid): payload = Payload() payload.put_u32('iid', iid) response = self.request('INJT', payload) for i in xrange(response.get('tptc', 0)): postfix = '[%i]' % i yield Tracepoint(response.get('tpta' + postfix), response.get('tpth' + postfix))
def iter_injectable_symbols(self, iid, which): if which not in 'EIA': raise ValueError payload = Payload() payload.put_u32('iid', iid) response = self.request('INJ' + which, payload) for i in xrange(response.get('symc', 0)): postfix = '[%i]' % i yield Symbol(response.get('symad' + postfix), response.get('symnm' + postfix))
def get_memory(self, pid): payload = Payload() payload.put_u32('pid', pid) response = self.request('MAPS', payload) def iter_segments(): for i in xrange(response.get('segc', 0)): def get(what): return response.get('seg{:}[{:}]'.format(what, i)) yield get('lo'), get('hi'), get('type'), get('file'), get('off') return sorted(iter_segments())
def dump(self, pid, address, size): payload = Payload() payload.put_u32('pid', pid) payload.put_u64('address', address) payload.put_u32('size', size) response = self.request('MEMD', payload) words = (response.get('word[%i]' % x) for x in xrange(response.get('size', 0))) def tobytes(word): a = (word >> 24) & 0xff b = (word >> 16) & 0xff c = (word >> 8) & 0xff d = (word) & 0xff return ''.join(chr(x) for x in (d, c, b, a)) bytes = (tobytes(x) for x in words) return ''.join(bytes)
def explain_address(self, pid, address): payload = Payload() payload.put_u32('pid', pid) payload.put_u64('address', address) return self.request('ADDR', payload)
def kill(self, pid): payload = Payload() payload.put_u32('pid', pid) return self.request('KILL', payload)
def injectable_unload(self, iid): payload = Payload() payload.put_u32('iid', iid) return self.request('INJU', payload)
def spawn(self, args): payload = Payload() payload.put_u32('argc', len(args)) for i, v in enumerate(args): payload.put_str('argv[{:}]'.format(i), v) return self.request('SPWN', payload)
def detach(self, pid): payload = Payload() payload.put_u32('pid', pid) return self.request('DETC', payload)
def loglevel(self, loglevel): payload = Payload() payload.put_u32('loglevel', loglevel) return self.request('LLEV', payload)