Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
derv82
GitHub Repository: derv82/wifite2
Path: blob/master/tests/test_Handshake.py
410 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
import sys
5
sys.path.insert(0, '..')
6
7
from wifite.model.handshake import Handshake
8
from wifite.util.process import Process
9
10
import unittest
11
12
class TestHandshake(unittest.TestCase):
13
''' Test suite for Target parsing an generation '''
14
15
def getFile(self, filename):
16
''' Helper method to parse targets from filename '''
17
import os, inspect
18
this_file = os.path.abspath(inspect.getsourcefile(self.getFile))
19
this_dir = os.path.dirname(this_file)
20
return os.path.join(this_dir, 'files', filename)
21
22
def testAnalyze(self):
23
hs_file = self.getFile('handshake_exists.cap')
24
hs = Handshake(hs_file, bssid='A4:2B:8C:16:6B:3A')
25
try:
26
hs.analyze()
27
except Exception:
28
fail()
29
30
@unittest.skipUnless(Process.exists('tshark'), 'tshark is missing')
31
def testHandshakeTshark(self):
32
hs_file = self.getFile('handshake_exists.cap')
33
hs = Handshake(hs_file, bssid='A4:2B:8C:16:6B:3A')
34
assert(len(hs.tshark_handshakes()) > 0)
35
36
@unittest.skipUnless(Process.exists('pyrit'), 'pyrit is missing')
37
def testHandshakePyrit(self):
38
hs_file = self.getFile('handshake_exists.cap')
39
hs = Handshake(hs_file, bssid='A4:2B:8C:16:6B:3A')
40
assert(len(hs.pyrit_handshakes()) > 0)
41
42
@unittest.skipUnless(Process.exists('cowpatty'), 'cowpatty is missing')
43
def testHandshakeCowpatty(self):
44
hs_file = self.getFile('handshake_exists.cap')
45
hs = Handshake(hs_file, bssid='A4:2B:8C:16:6B:3A')
46
hs.divine_bssid_and_essid()
47
assert(len(hs.cowpatty_handshakes()) > 0)
48
49
@unittest.skipUnless(Process.exists('aircrack-ng'), 'aircrack-ng is missing')
50
def testHandshakeAircrack(self):
51
hs_file = self.getFile('handshake_exists.cap')
52
hs = Handshake(hs_file, bssid='A4:2B:8C:16:6B:3A')
53
assert(len(hs.aircrack_handshakes()) > 0)
54
55
56
if __name__ == '__main__':
57
unittest.main()
58
59
60