def handle_data_content(self): new_syscall = None if self.syscall is not None: new_syscall = scribe.EventSyscallExtra(nr=self.syscall.nr, ret=0, args=self.syscall.args) self.mutations = [ None, Event( scribe.EventDataExtra(data_type=scribe.SCRIBE_DATA_INPUT | scribe.SCRIBE_DATA_STRING, data=self.diverge_event. data[:self.diverge_event.size]), self.proc), Event(scribe.EventSyscallEnd(), self.proc) ] add_state = self.get_add_state() self.add_event(self.syscall, scribe.EventSetFlags( 0, scribe.SCRIBE_UNTIL_NEXT_SYSCALL, new_syscall.encode()), fly_state=add_state) # not replacing inline data events, it's messed up with resource # and all. #self.replace_event(self.culprit, scribe.EventData(data=self.diverge_event.data[:self.diverge_event.size])) start = self.syscall or self.culprit end = new_syscall or self.culprit self.delete_event(self.take_until_match(start, end)) self.status = "diverge data content"
def handle_syscall(self): add_location = None if len(self.mutations) > 0: new_syscall = self.mutations[0] else: new_syscall = scribe.EventSyscallExtra( nr=self.diverge_event.nr, ret=0, args=self.diverge_event.args[:struct.calcsize('L') * self.diverge_event.num_args]) # Because of how signals are handled, we need to put the ignore # syscall event before the signals... if self.syscall is not None: try: first_signal = itertools.takewhile( lambda e: e.is_a(scribe.EventSignal), self.syscall.proc.events.before(self.syscall)).next() add_location = Location(first_signal, 'before') except StopIteration: # no signal found pass add_event = scribe.EventSetFlags(0, scribe.SCRIBE_UNTIL_NEXT_SYSCALL, new_syscall.encode()) self.add_event(self.culprit, add_event, add_location=add_location) self.delete_event(self.take_until_match(self.culprit, new_syscall)) self.status = "syscall: %s" % add_event
def handle_syscall_ret(self): new_syscall = scribe.EventSyscallExtra(nr=self.syscall.nr, ret=0, args=self.syscall.args) add_state = self.get_add_state() self.add_event(self.syscall, scribe.EventSetFlags(0, scribe.SCRIBE_UNTIL_NEXT_SYSCALL, new_syscall.encode()), fly_state=add_state) self.replace_event( self.syscall, scribe.EventSyscallExtra(nr=self.syscall.nr, ret=self.diverge_event.ret, args=self.syscall.args)) self.delete_event(self.take_until_match(self.syscall, new_syscall)) self.status = "ret value mismatch"
def handle_default(self): new_syscall = None if self.syscall is not None: new_syscall = scribe.EventSyscallExtra(nr=self.syscall.nr, ret=0, args=self.syscall.args) self.mutations = [None, Event(scribe.EventSyscallEnd(), self.proc)] self.add_event( self.syscall, scribe.EventSetFlags(0, scribe.SCRIBE_UNTIL_NEXT_SYSCALL, new_syscall.encode())) start = self.syscall or self.culprit end = new_syscall or self.culprit self.delete_event(self.take_until_match(start, end)) self.status = "unhandled case: %s" % self.diverge_event.__class__
def __init__(self, where, new_syscall): extra = None if new_syscall != 0: extra = scribe.EventSyscallExtra(nr=new_syscall, ret=0).encode() SetFlags.__init__(self, where, 0, scribe.SCRIBE_UNTIL_NEXT_SYSCALL, extra)