session['nickname'] = 'dsniff' session['domains'] = ['live.capture'] session['transactions'] = [] session['date'] = time.time() session['seentids'] = [] session['active'] = True return session def get(self, session, tinfo): return None def get_next(self, session): event.loop(1) # EVLOOP_ONCE #log.info('pmdsniff.get_next: ' + str(self.handler.transactions)) if self.handler and len(self.handler.transactions): #log.info('pmdsniff.get_next: transactions is %d long' % ( # len(self.handler.transactions))) for t in self.handler.transactions: if t['id'] not in session['seentids']: if not (t['request'] or t['response']): continue #log.debug(t) session['seentids'].append(t['id']) session['transactions'].append(t) return t return None if __name__ == '__main__': print "__name__ == __main__" dsniff.main()
# $Id$ import os, time import dsniff class MailSnarf(dsniff.Handler): def setup(self): self.subscribe('*', 'email', self.recv_email) self.__last_hdrs = None def recv_email(self, hdrs, msgfile): """Output mail in BSD mbox format. """ flow = self.flow if hdrs != self.__last_hdrs: self.__last_hdrs = hdrs print 'From mailsnarf', time.ctime(flow.etime) for line in open(msgfile): line = line.rstrip() if line.startswith('From '): print '>%s' % line else: print line os.unlink(msgfile) if __name__ == '__main__': dsniff.main()