ScanRpm
Collects metadata and extracts files from RPM files.
Options
tmp_directory: Location where tempfile writes temporary files.
Defaults to '/tmp/'.
Source code in strelka/src/python/strelka/scanners/scan_rpm.py
| class ScanRpm(strelka.Scanner):
"""Collects metadata and extracts files from RPM files.
Options:
tmp_directory: Location where tempfile writes temporary files.
Defaults to '/tmp/'.
"""
def scan(self, data, file, options, expire_at):
tmp_directory = options.get("tmp_directory", "/tmp/")
with tempfile.NamedTemporaryFile(dir=tmp_directory) as tmp_data:
tmp_data.write(data)
tmp_data.flush()
try:
with rpmfile.open(tmp_data.name) as rpm_obj:
extract_name = ""
for key, value in rpm_obj.headers.items():
if key == "arch":
self.event["architecture"] = value
elif key == "archive_compression":
self.event["archive_compression"] = value
elif key == "archive_format":
self.event["archive_format"] = value
elif key == "authors":
self.event["authors"] = value
elif key == "buildhost":
self.event["build_host"] = value
elif key == "buildtime":
self.event["build_time"] = value
elif key == "copyright":
self.event["copyright"] = value
elif key == "description":
if value is not None:
self.event["description"] = value.replace(b"\n", b" ")
elif key == "filenames":
self.event["filenames"] = value
elif key == "group":
self.event["group"] = value
elif key == "name":
self.event["name"] = value
extract_name = f"{value.decode()}"
elif key == "os":
self.event["os"] = value
elif key == "packager":
self.event["packager"] = value
elif key == "provides":
self.event["provides"] = value
elif key == "release":
self.event["release"] = value
elif key == "requirename":
self.event["require_name"] = value
elif key == "rpmversion":
self.event["rpm_version"] = value
elif key == "serial":
self.event["serial"] = value
elif key == "sourcerpm":
self.event["source_rpm"] = value
elif key == "summary":
self.event["summary"] = value
elif key == "vendor":
self.event["vendor"] = value
elif key == "version":
self.event["version"] = value
elif key == "url":
self.event["url"] = value
# Send extracted file back to Strelka
self.emit_file(
data[rpm_obj.data_offset :], name=extract_name
) # FIXME: extract_name always empty string
except ValueError:
self.flags.append("value_error")
|
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 |
application/x-rpm |
|
rpm_file |
|
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.
Failure
No fields to display. The test file may not exist or could not be processed.
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.
Failure
Test file not found for scanner rpm