1
2
3
4
5
6 import logging
7 import time
8
9 from lib.cuckoo.common.abstracts import Auxiliary
10 from lib.cuckoo.common.config import Config
11 from lib.cuckoo.core.database import Database
12
13 log = logging.getLogger(__name__)
14 cfg = Config()
15 db = Database()
16
18 """Allows one or more additional VMs to be run next to an analysis. Either
19 as global services (which are generally never rebooted) or on a
20 per-analysis basis."""
21
31
35
37 self.tasks = []
38
39 if self.task.category == "service":
40 return
41
42
43 if not self.task.options.get("services"):
44 return
45
46 for service in self.options.get("services", "").split(","):
47 service = service.strip()
48 if not service:
49 continue
50
51 task_id = self.start_service(service)
52 self.tasks.append((task_id, service))
53
54 log.info("Started service %s #%d for task #%d",
55 service, task_id, self.task.id)
56
57
58
59 wait_states = "starting", "running", "stopping"
60 for task_id, service in self.tasks:
61 while db.guest_get_status(task_id) not in wait_states:
62 time.sleep(1)
63
64
65 timeout = self.options.get("timeout")
66 if isinstance(timeout, int):
67 time.sleep(timeout)
68
77