예제 #1
0
 def test_builtin_fact_replacement_with_upstream_dest(
         self, loop, obfuscator, init_base_world):
     executor = Executor(
         name='psh',
         platform='windows',
         command=
         'echo #{paw} #{server} #{group} #{location} #{exe_name} #{upstream_dest}'
     )
     ability = Ability(ability_id='123', executors=[executor])
     agent = Agent(paw='123',
                   sleep_min=2,
                   sleep_max=8,
                   watchdog=0,
                   executors=['pwsh', 'psh'],
                   platform='windows',
                   group='my_group',
                   server='http://10.10.10.10:8888',
                   location='testlocation',
                   exe_name='testexe',
                   upstream_dest='http://127.0.0.1:12345')
     loop.run_until_complete(agent.task([ability], 'plain-text', []))
     assert 1 == len(agent.links)
     link = agent.links[0]
     decoded_command = b64decode(link.command).decode('utf-8')
     want = 'echo 123 http://10.10.10.10:8888 my_group testlocation testexe http://127.0.0.1:12345'
     assert want == decoded_command
예제 #2
0
    def test_task_with_facts(self, event_loop, obfuscator, init_base_world, knowledge_svc):
        executor = Executor(name='psh', platform='windows', command='net user #{domain.user.name} /domain')
        ability = Ability(ability_id='123', executors=[executor])
        agent = Agent(paw='123', sleep_min=2, sleep_max=8, watchdog=0, executors=['pwsh', 'psh'], platform='windows')
        fact = Fact(trait='domain.user.name', value='bob')

        event_loop.run_until_complete(agent.task([ability], 'plain-text', [fact]))
        assert 1 == len(agent.links)
예제 #3
0
    def test_task_with_facts(self, loop, obfuscator, init_base_world):
        ability = Ability(ability_id='123', test=BaseWorld.encode_string('net user #{domain.user.name} /domain'),
                          variations=[], executor='psh', platform='windows')
        agent = Agent(paw='123', sleep_min=2, sleep_max=8, watchdog=0, executors=['pwsh', 'psh'], platform='windows')
        fact = Fact(trait='domain.user.name', value='bob')

        loop.run_until_complete(agent.task([ability], 'plain-text', [fact]))
        assert 1 == len(agent.links)
예제 #4
0
 def test_task_no_facts(self, loop, data_svc, obfuscator, init_base_world):
     executor = Executor(name='psh', platform='windows', command='whoami')
     ability = Ability(ability_id='123', executors=[executor])
     agent = Agent(paw='123',
                   sleep_min=2,
                   sleep_max=8,
                   watchdog=0,
                   executors=['pwsh', 'psh'],
                   platform='windows')
     loop.run_until_complete(agent.task([ability], obfuscator='plain-text'))
     assert 1 == len(agent.links)
예제 #5
0
 def test_task_missing_fact(self, loop, obfuscator, init_base_world):
     executor = Executor(name='psh',
                         platform='windows',
                         command='net user #{domain.user.name} /domain')
     ability = Ability(ability_id='123', executors=[executor])
     agent = Agent(paw='123',
                   sleep_min=2,
                   sleep_max=8,
                   watchdog=0,
                   executors=['pwsh', 'psh'],
                   platform='windows')
     loop.run_until_complete(agent.task([ability], obfuscator='plain-text'))
     assert 0 == len(agent.links)
예제 #6
0
 def test_task_no_facts(self, loop, data_svc, obfuscator, init_base_world):
     ability = Ability(ability_id='123',
                       test=BaseWorld.encode_string('whoami'),
                       variations=[],
                       executor='psh',
                       platform='windows')
     agent = Agent(paw='123',
                   sleep_min=2,
                   sleep_max=8,
                   watchdog=0,
                   executors=['pwsh', 'psh'],
                   platform='windows')
     loop.run_until_complete(agent.task([ability], obfuscator='plain-text'))
     assert 1 == len(agent.links)
예제 #7
0
 def test_task_missing_fact(self, loop, init_base_world):
     ability = Ability(ability_id='123',
                       test=BaseWorld.encode_string(
                           'net user #{domain.user.name} /domain'),
                       variations=[],
                       executor='psh',
                       platform='windows')
     agent = Agent(paw='123',
                   sleep_min=2,
                   sleep_max=8,
                   watchdog=0,
                   executors=['pwsh', 'psh'],
                   platform='windows')
     loop.run_until_complete(agent.task([ability]))
     assert 0 == len(agent.links)