<commit_before># Copyright (C) 2010-2014 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.

from lib.cuckoo.common.abstracts import Processing

class TLSMasterSecrets(Processing):
    """Cross-references TLS master secrets extracted from the monitor and key
    information extracted from the PCAP to dump a master secrets file
    compatible with, e.g., Wireshark."""

    order = 2
    key = "dumptls"

    def run(self):
        metakeys = {}

        # Build server random -> session id from the pcap information.
        if "network" in self.results and "tls" in self.results["network"]:
            for row in self.results["network"]["tls"]:
                metakeys[row["server_random"]] = row["session_id"]

        results = {}

        # Fetch all key information from the behavior logs.
        for process in self.results.get("behavior", {}).get("processes", []):
            if process["process_name"] != "lsass.exe":
                continue<commit_msg>check master tls secrets file before using it<commit_after># Copyright (C) 2010-2014 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.

import logging
import os.path

from lib.cuckoo.common.abstracts import Processing

log = logging.getLogger(__name__)

class TLSMasterSecrets(Processing):
    """Cross-references TLS master secrets extracted from the monitor and key
    information extracted from the PCAP to dump a master secrets file
    compatible with, e.g., Wireshark."""

    order = 2
    key = "dumptls"

    def run(self):
        metakeys = {}

        if not os.path.exists(self.tlsmaster_path):
            log.info("TLS Master secrets file not found for analysis.")
            return

        # Build server random -> session id from the pcap information.
        if "network" in self.results and "tls" in self.results["network"]:
            for row in self.results["network"]["tls"]:
                metakeys[row["server_random"]] = row["session_id"]

        results = {}

        # Fetch all key information from the behavior logs.
        for process in self.results.get("behavior", {}).get("processes", []):
            if process["process_name"] != "lsass.exe":
                continue
{'fraction_non_alphanumeric': 0.10635593220338983, 'fraction_numerical': 0.007627118644067797, 'mean_word_length': 2.8142164781906303, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5083061', 'n_tokens_mistral': 682, 'n_tokens_neox': 646, 'n_words': 224}