1
2
3
4
5 import json
6 import logging
7 import os.path
8
9 from lib.cuckoo.common.abstracts import Auxiliary
10 from lib.cuckoo.common.constants import CUCKOO_ROOT
11 from lib.cuckoo.common.exceptions import CuckooDisableModule
12
13 log = logging.getLogger(__name__)
14
19
21 log.error(
22 "Reboot analysis is not backwards compatible with the Old Agent, "
23 "please upgrade your target machine (%s) to the New Agent to use "
24 "the reboot analysis capabilities.", self.machine
25 )
26 raise CuckooDisableModule
27
29 files_json = os.path.join(analysis_path, "files.json")
30 if not os.path.exists(files_json):
31 return
32
33
34 for line in open(files_json, "rb"):
35 entry = json.loads(line)
36
37
38 if not entry["filepath"]:
39 continue
40
41 filepath = os.path.join(analysis_path, entry["path"])
42
43 data = {
44 "filepath": entry["filepath"],
45 }
46 files = {
47 "file": open(filepath, "rb"),
48 }
49 self.guest_manager.post("/store", files=files, data=data)
50
52 log.info("Preparing task #%d for a reboot analysis..", self.task.id)
53
54 analysis_path = os.path.join(
55 CUCKOO_ROOT, "storage", "analyses", self.task.custom
56 )
57
58 self._push_dropped_files(analysis_path)
59
60
61 files = {
62 "file": open(os.path.join(analysis_path, "reboot.json"), "rb"),
63 }
64 reboot_path = os.path.join(
65 self.guest_manager.analyzer_path, "reboot.json"
66 )
67 data = {
68 "filepath": reboot_path,
69 }
70 self.guest_manager.post("/store", files=files, data=data)
71