-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwiregrep.py
executable file
·51 lines (43 loc) · 1.09 KB
/
wiregrep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# wiregrep.py
#
# Copyright 2011 Philippe Langlois <phil _-~AATT~-_ p1sec.com>
#
# Philippe Langlois
# http://www.p1sec.com
#
# Work licensed under GPLv3, please see gpl.org for more information.
#
#
import pyshark
import sys
import binascii
class wiregrep():
def __init__(self, pfile = None, wire_filter = 'ip.version eq 4'):
self.pcap = 0
self.pfile = pfile
self.wire_filter = wire_filter
if pfile != None:
self.add(pfile)
def add(self, pfile):
self.pfile = pfile
#self.pcap = pyshark.read(pfile, ['frame.number', 'frame'], self.wire_filter)
self.pcap = pyshark.read(pfile, ['frame.number'], self.wire_filter)
def count(self):
return(len(self.pcap))
def main(argv):
if len(argv) < 3:
print ("Usage: %s 'filter' files" % argv[0])
sys.exit(-1)
wire_filter = argv[1]
files = argv[2:]
for mfile in files:
wg = wiregrep(mfile, wire_filter)
if wg.count() > 0:
print mfile
else:
del(wg)
if __name__ == '__main__':
main(sys.argv)