Esempio n. 1
0
    def test_route_network_none(self, mr):
        route = Route(FakeTask(), FakeMachine())
        route.route_network()

        assert route.route == "none"
        assert route.interface is None
        assert route.rt_table is None
        mr.assert_not_called()
Esempio n. 2
0
    def test_route_network_tor(self, mr):
        route = Route(FakeTask(options={"route": "tor"}), FakeMachine())
        route.route_network()

        assert route.route == "tor"
        assert route.interface is None
        assert route.rt_table is None
        mr.assert_called_once_with(
            "proxy_enable", "192.168.56.10", "192.168.56.1", "5353", "9040"
        )
Esempio n. 3
0
    def test_route_network_drop(self, mr):
        route = Route(FakeTask(options={"route": "drop"}), FakeMachine())
        route.route_network()

        assert route.route == "drop"
        assert route.interface is None
        assert route.rt_table is None
        mr.assert_called_once_with(
            "drop_enable", "192.168.56.10", "192.168.56.1", "2042"
        )
Esempio n. 4
0
    def test_route_network_inetsim(self, mr):
        route = Route(FakeTask(options={"route": "inetsim"}), FakeMachine())
        route.route_network()

        assert route.route == "inetsim"
        assert route.interface is None
        assert route.rt_table is None
        mr.assert_called_once_with(
            "inetsim_enable", "192.168.56.10", "192.168.56.1",
            "vboxnet0", "2042", ""
        )
Esempio n. 5
0
    def test_unroute_network_tor(self, mr):
        route = Route(FakeTask(), FakeMachine())
        route.route = "tor"
        route.unroute_network()

        mr.assert_has_calls([
            mock.call(
                "proxy_disable", "192.168.56.10", "192.168.56.1", "5353",
                "9040"
            )
        ])
Esempio n. 6
0
    def test_unroute_network_inetsim(self, mr):
        route = Route(FakeTask(), FakeMachine())
        route.route = "inetsim"
        route.unroute_network()

        mr.assert_has_calls([
            mock.call(
                "inetsim_disable", "192.168.56.10", "192.168.56.1", "vboxnet0",
                "2042", ""
            )
        ])
Esempio n. 7
0
    def test_unroute_network_socks5(self, mr):
        route = Route(FakeTask(), FakeMachine())
        route.route = "socks5"
        route.task.options["socks5.localport"] = 4242
        route.unroute_network()

        mr.assert_has_calls([
            mock.call(
                "proxy_disable", "192.168.56.10", "192.168.56.1", "53",
                "4242",
            )
        ])
Esempio n. 8
0
    def test_route_network_vpn(self, mr):
        mr.return_value = True
        route = Route(FakeTask(options={"route": "vpn0"}), FakeMachine())
        route.route_network()

        assert route.route == "vpn0"
        assert route.interface == "tun0"
        assert route.rt_table == "tun0"
        mr.assert_has_calls([
            mock.call("nic_available", "tun0"),
            mock.call("forward_enable", "tap0", "tun0", "192.168.56.10"),
            mock.call("srcroute_enable", "tun0", "192.168.56.10")
        ])
Esempio n. 9
0
    def test_unroute_network_vpn(self, mr):
        route = Route(FakeTask(), FakeMachine())
        route.route = "vpn0"
        route.unroute_network()
        route.rt_table = "tun0"
        route.interface = "tun0"
        route.unroute_network()

        mr.assert_has_calls([
            mock.call("forward_disable", "tap0", "tun0", "192.168.56.10"),
            mock.call("srcroute_disable", "tun0", "192.168.56.10"),
        ])
Esempio n. 10
0
 def test_route_network_socks5_noport(self, mr):
     write_cuckoo_conf(cfg={
         "auxiliary": {
             "redsocks": {
                 "enabled": True
             }
         }
     })
     route = Route(FakeTask(options={
         "route": "socks5"
     }), FakeMachine())
     route.route_network()
     assert route.route == "none"
     assert route.task.options["route"] is "none"
     assert route.interface is None
     assert route.rt_table is None
     mr.assert_not_called()
Esempio n. 11
0
 def test_route_network_socks5(self, mr):
     write_cuckoo_conf(cfg={
         "auxiliary": {
             "redsocks": {
                 "enabled": True
             }
         }
     })
     route = Route(FakeTask(options={
         "route": "socks5",
         "socks5.localport": 4242
     }), FakeMachine())
     route.route_network()
     assert route.route == "socks5"
     assert route.interface is None
     assert route.rt_table is None
     mr.assert_called_once_with(
         "proxy_enable", "192.168.56.10", "192.168.56.1", "53", "4242"
     )
Esempio n. 12
0
    def test_route_network_internet(self, mr):
        write_cuckoo_conf(cfg={
            "routing": {
                "routing": {
                    "internet": "eth0"
                }
            }
        })
        # Clear config cache so it will load new values
        config._cache = {}
        mr.return_value = True
        route = Route(FakeTask(options={"route": "internet"}), FakeMachine())
        route.route_network()

        assert route.route == "internet"
        assert route.interface == "eth0"
        assert route.rt_table == "main"
        mr.assert_has_calls([
            mock.call("nic_available", "eth0"),
            mock.call("drop_enable", "192.168.56.10", "192.168.56.1", "2042"),
            mock.call("forward_enable", "tap0", "eth0", "192.168.56.10"),
            mock.call("srcroute_enable", "main", "192.168.56.10")
        ])
Esempio n. 13
0
    def test_unroute_network_none(self, mr):
        route = Route(FakeTask(), FakeMachine())
        route.route = "none"
        route.unroute_network()

        mr.assert_not_called()