Python pcapy.PcapError() Examples

The following are 12 code examples of pcapy.PcapError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pcapy , or try the search function .
Example #1
Source File: pcapdnet.py    From CyberScan with GNU General Public License v3.0 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #2
Source File: pcapdnet.py    From smod-1 with GNU General Public License v2.0 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #3
Source File: pcapdnet.py    From CVE-2016-6366 with MIT License 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #4
Source File: pcapdnet.py    From mptcp-abuse with GNU General Public License v2.0 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #5
Source File: pcapdnet.py    From dash-hack with MIT License 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #6
Source File: pcapdnet.py    From dash-hack with MIT License 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #7
Source File: pcapdnet.py    From dash-hack with MIT License 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #8
Source File: pcapdnet.py    From isip with MIT License 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #9
Source File: split.py    From Slackor with GNU General Public License v3.0 5 votes vote down vote up
def packetHandler(self, hdr, data):
        """Handles an incoming pcap packet. This method only knows how
        to recognize TCP/IP connections.
        Be sure that only TCP packets are passed onto this handler (or
        fix the code to ignore the others).

        Setting r"ip proto \tcp" as part of the pcap filter expression
        suffices, and there shouldn't be any problem combining that with
        other expressions.
        """

        # Use the ImpactDecoder to turn the rawpacket into a hierarchy
        # of ImpactPacket instances.
        p = self.decoder.decode(data)
        ip = p.child()
        tcp = ip.child()

        # Build a distinctive key for this pair of peers.
        src = (ip.get_ip_src(), tcp.get_th_sport() )
        dst = (ip.get_ip_dst(), tcp.get_th_dport() )
        con = Connection(src,dst)

        # If there isn't an entry associated yetwith this connection,
        # open a new pcapdumper and create an association.
        if ('%s%s' % (con.p1, con.p2)) not in self.connections:
            fn = con.getFilename()
            print("Found a new connection, storing into:", fn)
            try:
                dumper = self.pcap.dump_open(fn)
            except pcapy.PcapError:
                print("Can't write packet to:", fn)
                return
            self.connections['%s%s' % (con.p1, con.p2)] = dumper

        # Write the packet to the corresponding file.
        self.connections['%s%s' % (con.p1, con.p2)].dump(hdr, data) 
Example #10
Source File: pcapdnet.py    From POC-EXP with GNU General Public License v3.0 5 votes vote down vote up
def next(self):
                    try:
                        c = self.pcap.next()
                    except pcap.PcapError:
                        return None
                    else:
                        h,p = c
                        s,us = h.getts()
                        return (s+0.000001*us), p 
Example #11
Source File: tracer.py    From PiBunny with MIT License 5 votes vote down vote up
def poll(self,event = None):
        self.tk.after(POLL_PERIOD, self.poll)
        received = 0
        while 1:
            try:
                hdr, data = self.p.next()
            except PcapError, e:
                break
            self.newPacket(hdr.getcaplen(), data, hdr.getts()[0])
            received = 1 
Example #12
Source File: split.py    From PiBunny with MIT License 5 votes vote down vote up
def packetHandler(self, hdr, data):
        """Handles an incoming pcap packet. This method only knows how
        to recognize TCP/IP connections.
        Be sure that only TCP packets are passed onto this handler (or
        fix the code to ignore the others).

        Setting r"ip proto \tcp" as part of the pcap filter expression
        suffices, and there shouldn't be any problem combining that with
        other expressions.
        """

        # Use the ImpactDecoder to turn the rawpacket into a hierarchy
        # of ImpactPacket instances.
        p = self.decoder.decode(data)
        ip = p.child()
        tcp = ip.child()

        # Build a distinctive key for this pair of peers.
        src = (ip.get_ip_src(), tcp.get_th_sport() )
        dst = (ip.get_ip_dst(), tcp.get_th_dport() )
        con = Connection(src,dst)

        # If there isn't an entry associated yetwith this connection,
        # open a new pcapdumper and create an association.
        if not self.connections.has_key(con):
            fn = con.getFilename()
            print "Found a new connection, storing into:", fn
            try:
                dumper = self.pcap.dump_open(fn)
            except pcapy.PcapError, e:
                print "Can't write packet to:", fn
                return
            self.connections[con] = dumper

        # Write the packet to the corresponding file.