dissect.target 3.8.dev38__py3-none-any.whl → 3.8.dev40__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dissect/target/loaders/velociraptor.py +10 -1
 - dissect/target/plugins/apps/av/mcafee.py +141 -0
 - {dissect.target-3.8.dev38.dist-info → dissect.target-3.8.dev40.dist-info}/METADATA +1 -1
 - {dissect.target-3.8.dev38.dist-info → dissect.target-3.8.dev40.dist-info}/RECORD +9 -8
 - {dissect.target-3.8.dev38.dist-info → dissect.target-3.8.dev40.dist-info}/COPYRIGHT +0 -0
 - {dissect.target-3.8.dev38.dist-info → dissect.target-3.8.dev40.dist-info}/LICENSE +0 -0
 - {dissect.target-3.8.dev38.dist-info → dissect.target-3.8.dev40.dist-info}/WHEEL +0 -0
 - {dissect.target-3.8.dev38.dist-info → dissect.target-3.8.dev40.dist-info}/entry_points.txt +0 -0
 - {dissect.target-3.8.dev38.dist-info → dissect.target-3.8.dev40.dist-info}/top_level.txt +0 -0
 
| 
         @@ -53,4 +53,13 @@ class VelociraptorLoader(DirLoader): 
     | 
|
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
                def map(self, target: Target) -> None:
         
     | 
| 
       55 
55 
     | 
    
         
             
                    os_type, dirs = find_fs_directories(self.path)
         
     | 
| 
       56 
     | 
    
         
            -
                     
     | 
| 
      
 56 
     | 
    
         
            +
                    if os_type == OperatingSystem.WINDOWS:
         
     | 
| 
      
 57 
     | 
    
         
            +
                        # Velociraptor doesn't have the correct filenames for several files, like $J
         
     | 
| 
      
 58 
     | 
    
         
            +
                        map_dirs(
         
     | 
| 
      
 59 
     | 
    
         
            +
                            target,
         
     | 
| 
      
 60 
     | 
    
         
            +
                            dirs,
         
     | 
| 
      
 61 
     | 
    
         
            +
                            os_type,
         
     | 
| 
      
 62 
     | 
    
         
            +
                            usnjrnl_path="$Extend/$UsnJrnl%3A$J",
         
     | 
| 
      
 63 
     | 
    
         
            +
                        )
         
     | 
| 
      
 64 
     | 
    
         
            +
                    else:
         
     | 
| 
      
 65 
     | 
    
         
            +
                        map_dirs(target, dirs, os_type)
         
     | 
| 
         @@ -0,0 +1,141 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import ipaddress
         
     | 
| 
      
 2 
     | 
    
         
            +
            import re
         
     | 
| 
      
 3 
     | 
    
         
            +
            from collections import defaultdict
         
     | 
| 
      
 4 
     | 
    
         
            +
            from pathlib import Path
         
     | 
| 
      
 5 
     | 
    
         
            +
            from typing import Iterator
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            from dissect.sql import SQLite3
         
     | 
| 
      
 8 
     | 
    
         
            +
            from dissect.util.ts import from_unix
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            from dissect.target.exceptions import UnsupportedPluginError
         
     | 
| 
      
 11 
     | 
    
         
            +
            from dissect.target.helpers.record import TargetRecordDescriptor
         
     | 
| 
      
 12 
     | 
    
         
            +
            from dissect.target.plugin import Plugin, export
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            McAfeeMscLogRecord = TargetRecordDescriptor(
         
     | 
| 
      
 15 
     | 
    
         
            +
                "application/av/mcafee/msc/log",
         
     | 
| 
      
 16 
     | 
    
         
            +
                [
         
     | 
| 
      
 17 
     | 
    
         
            +
                    ("datetime", "ts"),
         
     | 
| 
      
 18 
     | 
    
         
            +
                    ("string", "threat"),
         
     | 
| 
      
 19 
     | 
    
         
            +
                    ("string", "message"),
         
     | 
| 
      
 20 
     | 
    
         
            +
                    ("string", "keywords"),
         
     | 
| 
      
 21 
     | 
    
         
            +
                    ("string", "fkey"),
         
     | 
| 
      
 22 
     | 
    
         
            +
                ],
         
     | 
| 
      
 23 
     | 
    
         
            +
            )
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            McAfeeMscFirewallRecord = TargetRecordDescriptor(
         
     | 
| 
      
 26 
     | 
    
         
            +
                "application/av/mcafee/msc/firewall",
         
     | 
| 
      
 27 
     | 
    
         
            +
                [
         
     | 
| 
      
 28 
     | 
    
         
            +
                    ("datetime", "ts"),
         
     | 
| 
      
 29 
     | 
    
         
            +
                    ("net.ipaddress", "ip"),
         
     | 
| 
      
 30 
     | 
    
         
            +
                    ("uint16", "port"),
         
     | 
| 
      
 31 
     | 
    
         
            +
                    ("string", "protocol"),
         
     | 
| 
      
 32 
     | 
    
         
            +
                    ("string", "message"),
         
     | 
| 
      
 33 
     | 
    
         
            +
                    ("string", "keywords"),
         
     | 
| 
      
 34 
     | 
    
         
            +
                    ("string", "fkey"),
         
     | 
| 
      
 35 
     | 
    
         
            +
                ],
         
     | 
| 
      
 36 
     | 
    
         
            +
            )
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            re_cdata = re.compile(r"<!\[CDATA\[(.*?)\]\]>", flags=re.M)
         
     | 
| 
      
 39 
     | 
    
         
            +
            re_strip_tags = re.compile(r"<[^!][^>]*>")
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            class McAfeePlugin(Plugin):
         
     | 
| 
      
 43 
     | 
    
         
            +
                __namespace__ = "mcafee"
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                DIRS = [
         
     | 
| 
      
 46 
     | 
    
         
            +
                    "sysvol/ProgramData/McAfee/MSC/Logs",  # Windows
         
     | 
| 
      
 47 
     | 
    
         
            +
                    "/opt/McAfee/ens/log/tp",  # Linux/Mac according to docs
         
     | 
| 
      
 48 
     | 
    
         
            +
                    "/opt/McAfee/ens/log/esp",  # Linux/Mac according to docs
         
     | 
| 
      
 49 
     | 
    
         
            +
                ]
         
     | 
| 
      
 50 
     | 
    
         
            +
                LOG_FILE_PATTERN = "*.log"
         
     | 
| 
      
 51 
     | 
    
         
            +
                TEMPLATE_ID_INFECTION = 102
         
     | 
| 
      
 52 
     | 
    
         
            +
                MARKER_INFECTION = "%INFECTION_INFO%"
         
     | 
| 
      
 53 
     | 
    
         
            +
                MARKER_SUSPICIOUS_TCP_CONNECTION = "TCP port "
         
     | 
| 
      
 54 
     | 
    
         
            +
                MARKER_SUSPICIOUS_UDP_CONNECTION = "UDP port "
         
     | 
| 
      
 55 
     | 
    
         
            +
                TABLE_LOG = "log"
         
     | 
| 
      
 56 
     | 
    
         
            +
                TABLE_FIELD = "field"
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                def check_compatible(self) -> bool:
         
     | 
| 
      
 59 
     | 
    
         
            +
                    if not self.get_log_files():
         
     | 
| 
      
 60 
     | 
    
         
            +
                        raise UnsupportedPluginError("No McAfee Log files found")
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                def get_log_files(self) -> Iterator[Path]:
         
     | 
| 
      
 63 
     | 
    
         
            +
                    for path in self.DIRS:
         
     | 
| 
      
 64 
     | 
    
         
            +
                        yield from self.target.fs.path(path).glob(self.LOG_FILE_PATTERN)
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                def _clean_message(self, message: str) -> str:
         
     | 
| 
      
 67 
     | 
    
         
            +
                    return re.sub(re_strip_tags, "", (" ".join(re.findall(re_cdata, message))))
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                @export(record=McAfeeMscLogRecord)
         
     | 
| 
      
 70 
     | 
    
         
            +
                def msc(self) -> Iterator[McAfeeMscLogRecord]:
         
     | 
| 
      
 71 
     | 
    
         
            +
                    """Return msc log history records from McAfee.
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                    Yields McAfeeMscLogRecord with the following fields:
         
     | 
| 
      
 74 
     | 
    
         
            +
                        hostname (string): The target hostname.
         
     | 
| 
      
 75 
     | 
    
         
            +
                        domain (string): The target domain.
         
     | 
| 
      
 76 
     | 
    
         
            +
                        ts (datetime): timestamp.
         
     | 
| 
      
 77 
     | 
    
         
            +
                        ip (net.ipadress): IP of suspicious connection (if available).
         
     | 
| 
      
 78 
     | 
    
         
            +
                        tcp_port (net.tcp.Port): TCP Port of suspicious incoming connection (if available).
         
     | 
| 
      
 79 
     | 
    
         
            +
                        udp_port (net.udp.Port): UDP Port of suspicious incoming connection (if available).
         
     | 
| 
      
 80 
     | 
    
         
            +
                        threat (string): Description of the detected threat (if available).
         
     | 
| 
      
 81 
     | 
    
         
            +
                        message (string): Message as reported in the user interface (might include template slots).
         
     | 
| 
      
 82 
     | 
    
         
            +
                        keywords (string): Unparsed fields that might be visible in user interface.
         
     | 
| 
      
 83 
     | 
    
         
            +
                        fkey (string): Foreign key for reference for further investigation.
         
     | 
| 
      
 84 
     | 
    
         
            +
                    """
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                    len_marker = len(self.MARKER_SUSPICIOUS_UDP_CONNECTION)
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                    for log_file in self.get_log_files():
         
     | 
| 
      
 89 
     | 
    
         
            +
                        with log_file.open() as open_log:
         
     | 
| 
      
 90 
     | 
    
         
            +
                            database = SQLite3(open_log)
         
     | 
| 
      
 91 
     | 
    
         
            +
                            fields = defaultdict(dict)
         
     | 
| 
      
 92 
     | 
    
         
            +
                            fields_table = database.table(self.TABLE_FIELD)
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                            for field in fields_table.rows():
         
     | 
| 
      
 95 
     | 
    
         
            +
                                fields[field.fkey][field.field_id] = field.data
         
     | 
| 
      
 96 
     | 
    
         
            +
                            log_table = database.table(self.TABLE_LOG)
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                            for entry in log_table.rows():
         
     | 
| 
      
 99 
     | 
    
         
            +
                                fkey = entry.fkey
         
     | 
| 
      
 100 
     | 
    
         
            +
                                log_fields = fields[fkey]
         
     | 
| 
      
 101 
     | 
    
         
            +
                                ip = None
         
     | 
| 
      
 102 
     | 
    
         
            +
                                protocol = None
         
     | 
| 
      
 103 
     | 
    
         
            +
                                port = None
         
     | 
| 
      
 104 
     | 
    
         
            +
                                threat = None
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                                for key, log_field in log_fields.items():
         
     | 
| 
      
 107 
     | 
    
         
            +
                                    try:
         
     | 
| 
      
 108 
     | 
    
         
            +
                                        ipaddress.ip_address(log_field)
         
     | 
| 
      
 109 
     | 
    
         
            +
                                        ip = log_field
         
     | 
| 
      
 110 
     | 
    
         
            +
                                        continue
         
     | 
| 
      
 111 
     | 
    
         
            +
                                    except ValueError:
         
     | 
| 
      
 112 
     | 
    
         
            +
                                        pass
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                                    if log_field.startswith(
         
     | 
| 
      
 115 
     | 
    
         
            +
                                        (self.MARKER_SUSPICIOUS_TCP_CONNECTION, self.MARKER_SUSPICIOUS_UDP_CONNECTION)
         
     | 
| 
      
 116 
     | 
    
         
            +
                                    ):
         
     | 
| 
      
 117 
     | 
    
         
            +
                                        port = int(log_field[len_marker:])
         
     | 
| 
      
 118 
     | 
    
         
            +
                                        protocol = log_field[:3]
         
     | 
| 
      
 119 
     | 
    
         
            +
                                        continue
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                                    if key == self.TEMPLATE_ID_INFECTION and entry.details_info.find(self.MARKER_INFECTION) > -1:
         
     | 
| 
      
 122 
     | 
    
         
            +
                                        threat = log_field
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                                if threat:
         
     | 
| 
      
 125 
     | 
    
         
            +
                                    yield McAfeeMscLogRecord(
         
     | 
| 
      
 126 
     | 
    
         
            +
                                        ts=from_unix(entry.date),
         
     | 
| 
      
 127 
     | 
    
         
            +
                                        threat=threat,
         
     | 
| 
      
 128 
     | 
    
         
            +
                                        message=self._clean_message(entry.details_info),
         
     | 
| 
      
 129 
     | 
    
         
            +
                                        keywords=",".join(log_fields.values()),
         
     | 
| 
      
 130 
     | 
    
         
            +
                                        fkey=entry.fkey,
         
     | 
| 
      
 131 
     | 
    
         
            +
                                    )
         
     | 
| 
      
 132 
     | 
    
         
            +
                                else:
         
     | 
| 
      
 133 
     | 
    
         
            +
                                    yield McAfeeMscFirewallRecord(
         
     | 
| 
      
 134 
     | 
    
         
            +
                                        ts=from_unix(entry.date),
         
     | 
| 
      
 135 
     | 
    
         
            +
                                        ip=ip,
         
     | 
| 
      
 136 
     | 
    
         
            +
                                        protocol=protocol,
         
     | 
| 
      
 137 
     | 
    
         
            +
                                        port=port,
         
     | 
| 
      
 138 
     | 
    
         
            +
                                        message=self._clean_message(entry.details_info),
         
     | 
| 
      
 139 
     | 
    
         
            +
                                        keywords=",".join(log_fields.values()),
         
     | 
| 
      
 140 
     | 
    
         
            +
                                        fkey=entry.fkey,
         
     | 
| 
      
 141 
     | 
    
         
            +
                                    )
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Metadata-Version: 2.1
         
     | 
| 
       2 
2 
     | 
    
         
             
            Name: dissect.target
         
     | 
| 
       3 
     | 
    
         
            -
            Version: 3.8. 
     | 
| 
      
 3 
     | 
    
         
            +
            Version: 3.8.dev40
         
     | 
| 
       4 
4 
     | 
    
         
             
            Summary: This module ties all other Dissect modules together, it provides a programming API and command line tools which allow easy access to various data sources inside disk images or file collections (a.k.a. targets)
         
     | 
| 
       5 
5 
     | 
    
         
             
            Author-email: Dissect Team <dissect@fox-it.com>
         
     | 
| 
       6 
6 
     | 
    
         
             
            License: Affero General Public License v3
         
     | 
| 
         @@ -72,12 +72,13 @@ dissect/target/loaders/tar.py,sha256=55chcbh9CDTczSmSPJ3O1FrfpXaZTTPL28Oqih8rPOA 
     | 
|
| 
       72 
72 
     | 
    
         
             
            dissect/target/loaders/target.py,sha256=mfkNz586eHb1PuzbwrvRPf9CcoPDLm5wPGFT1_rMH5s,662
         
     | 
| 
       73 
73 
     | 
    
         
             
            dissect/target/loaders/vb.py,sha256=CnQcn7bAkMzIB1y-lWLtPPXdIVsyeDaT6hTZEurjkV4,2072
         
     | 
| 
       74 
74 
     | 
    
         
             
            dissect/target/loaders/vbox.py,sha256=bOxsUiJ0IKx2GETs12FJkYChXBVatSkvWdLmhR5XPZc,691
         
     | 
| 
       75 
     | 
    
         
            -
            dissect/target/loaders/velociraptor.py,sha256= 
     | 
| 
      
 75 
     | 
    
         
            +
            dissect/target/loaders/velociraptor.py,sha256=X-nks-V1QpuEfzDgI0_MPu_Fi--a4BEL6g8dDn_3lHU,2555
         
     | 
| 
       76 
76 
     | 
    
         
             
            dissect/target/loaders/vma.py,sha256=sWjkQrdq3zAJyckInhvJVsVfihoU4wLM25RMT8L2KWo,519
         
     | 
| 
       77 
77 
     | 
    
         
             
            dissect/target/loaders/vmx.py,sha256=By8AmbBmVd3U13oIZs9_0mVV3tpWNPoJBLmHZXqs1GE,740
         
     | 
| 
       78 
78 
     | 
    
         
             
            dissect/target/loaders/xva.py,sha256=66rsZGPwrLOaHtzou5oicYuOdIWQOeKtvvXsGm89dqg,544
         
     | 
| 
       79 
79 
     | 
    
         
             
            dissect/target/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         
     | 
| 
       80 
80 
     | 
    
         
             
            dissect/target/plugins/apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         
     | 
| 
      
 81 
     | 
    
         
            +
            dissect/target/plugins/apps/av/mcafee.py,sha256=GkMLeprZo5mNqH-Ic1bml8tjoau_10vm7HDmE9nHF5Y,5403
         
     | 
| 
       81 
82 
     | 
    
         
             
            dissect/target/plugins/apps/av/trendmicro.py,sha256=v1Gf2CjZVwtr1xOJjHOEiMtfngMkIc84lITgOHXtjB4,4649
         
     | 
| 
       82 
83 
     | 
    
         
             
            dissect/target/plugins/apps/containers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         
     | 
| 
       83 
84 
     | 
    
         
             
            dissect/target/plugins/apps/containers/docker.py,sha256=Tro1bR4Mvub3lZlsfIocgr8Is3R7kS-g9iztA9jzObs,6289
         
     | 
| 
         @@ -252,10 +253,10 @@ dissect/target/volumes/bde.py,sha256=gYGg5yF9MNARwNzEkrEfZmKkxyZW4rhLkpdnPJCbhGk 
     | 
|
| 
       252 
253 
     | 
    
         
             
            dissect/target/volumes/disk.py,sha256=95grSsPt1BLVpKwTclwQYzPFGKTkFFqapIk0RoGWf38,968
         
     | 
| 
       253 
254 
     | 
    
         
             
            dissect/target/volumes/lvm.py,sha256=zXAfszxNR6tOGrKAtAa_E-JhjI-sXQyR4VYLXD-kqCw,1616
         
     | 
| 
       254 
255 
     | 
    
         
             
            dissect/target/volumes/vmfs.py,sha256=mlAJ8278tYaoRjk1u6tFFlCaDQUrVu5ZZE4ikiFvxi8,1707
         
     | 
| 
       255 
     | 
    
         
            -
            dissect.target-3.8. 
     | 
| 
       256 
     | 
    
         
            -
            dissect.target-3.8. 
     | 
| 
       257 
     | 
    
         
            -
            dissect.target-3.8. 
     | 
| 
       258 
     | 
    
         
            -
            dissect.target-3.8. 
     | 
| 
       259 
     | 
    
         
            -
            dissect.target-3.8. 
     | 
| 
       260 
     | 
    
         
            -
            dissect.target-3.8. 
     | 
| 
       261 
     | 
    
         
            -
            dissect.target-3.8. 
     | 
| 
      
 256 
     | 
    
         
            +
            dissect.target-3.8.dev40.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
         
     | 
| 
      
 257 
     | 
    
         
            +
            dissect.target-3.8.dev40.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
         
     | 
| 
      
 258 
     | 
    
         
            +
            dissect.target-3.8.dev40.dist-info/METADATA,sha256=6qDgBpgS4hDq07AxHuGwssySQBk0doDOKqPsjtADqx4,9752
         
     | 
| 
      
 259 
     | 
    
         
            +
            dissect.target-3.8.dev40.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
         
     | 
| 
      
 260 
     | 
    
         
            +
            dissect.target-3.8.dev40.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
         
     | 
| 
      
 261 
     | 
    
         
            +
            dissect.target-3.8.dev40.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
         
     | 
| 
      
 262 
     | 
    
         
            +
            dissect.target-3.8.dev40.dist-info/RECORD,,
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |