Kevin Lund | aba2124 | 2019-10-02 16:20:16 -0600 | [diff] [blame^] | 1 | from os import path |
| 2 | |
| 3 | golden_sequences = [['0x04', '0x05', '0x0b', '0x00', '0x01', '0x0c'], |
| 4 | ['0x04', '0x05', '0x0b', '0x01', '0x0c']] |
| 5 | |
| 6 | pcap_filepath = '/tmp/filtered_pcap' |
| 7 | if 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() |
| 11 | pcap_file = open(pcap_filepath, 'r') |
| 12 | |
| 13 | for 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() |
| 26 | pcap_file.close() |
| 27 | |
| 28 | print('Failure: Your output file did not include the full connection ' + |
| 29 | 'sequence. You may need to add more packet types to your filter.') |
| 30 | exit() |