Browse Source

Merge branch 'attack_recognition_fix' of stefan.schmidt/ID2T-toolkit into master

Carlos Garcia 6 years ago
parent
commit
5d90c43259
1 changed files with 7 additions and 4 deletions
  1. 7 4
      code/Core/AttackController.py

+ 7 - 4
code/Core/AttackController.py

@@ -63,15 +63,18 @@ class AttackController:
                 if name != 'BaseAttack' and name != 'AttackParameters':
                     available_attacks.append(name)
 
-            input_name = input_name.lower()
             highest_sim = 0.0
             highest_sim_attack = None
             for attack in available_attacks:
+                # Check if attack name is accurate
+                if input_name == attack:
+                    return attack
                 # Compares input with one of the available attacks
                 # Makes comparison with lowercase version with generic 'attack' and 'exploit' ending removed
-                similarity = difflib.SequenceMatcher(None, input_name,
-                                                     Util.rchop(attack.lower(), ('attack', 'exploit')))\
-                    .ratio()
+                counter_check = attack.lower()
+                if 'attack' not in input_name and 'exploit' not in input_name:
+                    counter_check = Util.rchop(attack.lower(), ('attack', 'exploit'))
+                similarity = difflib.SequenceMatcher(None, input_name.lower(), counter_check).ratio()
                 # Exact match, return appropriate attack name
                 if similarity == 1.0:
                     return attack