def __init__(self, dev1, dev2=None, bpf_filter=None, skip_forwarded=True, unoffensive=False, capmethod=0): """ @param dev1 the first interface to sniff on @param dev2 the second interface to sniff on (used in bridged sniffing) or None @param bpf_filter pcap filter to apply to the inputs interfaces @param skip_forwarded Skip forwarded packets. Don't execute decode phase @param unoffensive Don't forward any packets while unified sniffing @param capmethod use 0 for standard capture, 1 for tcpdump and 2 for dumpcap helper @return a BaseAuditContext """ TimedContext.__init__(self) self._iface1 = dev1 self._iface2 = dev2 # These are sockets used to send packets self._l2_socket = None self._l3_socket = None self._lb_socket = None # Listen sockets self._listen_dev1 = None self._listen_dev2 = None self.capmethod = capmethod self.status = self.SAVED
def __init__(self, metapacket, count, inter, iface, callback, udata=None): """ Create a BaseSendContext object @param metapacket the packet to send @param count the n metapacket to send @param inter the interval of time between two consecutive send @param iface the interface to use for sending @param callback the function to call at every send @param udata the user data to pass to callback """ self.packet = metapacket self.tot_count = count self.count = 0 self.inter = float(inter) / 1000.0 self.iface = iface self.callback = callback self.udata = udata TimedContext.__init__(self)
def __init__(self, metapacket, count, inter, iface, \ strict, report_recv, report_sent, capmethod, \ scallback, rcallback, sudata=None, rudata=None): """ Create a BaseSendReceiveContext object @param metapacket the packet to send @param count the n of metapacket to send @param interval the interval between two consecutive send @param iface the interface to listen on for replies @param strict strict checking for reply @param report_recv report received packets @param report_sent report sent packets @param capmethod 0 for native, 1 for tcpdump, 2 for dumpcap @param scallback the send callback to call at each send @param rcallback the recv callback to call at each recv @param sudata the user data for scallback @param rudata the user data for rcallback """ self.packet = metapacket self.tot_count = count self.count = 0 self.inter = float(inter) / 1000.0 self.iface = iface self.strict = strict self.report_recv = report_recv self.report_sent = report_sent self.scallback = scallback self.rcallback = rcallback self.sudata = sudata self.rudata = rudata self.remaining = count self.answers = 0 self.received = 0 self.capmethod = capmethod TimedContext.__init__(self)
def __init__(self, iface, filter=None, minsize=0, maxsize=0, capfile=None, \ scount=0, stime=0, ssize=0, real=True, scroll=True, \ resmac=True, resname=False, restransport=True, promisc=True, \ background=False, capmethod=0, audits=True, \ callback=None, udata=None): """ Create a BaseSniffContext object @param iface the interface to sniff from @param filter the BPF filter to apply @param minsize the min size for every packet (0 no filter) @param maxsize the max size for every packet (0 no filter) @param capfile the file where the packets are saved (in real time) @param scount stop after scount packets sniffed (0 no filter) @param stime stop after stime seconds (0 no filter) @param ssize stop after ssize bytes (0 no filter) @param real if the view should be updated in real time @param scroll if the view shoud be scrolled at every packet received @param resmac enable MAC resolution @param resname enable name resolution @param restransport enable transport resolution @param promisc set the interface to promisc mode @param background if the sniff context should be runned in background @param capmethod the method to use (0 for standard, 1 for virtual interface trough file, 2 for tcpdump helper, 3 for dumpcap helper) @param audits a bool to indicate if auditdispatcher should be feeded with captured packets. @param callback a function to call at every packet sniffed @param udata the user data to pass to callback """ TimedContext.__init__(self) self.iface = iface self.filter = filter self.min_packet_size = minsize self.max_packet_size = maxsize self.cap_file = capfile self.promisc = promisc self.stop_count = scount self.stop_time = stime self.stop_size = ssize self.real_time = real self.auto_scroll = scroll self.mac_resolution = resmac self.name_resolution = resname self.transport_resoltioin = restransport self.capmethod = capmethod self.audits = audits self.background = background self.callback = callback self.udata = udata self.tot_size = 0 self.tot_time = 0 self.tot_count = 0
def __init__( self, iface, filter=None, minsize=0, maxsize=0, capfile=None, scount=0, stime=0, ssize=0, real=True, scroll=True, resmac=True, resname=False, restransport=True, promisc=True, background=False, capmethod=0, audits=True, callback=None, udata=None, ): """ Create a BaseSniffContext object @param iface the interface to sniff from @param filter the BPF filter to apply @param minsize the min size for every packet (0 no filter) @param maxsize the max size for every packet (0 no filter) @param capfile the file where the packets are saved (in real time) @param scount stop after scount packets sniffed (0 no filter) @param stime stop after stime seconds (0 no filter) @param ssize stop after ssize bytes (0 no filter) @param real if the view should be updated in real time @param scroll if the view shoud be scrolled at every packet received @param resmac enable MAC resolution @param resname enable name resolution @param restransport enable transport resolution @param promisc set the interface to promisc mode @param background if the sniff context should be runned in background @param capmethod the method to use (0 for standard, 1 for virtual interface trough file, 2 for tcpdump helper, 3 for dumpcap helper) @param audits a bool to indicate if auditdispatcher should be feeded with captured packets. @param callback a function to call at every packet sniffed @param udata the user data to pass to callback """ TimedContext.__init__(self) self.iface = iface self.filter = filter self.min_packet_size = minsize self.max_packet_size = maxsize self.cap_file = capfile self.promisc = promisc self.stop_count = scount self.stop_time = stime self.stop_size = ssize self.real_time = real self.auto_scroll = scroll self.mac_resolution = resmac self.name_resolution = resname self.transport_resoltioin = restransport self.capmethod = capmethod self.audits = audits self.background = background self.callback = callback self.udata = udata self.tot_size = 0 self.tot_time = 0 self.tot_count = 0
def __init__(self, seq, count=1, inter=0, iface=None, \ strict=True, report_recv=False, report_sent=True, capmethod=0,\ scallback=None, rcallback=None, sudata=None, rudata=None): """ Create a BaseSequenceContext object If seq is a string then the sequence is loaded from file pointed by seq variable and you could set the other attributes are ignored except [sr]callback and [sr]udata. The others are loaded directly from file. @param seq a Sequence object or a string to load from @param count the n of metapacket to send @param interval the interval between two consecutive send @param iface the interface to listen on for replies @param strict strict checking for reply @param report_recv report received packets @param report_sent report sent packets @param capmethod 0 for native, 1 for tcpdump, 2 for dumpcap @param scallback the send callback to call at each send @param rcallback the recv callback to call at each recv @param sudata the user data for scallback @param rudata the user data for rcallback """ TimedContext.__init__(self) if isinstance(seq, basestring): self.cap_file = seq self.title = self.cap_file self.tot_loop_count = 1 self.loop_count = 0 self.tot_packet_count = len(seq) self.packet_count = 0 self.inter = 0 self.iface = None self.strict = True self.report_recv = True self.report_sent = True self.capmethod = 0 else: self.seq = seq self.title = _('Unsaved sequence') self.tot_loop_count = count self.loop_count = 0 self.tot_packet_count = len(seq) self.packet_count = 0 self.inter = float(inter) / 1000.0 self.iface = iface self.strict = strict self.report_recv = report_recv self.report_sent = report_sent self.capmethod = capmethod self.scallback = scallback self.rcallback = rcallback self.sudata = sudata self.rudata = rudata self.answers = 0 self.received = 0