test_SMBLoris.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import random
  2. import unittest
  3. import unittest.mock as mock
  4. import hashlib
  5. from definitions import ROOT_DIR
  6. from ID2TLib.Controller import *
  7. sha_one_attacker = '887226f047456608c5c8746c91d387ffa35777650f083564e0104e381155c58e'
  8. class UnitTestSMBLoris(unittest.TestCase):
  9. def get_sha256(self, file):
  10. sha = hashlib.sha256()
  11. with open(file, 'rb') as f:
  12. while True:
  13. data = f.read(0x100000)
  14. if not data:
  15. break
  16. sha.update(data)
  17. return sha.hexdigest()
  18. def test_one_attacker(self):
  19. # TODO: implement test
  20. random.seed(5)
  21. controller = Controller(pcap_file_path=ROOT_DIR+"/../resources/test/test.pcap", do_extra_tests=False)
  22. controller.load_pcap_statistics(False, False, False)
  23. controller.process_attacks([['SMBLorisAttack', 'ip.src=192.168.1.240', 'ip.dst=192.168.1.210']])
  24. self.assertEqual(self.get_sha256(controller.pcap_dest_path), sha_one_attacker)
  25. #def one_hundred_attacker(self):
  26. # TODO: implement test
  27. #def target_ip_not_in_pcap(self):
  28. # TODO: implement test
  29. #def five_minutes(self):
  30. # TODO: implement test
  31. if __name__ == '__main__':
  32. unittest.main()