Beispiel #1
0
 def test_set_pref(self):
     p = prefs.read_prefs()
     self.assertRaises(prefs.PrefSyntaxError, p.set_pref, "_B0RK_")
     self.assertRaises(prefs.NoSuchPreference, p.set_pref, 'foo.bar:""')
     p.set_pref('column.format: "No.", "%m"')
     self.assertEqual(p.num_cols, 1)
Beispiel #2
0
'''Capture traffic from all interfaces for 30 seconds and look for HTTP traffic.

Note the use of column.Type.CUSTOM in conjunction with field "http.user_agent".
The dictionary created in _show() will contain a string like
"Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0" when a
HTTP request is made on the network. We get to this without ever having to really
look at any of the packets by ourselves.
'''

import pprint
from wirepy.lib import column, dfilter, dumpcap, epan, wtap, prefs

# Some required setup
epan.epan_init()
prefs.read_prefs()
epan.init_dissection()

# Some general information we are interested in for every packet
CINFO = column.ColumnInfo([column.Format(column.Type.NUMBER,
                                         title='Packet number'),
                           column.Format(column.Type.INFO, title='Info'),
                           column.Format(column.Type.PACKET_LENGTH,
                                         title='Length'),
                           column.Format(column.Type.EXPERT, title='Expert'),
                           column.Format(column.Type.PROTOCOL,
                                         title='The protocol'),
                           column.Format(column.Type.ABS_TIME,
                                         title='The time'),
                           column.Format(column.Type.UNRES_DST,
                                         title='Destination'),
                           column.Format(column.Type.CUSTOM,
Beispiel #3
0
 def test_set_pref(self):
     p = prefs.read_prefs()
     self.assertRaises(prefs.PrefSyntaxError, p.set_pref, '_B0RK_')
     self.assertRaises(prefs.NoSuchPreference, p.set_pref, 'foo.bar:""')
     p.set_pref('column.format: "No.", "%m"')
     self.assertEqual(p.num_cols, 1)