Ejemplo n.º 1
0
 def get_technique_status_and_data():
     monkeys = Monkey.get_tunneled_monkeys()
     hops = []
     for monkey in monkeys:
         proxy_count = 0
         proxy = initial = monkey
         while proxy.tunnel:
             proxy_count += 1
             proxy = proxy.tunnel
         if proxy_count > 1:
             hops.append({
                 "from": initial.get_network_info(),
                 "to": proxy.get_network_info(),
                 "count": proxy_count,
             })
     status = ScanStatus.USED.value if hops else ScanStatus.UNSCANNED.value
     return (status, hops)
Ejemplo n.º 2
0
 def get_report_data():
     monkeys = Monkey.get_tunneled_monkeys()
     hops = []
     for monkey in monkeys:
         proxy_count = 0
         proxy = initial = monkey
         while proxy.tunnel:
             proxy_count += 1
             proxy = proxy.tunnel
         if proxy_count > 1:
             hops.append({'from': initial.get_network_info(),
                          'to': proxy.get_network_info(),
                          'count': proxy_count})
     status = ScanStatus.USED.value if hops else ScanStatus.UNSCANNED.value
     data = T1188.get_base_data_by_status(status)
     data.update({'hops': hops})
     return data
Ejemplo n.º 3
0
 def test_get_tunneled_monkeys(self):
     linux_monkey = Monkey(guid=str(uuid.uuid4()),
                           description="Linux shay-Virtual-Machine")
     windows_monkey = Monkey(guid=str(uuid.uuid4()),
                             description="Windows bla bla bla",
                             tunnel=linux_monkey)
     unknown_monkey = Monkey(guid=str(uuid.uuid4()),
                             description="bla bla bla",
                             tunnel=windows_monkey)
     linux_monkey.save()
     windows_monkey.save()
     unknown_monkey.save()
     tunneled_monkeys = Monkey.get_tunneled_monkeys()
     test = bool(windows_monkey in tunneled_monkeys
                 and unknown_monkey in tunneled_monkeys
                 and linux_monkey not in tunneled_monkeys
                 and len(tunneled_monkeys) == 2)
     assert test
Ejemplo n.º 4
0
    def test_get_tunneled_monkeys(self):
        self.fail_if_not_testing_env()
        self.clean_monkey_db()

        linux_monkey = Monkey(guid=str(uuid.uuid4()),
                              description="Linux shay-Virtual-Machine")
        windows_monkey = Monkey(guid=str(uuid.uuid4()),
                                description="Windows bla bla bla",
                                tunnel=linux_monkey)
        unknown_monkey = Monkey(guid=str(uuid.uuid4()),
                                description="bla bla bla",
                                tunnel=windows_monkey)
        linux_monkey.save()
        windows_monkey.save()
        unknown_monkey.save()
        tunneled_monkeys = Monkey.get_tunneled_monkeys()
        test = bool(windows_monkey in tunneled_monkeys
                    and unknown_monkey in tunneled_monkeys
                    and linux_monkey not in tunneled_monkeys
                    and len(tunneled_monkeys) == 2)
        self.assertTrue(test, "Tunneling test")