Exemple #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):
     ps = []
     for module in parsers:
         pcs = [(ParserConfig(**m)) for m in parsers[module]]
         ps.append(Parser(module=module, parserconfigs=pcs))
     rs = []
     for requirement in requirements:
         for module in requirement:
             relation = [
                 Relationship(source=r['source'],
                              edge=r.get('edge'),
                              target=r.get('target'))
                 for r in requirement[module]
             ]
             rs.append(Requirement(module=module, relationships=relation))
     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)
     ability.access = access
     return await self.store(ability)
Exemple #2
0
 async def _create_ability(self,
                           ability_id,
                           tactic,
                           technique_name,
                           technique_id,
                           name,
                           test,
                           description,
                           executor,
                           platform,
                           cleanup=None,
                           payload=None,
                           parsers=None,
                           requirements=None,
                           privilege=None,
                           timeout=60):
     ps = []
     for module in parsers:
         pcs = [(ParserConfig(**m)) for m in parsers[module]]
         ps.append(Parser(module=module, parserconfigs=pcs))
     rs = []
     for requirement in requirements:
         for module in requirement:
             relation = [
                 Relationship(source=r['source'],
                              edge=r.get('edge'),
                              target=r.get('target'))
                 for r in requirement[module]
             ]
             rs.append(Requirement(module=module, relationships=relation))
     return await self.store(
         Ability(ability_id=ability_id,
                 name=name,
                 test=test,
                 tactic=tactic,
                 technique_id=technique_id,
                 technique=technique_name,
                 executor=executor,
                 platform=platform,
                 description=description,
                 cleanup=cleanup,
                 payload=payload,
                 parsers=ps,
                 requirements=rs,
                 privilege=privilege,
                 timeout=timeout))
Exemple #3
0
 def from_json(cls, json):
     parserconfigs = [
         ParserConfig.from_json(r) for r in json['relationships']
     ]
     return cls(module=json['module'], parserconfigs=parserconfigs)