EDF Plasma Dissectors
Introduction
This package implements Plasma Framework's built-in dissectors.
Setup
# first, install edf-plasma-dissectors dependencies
apt install autoconf \
automake \
autopoint \
build-essential \
git \
libsystemd-dev \
libtool \
pkg-config \
python3-dev \
python3-venv
# create a virtual environment
python3 -m venv venv
# install edf-plasma-cli (will also install edf-plasma-core and edf-plasma-dissectors)
venv/bin/python -m pip install edf-plasma-dissectors[pcap,linux,binary,memdump,windows]
# then you can use it to create your own dissectors
Creating a Custom Dissector
Suppose we want to create a dissector extract and normalize data from auditd log files
"""Auditd Dissector"""
# ------------------------------------------------------------------------------
# import python libraries
# ------------------------------------------------------------------------------
from pathlib import Path
# ------------------------------------------------------------------------------
# import concepts and helpers from edf-plasma-core
# ------------------------------------------------------------------------------
from edf_plasma_core.concept import Tag
from edf_plasma_core.dissector import (
DissectionContext,
Dissector,
register_dissector,
)
from edf_plasma_core.helper.datetime import from_unix_timestamp, to_iso_fmt
from edf_plasma_core.helper.logging import get_logger
from edf_plasma_core.helper.matching import regexp
from edf_plasma_core.helper.selecting import select
from edf_plasma_core.helper.streaming import (
lines_from_filepath,
lines_from_gz_filepath,
)
from edf_plasma_core.helper.table import Column, DataType
from edf_plasma_core.helper.typing import PathIterator, RecordIterator
# ------------------------------------------------------------------------------
# initialize private globals (logger and constant values)
# ------------------------------------------------------------------------------
_LOGGER = get_logger('dissectors.linux.auditd')
_PATTERN = regexp(
r'type=(?P<type>[^\s]+) [^\(]+\((?P<date>[^\:]+):(?P<id>[^\)]+)\): (?P<data>.+)'
)
# ------------------------------------------------------------------------------
# implement the dissector selection routine
#
# the root directory storing artifacts is passed to the selection routine which
# usually walks through it recursively yielding path for files it can dissect.
# ------------------------------------------------------------------------------
def _select_impl(directory: Path) -> PathIterator:
pattern = 'audit.log*'
yield from select(directory, pattern)
# ------------------------------------------------------------------------------
# implement the dissector dissection routine
#
# each selected file is passed to the dissection routine using a dissection
# context. Artifact analysis produces records yielded by the dissection routine.
# ------------------------------------------------------------------------------
def _dissect_impl(ctx: DissectionContext) -> RecordIterator:
skipped = 0
lines_from_filepath_strategy = (
lines_from_gz_filepath
if ctx.filepath.suffix == '.gz'
else lines_from_filepath
)
for line in lines_from_filepath_strategy(ctx.filepath):
line = line.rstrip()
match = _PATTERN.search(line)
if not match:
skipped += 1
continue
auditd_date = float(match.group('date'))
auditd_date = from_unix_timestamp(auditd_date * 1000 * 1000)
yield {
'auditd_type': match.group('type'),
'auditd_date': to_iso_fmt(auditd_date),
'auditd_id': match.group('id'),
'auditd_data': match.group('data'),
}
if skipped:
_LOGGER.warning("skipped %s lines.", skipped)
# ------------------------------------------------------------------------------
# instanciate the dissector and define properties
# ------------------------------------------------------------------------------
DISSECTOR = Dissector(
slug='linux_auditd',
tags={Tag.LINUX},
columns=[
Column('auditd_type', DataType.STR),
Column('auditd_date', DataType.STR),
Column('auditd_id', DataType.INT),
Column('auditd_data', DataType.STR),
],
description="auditd log",
select_impl=_select_impl,
dissect_impl=_dissect_impl,
)
# ------------------------------------------------------------------------------
# dynamically register the dissector
# ------------------------------------------------------------------------------
register_dissector(DISSECTOR)
License
Distributed under the MIT License.
Contributing
Contributions are welcome. See CONTRIBUTING.md.
Past contributors (before open sourcing)
Security
To report a (suspected) security issue, see SECURITY.md.
Metadata
Release files for edf-plasma-dissectors 3.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| edf_plasma_dissectors-3.0.2-py3-none-any.whl | Python 3 | none | any | Details for edf_plasma_dissectors-3.0.2-py3-none-any.whl |
Release files / edf_plasma_dissectors-3.0.2-py3-none-any.whl
| Download URL | edf_plasma_dissectors-3.0.2-py3-none-any.whl |
|---|---|
| Size | 225.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6dab901aa2c07c9c02b9582311d565f7eff1d4651e48a48955a937506d584b6d
|
|
BLAKE2b-256 checksum How to use checksums |
65062f89dd05647f2c456f76310f64d0d57dda87dfe845b85e9915a7b6b4a8c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for edf-plasma-dissectors 3.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.