/src/honeynet_web/packetAnalysis/analyzers/dos.py

https://bitbucket.org/cpdean/pig · Python · 49 lines · 17 code · 5 blank · 27 comment · 5 complexity · ad24fe8d9cf55286da82c1fd609412d9 MD5 · raw file

  1. """
  2. analyzers.py
  3. Basic file for defining the different attack profiles
  4. Functions to use are:
  5. - addPrelimNode() :: adds a Node at the PRELIM threat level
  6. @return - The integer index of the added node
  7. - addThreatNode() :: adds a Node at the THREAT threat level
  8. @return - The integer index of the added node
  9. - addTransition(src, dest, score, triggers) :: adds a scored transition between
  10. the src and dest nodes
  11. @param src - Integer index of the Node to transition from
  12. @param dest - Integer index of the Node to transition to
  13. @param score - Numerical attack score to be assigned to the transition
  14. @param triggers - List of boolean functions to be satisfied in order to
  15. make the transition
  16. """
  17. from attackanalyzer import AttackAnalyzer
  18. class DOSAnalyzer(AttackAnalyzer):
  19. attackType = 'dos'
  20. def addAttackProfile(self):
  21. '''A standard DoS attack shall be a connection that sends more than
  22. 200 packets over one second.
  23. '''
  24. funct = lambda x: True
  25. for i in range(1000):
  26. self.addPrelimNode(1.1)
  27. self.addTransition(i, i+1, 1, [funct])
  28. threat = self.addThreatNode(5.1)
  29. self.addTransition(i+1, threat, 1, [funct])
  30. self.addTransition(threat, threat, 1, [funct])
  31. '''A fraggle attack utilizes the random character generation TCP port
  32. and the Echo port to cause an endless loop.
  33. '''
  34. charGenPort = 19
  35. fraggle = lambda x: x.source_port == charGenPort or \
  36. x.destination_port == charGenPort
  37. self.addTransition(0, threat, 100, [fraggle])
  38. '''A land attack spoofs the victim's IP as the source and dest,
  39. causing the machine to try to open a connection with itself.
  40. '''
  41. land = lambda x: x.source_ip == x.destination_ip
  42. self.addTransition(0, threat, 150, [land])