Skip to content

ScanIni

Parses keys from INI files.

Source code in strelka/src/python/strelka/scanners/scan_ini.py
class ScanIni(strelka.Scanner):
    """Parses keys from INI files."""

    def scan(self, data, file, options, expire_at):
        self.event["comments"] = []
        self.event["keys"] = []
        self.event["sections"] = []

        section = ""
        ini = data.splitlines()
        for key in ini:
            key = key.strip()
            if not key:
                continue

            if key.startswith(b"[") and key.endswith(b"]"):
                section = key[1:-1]
                self.event["sections"].append(section)
            elif key.startswith(b"#") or key.startswith(b";"):
                self.event["comments"].append(key)
            else:
                split_key = key.split(b"=")
                if len(split_key) == 1:
                    self.event["keys"].append(
                        {
                            "section": section,
                            "value": split_key[0].strip().strip(b'"\'"'),
                        }
                    )
                elif len(split_key) == 2:
                    self.event["keys"].append(
                        {
                            "section": section,
                            "name": split_key[0].strip().strip(b'"\'"'),
                            "value": split_key[1].strip().strip(b'"\'"'),
                        }
                    )

Features

The features of this scanner are detailed below. These features represent the capabilities and the type of analysis the scanner can perform. This may include support for Indicators of Compromise (IOC), the ability to emit files for further analysis, and the presence of extended documentation for complex analysis techniques.

Feature
Support
IOC Support
Emit Files
Extended Docs
Malware Scanner
Image Thumbnails

Tastes

Strelka's file distribution system assigns scanners to files based on 'flavors' and 'tastes'. Flavors describe the type of file, typically determined by MIME types from libmagic, matches from YARA rules, or characteristics of parent files. Tastes are the criteria used within Strelka to determine which scanners are applied to which files, with positive and negative tastes defining files to be included or excluded respectively.

Source Filetype
Include / Exclude

Scanner Fields

This section provides a list of fields that are extracted from the files processed by this scanner. These fields include the data elements that the scanner extracts from each file, representing the analytical results produced by the scanner. If the test file is missing or cannot be parsed, this section will not contain any data.

Field Name
Field Type
comments
list
elapsed
str
flags
list
keys
list
keys.name
bytes
keys.section
bytes
keys.value
bytes
sections
list

Sample Event

Below is a sample event generated by this scanner, demonstrating the kind of output that can be expected when it processes a file. This sample is derived from a mock scan event configured in the scanner's test file. If no test file is available, this section will not display a sample event.

    test_scan_event = {
        "elapsed": 0.001,
        "flags": [],
        "comments": [
            b"; Lorem ipsum dolor sit amet, consectetur adipiscing elit,",
            b";sed do eiusmod tempor incididunt ut labore et dolore magna",
            b";aliqua.",
            b"# Elementum sagittis vitae et leo duis ut diam.",
            b"# Nulla facilisi etiam dignissim diam quis.",
        ],
        "keys": [
            {"section": b"Lorem", "name": b"Update", "value": b"300"},
            {"section": b"Lorem", "name": b"Repeat", "value": b"24"},
            {"section": b"Ipsum", "name": b"Name", "value": b"Lorem Ipsum"},
            {"section": b"Ipsum", "name": b"Author", "value": b"Lorem"},
            {
                "section": b"Ipsum",
                "name": b"Information",
                "value": b"Volutpat commodo sed egestas egestas.",
            },
            {"section": b"Ipsum", "name": b"License", "value": b"Ipsum"},
            {"section": b"Ipsum", "name": b"Version", "value": b"1.0.1"},
        ],
        "sections": [b"Lorem", b"Ipsum"],
    }