Esempio n. 1
0
 def _convert_link_to_instruction(link):
     link.collect = datetime.now()
     return Instruction(identifier=link.unique,
                        sleep=link.jitter,
                        command=link.command,
                        executor=link.ability.executor,
                        timeout=link.ability.timeout,
                        payloads=link.ability.payloads)
Esempio n. 2
0
 def _convert_link_to_instruction(link):
     link.collect = datetime.now()
     payloads = [] if link.cleanup else link.ability.payloads
     return Instruction(id=link.unique,
                        sleep=link.jitter,
                        command=link.command,
                        executor=link.ability.executor,
                        timeout=link.ability.timeout,
                        payloads=payloads)
Esempio n. 3
0
 async def _get_bootstrap_instructions(self, agent):
     data_svc = self._services.get('data_svc')
     abilities = []
     for i in self._bootstrap_instructions:
         for a in await data_svc.locate('abilities',
                                        match=dict(ability_id=i)):
             abilities.append(a)
     x = 'bootstrap-%s-%s' % (agent.paw, self.generate_name(size=4))
     return [
         Instruction(command=i.test, link_id=x, executor=i.executor)
         for i in await agent.capabilities(abilities)
     ]
 def _convert_link_to_instruction(link):
     link.collect = datetime.now()
     payloads = [] if link.cleanup else link.executor.payloads
     uploads = [] if link.cleanup else link.executor.uploads
     return Instruction(id=link.unique,
                        sleep=link.jitter,
                        command=link.command,
                        executor=link.executor.name,
                        timeout=link.executor.timeout,
                        payloads=payloads,
                        uploads=uploads,
                        deadman=link.deadman)
Esempio n. 5
0
 async def _get_bootstrap_instructions(self, agent):
     data_svc = self._services.get('data_svc')
     abilities = []
     for i in self.get_config(name='agents', prop='bootstrap_abilities'):
         for a in await data_svc.locate('abilities', match=dict(ability_id=i)):
             abilities.append(a)
     instructions = []
     for x, i in enumerate(await agent.capabilities(abilities)):
         new_id = 'bootstrap-%s-%d' % (agent.paw, x)
         cmd = self.encode_string(agent.replace(i.test, file_svc=self.get_service('file_svc')))
         instructions.append(Instruction(identifier=new_id, command=cmd, executor=i.executor))
     return instructions
Esempio n. 6
0
 async def _get_instructions(self, paw):
     ops = await self.get_service('data_svc').locate('operations', match=dict(finish=None))
     instructions = []
     for link in [c for op in ops for c in op.chain
                  if c.paw == paw and not c.collect and c.status == c.states['EXECUTE']]:
         link.collect = datetime.now()
         instructions.append(Instruction(identifier=link.unique,
                                         sleep=link.jitter,
                                         command=link.command,
                                         executor=link.ability.executor,
                                         timeout=link.ability.timeout,
                                         payloads=link.ability.payloads))
     return instructions