예제 #1
0
 async def _create_ability(self,
                           ability_id,
                           tactic=None,
                           technique_name=None,
                           technique_id=None,
                           name=None,
                           test=None,
                           description=None,
                           executor=None,
                           platform=None,
                           cleanup=None,
                           payloads=None,
                           parsers=None,
                           requirements=None,
                           privilege=None,
                           timeout=60,
                           access=None,
                           buckets=None,
                           repeatable=False,
                           code=None,
                           language=None,
                           build_target=None,
                           variations=None,
                           **kwargs):
     ps = []
     for module in parsers:
         ps.append(
             Parser.load(dict(module=module,
                              parserconfigs=parsers[module])))
     rs = []
     for requirement in requirements:
         for module in requirement:
             rs.append(
                 Requirement.load(
                     dict(module=module,
                          relationship_match=requirement[module])))
     ability = Ability(ability_id=ability_id,
                       name=name,
                       test=test,
                       tactic=tactic,
                       technique_id=technique_id,
                       technique=technique_name,
                       code=code,
                       language=language,
                       executor=executor,
                       platform=platform,
                       description=description,
                       build_target=build_target,
                       cleanup=cleanup,
                       payloads=payloads,
                       parsers=ps,
                       requirements=rs,
                       privilege=privilege,
                       timeout=timeout,
                       repeatable=repeatable,
                       variations=variations,
                       buckets=buckets,
                       **kwargs)
     ability.access = access
     return await self.store(ability)
예제 #2
0
 async def _load_executor_parsers(parsers):
     ps = []
     for module in parsers:
         ps.append(
             Parser.load(dict(module=module,
                              parserconfigs=parsers[module])))
     return ps
예제 #3
0
 def from_json(cls, json):
     parsers = [Parser.load(p) for p in json['parsers']]
     requirements = [Requirement.from_json(r) for r in json['requirements']]
     return cls(ability_id=json['ability_id'],
                tactic=json['tactic'],
                technique_id=json['technique_id'],
                technique=json['technique_name'],
                name=json['name'],
                test=json['test'],
                variations=[],
                description=json['description'],
                cleanup=json['cleanup'],
                executor=json['executor'],
                platform=json['platform'],
                payloads=json['payloads'],
                parsers=parsers,
                requirements=requirements,
                privilege=json['privilege'],
                buckets=json['buckets'],
                timeout=json['timeout'],
                access=json['access'])