File: test_Airodump.py

package info (click to toggle)
wifite 2.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,196 kB
  • sloc: python: 6,457; sh: 10; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 2,349 bytes parent folder | download | duplicates (3)
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
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from wifite.tools.airodump import Airodump
import unittest

sys.path.insert(0, '..')


class TestAirodump(unittest.TestCase):
    """ Test suite for Wifite's interaction with the Airodump tool """

    def test_airodump(self):
        csv_filename = self.getFile('airodump.csv')
        targets = Airodump.get_targets_from_csv(csv_filename)

        print('')
        for target in targets:
            print("Testing ESSID: ", target.essid)
            if target.essid is not None:
                assert target.essid_len == len(target.essid), \
                    f'ESSID length is {target.essid_len} but ESSID is {len(target.essid)} - [{target.essid}]'

    def test_airodump_weird_characters(self):
        csv_filename = self.getFile('airodump-weird-ssids.csv')
        targets = Airodump.get_targets_from_csv(csv_filename)

        target = targets[0]
        expected = 'Comma, no trailing space'
        assert target.essid == expected, f'Expected ESSID ({expected}) but got ({target.essid})'

        target = targets[1]
        expected = '"Quoted ESSID, Comma, no trailing spaces.   "'
        assert target.essid == expected, f'Expected ESSID ({expected}) but got ({target.essid})'

        target = targets[2]
        expected = 'Comma, Trailing space '
        assert target.essid == expected, f'Expected ESSID ({expected}) but got ({target.essid})'

        target = targets[3]
        expected = '"quote" comma, trailing space '
        assert target.essid == expected, f'Expected ESSID ({expected}) but got ({target.essid})'

        # Hidden access point
        target = targets[4]
        assert target.essid_known is False, 'ESSID full of null characters should not be known'
        expected = None
        assert target.essid == expected, f'Expected ESSID ({expected}) but got ({target.essid})'
        assert target.essid_len == 19, f'ESSID [unknow chars] length should be 19, but got {target.essid_len}'

    def getFile(self, filename):
        """ Helper method to parse targets from filename """
        import os
        import inspect
        this_file = os.path.abspath(inspect.getsourcefile(self.getFile))
        this_dir = os.path.dirname(this_file)
        return os.path.join(this_dir, 'files', filename)


if __name__ == '__main__':
    unittest.main()