Exemple #1
0
            d = n['header'].now()
            if start >= d > end:
                yield n
            continue
        return

class File(pstruct.type):
    def __packets(self):
        self.attributes.update(self['header'].attributes)
        return List

    def blocksize(self):
        if isinstance(self.source, ptypes.provider.filebase):
            return self.source.size()
        return sys.maxint

    _fields_ = [
        (pcap_hdr_t, 'header'),
        (__packets, 'packets'),
    ]

if __name__ == '__main__':
    import ptypes,libpcap,osi
    s = ptypes.file('~/work/nezzwerk/pcap/win-2008.updates.restart.pcap')
    a = libpcap.File(source=s)
    b = a.l
    c = b['packets']

    packet = osi.default
    z = [x['data'].cast(packet) for x in c]
Exemple #2
0
        except (AttributeError, NotImplementedError):
            pass

        self.leftover -= last.size()
        return dyn.block(self.leftover)

    def isTerminator(self, value):
        if self.leftover is None:
            return False
        assert self.leftover >= 0, 'More than one layer contained within payload: %s' % '\n'.join(
            self.backtrace())
        if self.leftover == 0:
            return True
        return False

    _object_ = __nextlayer


def protocol(layer):
    return ptype.clone(layers, protocol=layer)


default = packet = protocol(datalink.ethernet.header)

if __name__ == '__main__':
    import ptypes, osi, libpcap
    filename = 'c:/users/user/work/audit/openldap-2.4.40/ldapsearch.anonymous-base.1.pcap'
    a = libpcap.File(source=ptypes.prov.file(filename, mode='rb'))
    a = a.l
    b = a['packets'][7]['data'].cast(osi.packet)