Esempio n. 1
0
    def test_initialize_global(self):
        set_cwd(tempfile.mkdtemp())
        cuckoo_create(
            cfg={
                "cuckoo": {
                    "cuckoo": {
                        "machinery": "virtualbox",
                    },
                    # This unittest will actually start the ResultServer.
                    "resultserver": {
                        "ip": "127.0.0.1",
                        "port": 3000,
                    },
                },
            })
        db.connect()

        self.m = VirtualBox()
        self.m.set_options(Config("virtualbox"))
        self.m._initialize("virtualbox")

        m, = db.list_machines()
        assert m.label == "cuckoo1"
        assert m.interface == "vboxnet0"
        assert m.ip == "192.168.56.101"
        assert m.options is None
        assert m.platform == "windows"
        assert m.resultserver_ip == "127.0.0.1"
        assert m.resultserver_port == 3000
        assert m.tags == []
Esempio n. 2
0
    def setup(self):
        set_cwd(tempfile.mkdtemp())
        cuckoo_create()

        with mock.patch("cuckoo.common.abstracts.Database") as p:
            p.return_value = mock.MagicMock()
            self.m = VirtualBox()

        self.m.set_options(Config("virtualbox"))
Esempio n. 3
0
    def setup(self):
        set_cwd(tempfile.mkdtemp())
        Folders.create(cwd(), "conf")
        write_cuckoo_conf()

        with mock.patch("cuckoo.common.abstracts.Database") as p:
            p.return_value = mock.MagicMock()
            self.m = VirtualBox()

        self.m.db.clean_machines.assert_called_once()
        self.m.set_options(Config("virtualbox"))
Esempio n. 4
0
    def test_initialize_specific(self):
        set_cwd(tempfile.mkdtemp())
        cuckoo_create(
            cfg={
                "cuckoo": {
                    "cuckoo": {
                        "machinery": "virtualbox",
                    },
                },
                "virtualbox": {
                    "cuckoo1": {
                        "label": "kookoo1",
                        "platform": "foobar",
                        "snapshot": "snapshot1",
                        "interface": "foo0",
                        "ip": "1.2.3.5",
                        "resultserver_ip": "1.2.3.4",
                        "resultserver_port": 1234,
                        # TODO Turn tags into a list.
                        "tags": "tag1,tag2",
                    },
                },
            })
        db.connect()

        self.m = VirtualBox()
        self.m.set_options(Config("virtualbox"))
        self.m._initialize("virtualbox")

        m, = db.list_machines()
        assert m.label == "kookoo1"
        assert m.platform == "foobar"
        assert m.snapshot == "snapshot1"
        assert m.interface == "foo0"
        assert m.ip == "1.2.3.5"
        assert m.resultserver_ip == "1.2.3.4"
        assert m.resultserver_port == 1234
        assert sorted((t.name for t in m.tags)) == ["tag1", "tag2"]