3
0

test_FTPWinaXeExploit.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import os
  2. import random
  3. import unittest
  4. import unittest.mock as mock
  5. from ID2TLib.Controller import *
  6. from Test.Lib import test_pcap, get_sha256
  7. sha_one_attacker_ftp = 'd43ebfd5b0f3c9b6556e6a8d2ae4da4d334ed673881d67720eda16faab1b498e'
  8. class UnitTestFTPWinaXeExploit(unittest.TestCase):
  9. def clean_up(self, controller):
  10. os.remove(controller.pcap_dest_path)
  11. os.remove(controller.label_manager.label_file_path)
  12. @mock.patch('ID2TLib.Utility.get_rnd_x86_nop')
  13. @mock.patch('ID2TLib.Utility.get_rnd_bytes')
  14. def test_one_attacker_ftp(self,mock_rnd_x86_nop,mock_rnd_bytes):
  15. random.seed(5)
  16. mock_rnd_x86_nop.return_value = b''
  17. mock_rnd_bytes.return_value = b''
  18. controller = Controller(pcap_file_path=test_pcap, do_extra_tests=False)
  19. controller.load_pcap_statistics(False, False, False)
  20. controller.process_attacks([['FTPWinaXeExploit' ]])
  21. self.assertEqual(get_sha256(controller.pcap_dest_path), sha_one_attacker_ftp)
  22. self.clean_up(controller)
  23. if __name__ == '__main__':
  24. unittest.main()