• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from os import path
2
3golden_sequences = [['0x04', '0x05', '0x0b', '0x00', '0x01', '0x0c'],
4                    ['0x04', '0x05', '0x0b', '0x01', '0x0c']]
5
6pcap_filepath = '/tmp/filtered_pcap'
7if not path.exists(pcap_filepath):
8    print('Could not find output file. Follow the steps in section 5 of ' +
9        'the codelab to generate a pcap output file.')
10    exit()
11pcap_file = open(pcap_filepath, 'r')
12
13for line in pcap_file:
14    packet_type = line[0:4]
15    if not packet_type.startswith('0x0'):
16        print('Failure: Non-connection packet of type ' + packet_type +
17            ' included in output.')
18        exit()
19    for sequence in golden_sequences:
20        if sequence[0] == packet_type:
21            sequence.pop(0)
22        if len(sequence) == 0:
23            print('Success: The full connection sequence was included in ' +
24                'your output!')
25            exit()
26pcap_file.close()
27
28print('Failure: Your output file did not include the full connection ' +
29    'sequence. You may need to add more packet types to your filter.')
30exit()