Ofer Schwartz

25 papers A 1Misc 6Journal 9Unranked 9
YearRankTypeTitle / Venue / Authors
2024 A conf
INTERSPEECH
Ofer Schwartz, Sharon Gannot
2024 J jnl
EURASIP J. Audio Speech Music. Process.
Ayal Schwartz, Ofer Schwartz, Shlomo E. Chazan, Sharon Gannot
2023 Misc conf
ICASSP
Ofer Schwartz, Ayal Schwartz
2022 Misc conf
ICASSP
Nir Raviv, Ofer Schwartz, Sharon Gannot
2022 conf
EUSIPCO
Ofer Schwartz
2021 J jnl
EURASIP J. Audio Speech Music. Process.
Ofer Schwartz, Sharon Gannot
2021 conf
EUSIPCO
Ofer Schwartz
2020 J jnl
EURASIP J. Audio Speech Music. Process.
Yuval Dorfan, Ofer Schwartz, Sharon Gannot
2020 Misc conf
ICASSP
Ofer Schwartz, Emanuël A. P. Habets, Sharon Gannot
2019 Misc conf
ICASSP
Koby Weisberg, Sharon Gannot, Ofer Schwartz
2018 conf
EUSIPCO
Ofer Schwartz, Sharon Gannot
2018 J jnl
IEEE ACM Trans. Audio Speech Lang. Process.
Sebastian Braun, Adam Kuklasinski, Ofer Schwartz, Oliver Thiergart, Emanuël A. P. Habets, Sharon Gannot, Simon Doclo, Jesper Jensen
2017 conf
WASPAA
Ofer Schwartz, Axel Plinge, Emanuël A. P. Habets, Sharon Gannot
2017 J jnl
IEEE ACM Trans. Audio Speech Lang. Process.
Ofer Schwartz, Sharon Gannot, Emanuël A. P. Habets
2017 conf
HSCMA
Ofer Schwartz, Yuval Dorfan, Maja Taseska, Emanuël A. P. Habets, Sharon Gannot
2017 J jnl
IEEE ACM Trans. Audio Speech Lang. Process.
Ofer Schwartz, Sharon Gannot, Emanuël A. P. Habets
2017 conf
LVA/ICA
Ofer Schwartz, Sebastian Braun, Sharon Gannot, Emanuël A. P. Habets
2016 J jnl
IEEE ACM Trans. Audio Speech Lang. Process.
Ofer Schwartz, Sharon Gannot, Emanuël A. P. Habets
2016 conf
EUSIPCO
Ofer Schwartz, Sharon Gannot, Emanuël A. P. Habets
2016 Misc conf
ICASSP
Ofer Schwartz, Sharon Gannot, Emanuël A. P. Habets
2016 conf
IWAENC
Ofer Schwartz, Yuval Dorfan, Emanuël A. P. Habets, Sharon Gannot
2015 conf
WASPAA
Ofer Schwartz, Sebastian Braun, Sharon Gannot, Emanuël A. P. Habets
2015 J jnl
IEEE ACM Trans. Audio Speech Lang. Process.
Ofer Schwartz, Sharon Gannot, Emanuël A. P. Habets
2015 Misc conf
ICASSP
Ofer Schwartz, Sharon Gannot, Emanuël A. P. Habets
2014 J jnl
IEEE ACM Trans. Audio Speech Lang. Process.
Ofer Schwartz, Sharon Gannot
redb/extractors/pe_extractors/pe_overlay.py
← Index redb/extractors/pe_extractors/pe_overlay.py python
from hashlib import md5, sha1, sha256
import inspect
from datetime import datetime, timezone
from typing import Any

import magic
from magika import Magika

from redb.extractors.enum import Tag
from redb.extractors.pe_extractor import PEExtractor
from redb.models.dataclasses import PEOverlay


class PEOverlayExtractor(PEExtractor):

    def __init__(
        self,
        filepath,
        log,
        exporters=None,
        index_prefix=None,
        elastic_index=None,
        known_benign=False,
        known_malicious=False,
        pe=None,
    ):
        super().__init__(
            filepath,
            log,
            exporters,
            index_prefix,
            elastic_index,
            known_benign,
            known_malicious,
            pe,
        )
        self.elastic_index = self.index_prefix + "-pe_overlay"
        self.log.debug(inspect.currentframe().f_code.co_name)

    def tag(self):
        return Tag.PE_OVERLAY.value

    def _extract_pe_overlay(self):
        self.log.debug(inspect.currentframe().f_code.co_name)
        overlay = self.pe.get_overlay()
        if overlay:
            return PEOverlay(
                _id=sha256(overlay).hexdigest(),
                overlay_size=len(overlay),
                overlay_entropy=self.calculate_entropy(overlay),
                overlay_offset=self.pe.get_overlay_data_start_offset(),
                overlay_mimetype=magic.from_buffer(overlay, mime=True),
                overlay_type=magic.from_buffer(overlay),
                overlay_magika=Magika().identify_bytes(overlay).output.ct_label,
                overlay_sha256=sha256(overlay).hexdigest(),
                overlay_sha1=sha1(overlay).hexdigest(),
                overlay_md5=md5(overlay).hexdigest(),
            )
        return None

    def extract(self):
        try:
            self.log.debug(inspect.currentframe().f_code.co_name)
            overlay = self._extract_pe_overlay()
            # self.export_to_elastic([overlay])  # Let the exporters handle this
            return overlay
        except Exception as e:
            self.log.error(f"Error extracting PE overlay: {e}")
            return None

    def prepare_export_data(self, exporter_type: str) -> Any:
        if exporter_type == "ElasticsearchExporter":
            return self.extract()
        elif exporter_type == "ClickHouseExporter":
            overlay = self.extract()
            if overlay is None:
                return None
            
            data = []
            current_time = datetime.now(timezone.utc)
            
            data.append([
                self.sha256,              # sha256
                self.md5,                 # md5
                self.sha1,                # sha1
                overlay.overlay_size,     # overlay_size
                overlay.overlay_entropy,  # overlay_entropy
                overlay.overlay_offset,   # overlay_offset
                overlay.overlay_mimetype, # overlay_mimetype
                overlay.overlay_type,     # overlay_type
                overlay.overlay_magika,   # overlay_magika
                overlay.overlay_sha256,   # overlay_sha256
                overlay.overlay_sha1,     # overlay_sha1
                overlay.overlay_md5,      # overlay_md5
                current_time             # analysis_date
            ])
            
            column_names = [
                'sha256', 'md5', 'sha1', 'overlay_size', 'overlay_entropy',
                'overlay_offset', 'overlay_mimetype', 'overlay_type', 'overlay_magika',
                'overlay_sha256', 'overlay_sha1', 'overlay_md5',
                'analysis_date'
            ]
            
            if not data:
                return None

            column_type_names = [
                'FixedString(64)', 'FixedString(32)', 'FixedString(40)',
                'UInt64', 'Float64', 'UInt64',
                'LowCardinality(String)', 'LowCardinality(String)', 'LowCardinality(String)',
                'FixedString(64)', 'FixedString(40)', 'FixedString(32)',
                'DateTime64(3, \'UTC\')'
            ]

            return (data, column_names, column_type_names)

    def get_clickhouse_table(self) -> str:
        return "redb_pe_overlays"