Exemplo n.º 1
0
    def load_attacks(self, attacks_list, multikeys=False):
        """ Dynamic load attacks according to context (single key or multiple keys)
        """
        try:
            attacks_list.remove("all")
        except ValueError:
            pass

        try:
            attacks_list.remove("nullattack")
        except ValueError:
            pass

        for attack in attacks_list:
            if attack == self.args.attack or self.args.attack == "all":
                try:
                    if multikeys:
                        attack_module = importlib.import_module(
                            "attacks.multi_keys.%s" % attack)
                    else:
                        attack_module = importlib.import_module(
                            "attacks.single_key.%s" % attack)
                    try:
                        if attack_module.__SAGE__:
                            if not sageworks():
                                self.logger.warning(
                                    "Can't load %s because sage is not installed"
                                    % attack)
                                continue
                    except:
                        pass
                    self.implemented_attacks.append(attack_module)
                except ModuleNotFoundError:
                    pass
Exemplo n.º 2
0
 def can_run(self):
     """Test if everything is ok for running attack"""
     if self.sage_required:
         if not sageworks():
             self.logger.warning(
                 "Can't load %s because sage is not installed" % attack)
             return False
     return True