Mahsa Salehi

70 papers A* 7A 3B 2Misc 1Journal 37Unranked 19
YearRankTypeTitle / Venue / Authors
2025 J jnl
Pattern Recognit.
Zahra Zamanzadeh Darban, Geoffrey I. Webb, Shirui Pan, Charu C. Aggarwal, Mahsa Salehi
2025 J jnl
CoRR
Zahra Zamanzadeh Darban, Qizhou Wang, Charu C. Aggarwal, Geoffrey I. Webb, Ehsan Abbasnejad, Mahsa Salehi
2025 conf
ECML/PKDD (9)
Sajjad Shumaly, Fahimeh Darvish, Mahsa Salehi, Navid Mohammadi Foumani, Oleksandra Kukharenko, Hans-Jürgen Butt, Ulrich Schwanecke, Rüdiger Berger
2025 J jnl
IEEE Trans. Knowl. Data Eng.
Zahra Zamanzadeh Darban, Yiyuan Yang, Geoffrey I. Webb, Charu C. Aggarwal, Qingsong Wen, Shirui Pan, Mahsa Salehi
2025 J jnl
ACM Comput. Surv.
Zahra Zamanzadeh Darban, Geoffrey I. Webb, Shirui Pan, Charu Aggarwal, Mahsa Salehi
2025 J jnl
CoRR
Navid Mohammadi Foumani, Soheila Ghane, Nam Nguyen, Mahsa Salehi, Geoffrey I. Webb, Geoffrey Mackellar
2025 conf
SIGSPATIAL/GIS
Muhammad Insan Al-Amin, Jinchun Du, Muhammad Aamir Cheema, Isma Farah Siddiqui, Mahsa Salehi
2025 J jnl
CoRR
Zahra Zamanzadeh Darban, Qizhou Wang, Geoffrey I. Webb, Shirui Pan, Charu C. Aggarwal, Mahsa Salehi
2025 J jnl
CoRR
Angus Dempster, Navid Mohammadi Foumani, Chang Wei Tan, Lynn Miller, Amish Mishra, Mahsa Salehi, Charlotte Pelletier, Daniel F. Schmidt, Geoffrey I. Webb
2025 J jnl
J. Data-centric Mach. Learn. Res.
Angus Dempster, Navid Mohammadi Foumani, Chang Wei Tan, Lynn Miller, Amish Mishra, Mahsa Salehi, Charlotte Pelletier, Daniel F. Schmidt, Geoffrey I. Webb
2025 A* conf
ICLR
Qizhou Wang, Guansong Pang, Mahsa Salehi, Xiaokun Xia, Christopher Leckie
2025 J jnl
Data Min. Knowl. Discov.
Chang Wei Tan, Matthieu Herrmann, Mahsa Salehi, Geoffrey I. Webb
2025 conf
WWW (Companion Volume)
Ming Jin, Mahsa Salehi, Yuxuan Liang, Dongjin Song, Flora Salim, Min Wu, Shirui Pan, Qingsong Wen
2024 J jnl
CoRR
Zahra Zamanzadeh Darban, Geoffrey I. Webb, Mahsa Salehi
2024 J jnl
ACM Comput. Surv.
Navid Mohammadi Foumani, Lynn Miller, Chang Wei Tan, Geoffrey I. Webb, Germain Forestier, Mahsa Salehi
2024 A* conf
KDD
Navid Mohammadi Foumani, Geoffrey Mackellar, Soheila Ghane, Saad Irtza, Nam Nguyen, Mahsa Salehi
2024 J jnl
CoRR
Navid Mohammadi Foumani, Geoffrey Mackellar, Soheila Ghane, Saad Irtza, Nam Nguyen, Mahsa Salehi
2024 J jnl
CoRR
Mahsa Salehi, Kalin Stefanov, Ehsan Shareghi
2024 J jnl
Data Min. Knowl. Discov.
Navid Mohammadi Foumani, Chang Wei Tan, Geoffrey I. Webb, Mahsa Salehi
2024 conf
ACL (Short Papers)
Gia-Bao Dinh Ho, Chang Wei Tan, Zahra Zamanzadeh Darban, Mahsa Salehi, Reza Haffari, Wray L. Buntine
2024 J jnl
CoRR
Gia-Bao Dinh Ho, Chang Wei Tan, Zahra Zamanzadeh Darban, Mahsa Salehi, Gholamreza Haffari, Wray L. Buntine
2024 A conf
LAK
Mladen Rakovic, Yuheng Li, Navid Mohammadi Foumani, Mahsa Salehi, Levin Kuhlmann, Geoffrey Mackellar, Roberto Martínez Maldonado, Gholamreza Haffari, Zachari Swiecki, Xinyu Li, Guanliang Chen, Dragan Gasevic
2024 conf
SmartGridComm
Thusitha Dayaratne, Carsten Rudolph, Mahsa Salehi, Ariel Liebman
2024 J jnl
Data Min. Knowl. Discov.
Navid Mohammadi Foumani, Chang Wei Tan, Geoffrey I. Webb, Hamid Rezatofighi, Mahsa Salehi
2023 J jnl
CoRR
Zahra Zamanzadeh Darban, Geoffrey I. Webb, Shirui Pan, Mahsa Salehi
2023 A* conf
AAAI
Qizhou Wang, Guansong Pang, Mahsa Salehi, Wray L. Buntine, Christopher Leckie
2023 J jnl
CoRR
Seyed Navid Mohammadi Foumani, Lynn Miller, Chang Wei Tan, Geoffrey I. Webb, Germain Forestier, Mahsa Salehi
2023 J jnl
CoRR
Thusitha Dayaratne, Carsten Rudolph, Ariel Liebman, Mahsa Salehi
2023 J jnl
CoRR
Seyed Navid Mohammadi Foumani, Chang Wei Tan, Geoffrey I. Webb, Mahsa Salehi
2023 conf
PKDD/ECML Workshops (4)
Yueyi Ge, Ingrid Zukerman, Mahsa Salehi, Mor Vered
2023 J jnl
CoRR
Qizhou Wang, Guansong Pang, Mahsa Salehi, Wray L. Buntine, Christopher Leckie
2023 J jnl
CoRR
Matthieu Herrmann, Chang Wei Tan, Mahsa Salehi, Geoffrey I. Webb
2023 J jnl
CoRR
Navid Mohammadi Foumani, Chang Wei Tan, Geoffrey I. Webb, Hamid Rezatofighi, Mahsa Salehi
2022 J jnl
Data Min. Knowl. Discov.
Chaitanya Manapragada, Heitor Murilo Gomes, Mahsa Salehi, Albert Bifet, Geoffrey I. Webb
2022 J jnl
CoRR
Qizhou Wang, Guansong Pang, Mahsa Salehi, Wray L. Buntine, Christopher Leckie
2022 J jnl
CoRR
Zahra Zamanzadeh Darban, Geoffrey I. Webb, Shirui Pan, Charu C. Aggarwal, Mahsa Salehi
2022 conf
PAKDD (2)
Qizhou Wang, Mahsa Salehi, Jia Shun Low, Wray L. Buntine, Christopher Leckie
2022 A* conf
ICDM
Chaitanya Manapragada, Mahsa Salehi, Geoffrey I. Webb
2022 A conf
DSN
Thusitha Dayaratne, Mahsa Salehi, Carsten Rudolph, Ariel Liebman
2022 J jnl
Inf. Process. Manag.
Chang How Tan, Vincent C. S. Lee, Mahsa Salehi
2021 conf
ICDM (Workshops)
Chang How Tan, Vincent C. S. Lee, Mahsa Salehi, Slaven Marusic, Srimal Jayawardena, Dion Lucke
2021 J jnl
Data Min. Knowl. Discov.
Yassien Shaalan, Xiuzhen Zhang, Jeffrey Chan, Mahsa Salehi
2021 conf
ICDM (Workshops)
Seyed Navid Mohammadi Foumani, Chang Wei Tan, Mahsa Salehi
2021 conf
CODASPY
Thusitha Dayaratne, Carsten Rudolph, Ariel Liebman, Mahsa Salehi
2020 J jnl
CoRR
Chaitanya Manapragada, Heitor Murilo Gomes, Mahsa Salehi, Albert Bifet, Geoffrey I. Webb
2020 J jnl
CoRR
Chang Wei Tan, Mahsa Salehi, Geoffrey Mackellar
2020 J jnl
CoRR
Chaitanya Manapragada, Geoffrey I. Webb, Mahsa Salehi, Albert Bifet
2020 J jnl
IEEE Internet Things J.
Shangqi Lai, Xingliang Yuan, Amin Sakzad, Mahsa Salehi, Joseph K. Liu, Dongxi Liu
2020 B conf
NOMS
Thusitha Dayaratne, Carsten Rudolph, Ariel Liebman, Mahsa Salehi
2020 conf
ICDM (Workshops)
Chang How Tan, Vincent C. S. Lee, Mahsa Salehi
2020 conf
ISGT-Europe
Thusitha Dayaratne, Carsten Rudolph, Ariel Liebman, Mahsa Salehi
2019 J jnl
CoRR
Shangqi Lai, Xingliang Yuan, Amin Sakzad, Mahsa Salehi, Joseph K. Liu, Dongxi Liu
2019 conf
ISGT Europe
Thusitha Dayaratne, Carsten Rudolph, Ariel Liebman, Mahsa Salehi, Shan He
2019 J jnl
CoRR
Chang How Tan, Vincent C. S. Lee, Mahsa Salehi
2018 J jnl
SIGKDD Explor.
Mahsa Salehi, Lida Rashidi
2018 conf
WISE (2)
Xuyun Zhang, Mahsa Salehi, Christopher Leckie, Yun Luo, Qiang He, Rui Zhou, Rao Kotagiri
2018 A* conf
KDD
Chaitanya Manapragada, Geoffrey I. Webb, Mahsa Salehi
2018 J jnl
CoRR
Chaitanya Manapragada, Geoffrey I. Webb, Mahsa Salehi
2018 conf
PAKDD (2)
Milad Chenaghlou, Masud Moshtaghi, Christopher Leckie, Mahsa Salehi
2017 conf
GeoRich@SIGMOD
Ziyuan Wang, Hoang Tam Vo, Mahsa Salehi, Laura Irina Rusu, Claire Reeves, Anna Phan
2017 B conf
GLOBECOM
Milad Chenaghlou, Masud Moshtaghi, Christopher Leckie, Mahsa Salehi
2017 A* conf
ICDE
Mahsa Salehi, Christopher Leckie, James C. Bezdek, Tharshan Vaithianathan, Xuyun Zhang
2016 Misc conf
ADC
Laura Irina Rusu, Hoang Tam Vo, Ziyuan Wang, Mahsa Salehi, Anna Phan
2016 A* conf
KDD
Mahsa Salehi, Laura Irina Rusu, Timothy M. Lynar, Anna Phan
2016 J jnl
IEEE Trans. Knowl. Data Eng.
Mahsa Salehi, Christopher Leckie, James C. Bezdek, Tharshan Vaithianathan, Xuyun Zhang
2016 conf
Australasian Conference on Artificial Intelligence
Mahsa Salehi, Xuyun Zhang, James C. Bezdek, Christopher Leckie
2015
Mahsa Salehi
2015 conf
ISSNIP
Mahsa Salehi, Christopher Leckie, James C. Bezdek, Tharshan Vaithianathan
2015 A conf
CIKM
Minh Tuan Doan, Sutharshan Rajasegarar, Mahsa Salehi, Masud Moshtaghi, Christopher Leckie
2014 conf
PAKDD (2)
Mahsa Salehi, Christopher A. Leckie, Masud Moshtaghi, Tharshan Vaithianathan
redb/extractors/pe_extractors/pe_extra_findings.py
← Index redb/extractors/pe_extractors/pe_extra_findings.py python
from hashlib import md5, sha1, sha256
import inspect
import pefile
from magika import Magika
import json
from datetime import datetime, timezone
from typing import List, Optional, Any
from asn1crypto import cms, pem, x509, core
from dataclasses import asdict

from redb.extractors.enum import Tag
from redb.extractors.pe_extractor import PEExtractor
from redb.models.dataclasses import PEExtraFinding, PECertificate


class PEExtraFindings(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_extrafindings"
        self.log.debug(inspect.currentframe().f_code.co_name)
        self.has_binary_overlay = False
        self.has_binary_resource = False
        self.findings = []

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

    """
    The section below triggers in case of a binary which is not signed.
    It trigger the scan for Certificates inside the binary, for example
    inside a resource or an overlay.
    """

    def _scan_for_certificates(self):
        """
        Comprehensive scan for certificate data in PE file.
        Returns list of tuples (location_description, certificate_data)
        """
        self.log.debug(inspect.currentframe().f_code.co_name)

        # 1. Scan resources for embedded PE files
        self._scan_resources_for_certificates()

        # 3. Scan overlay
        overlay_data = self.pe.get_overlay()
        if overlay_data:
            self._scan_overlay_for_certificates(overlay_data)


    def _extract_certificate_info(self, cert_data):
        self.log.debug(inspect.currentframe().f_code.co_name)

        certificate = x509.Certificate.load(cert_data)
        certificate_serial_number = format(certificate.serial_number, "x").upper()
        grouped_serial_number = ":".join(
            [
                certificate_serial_number[i : i + 2]
                for i in range(0, len(certificate_serial_number), 2)
            ]
        )
        return PECertificate(
            certificate_serial_number=grouped_serial_number,
            certificate_issuer=certificate.issuer.human_friendly,
            certificate_subject=certificate.subject.human_friendly,
            certificate_valid_from=certificate["tbs_certificate"]["validity"][
                "not_before"
            ].native.strftime("%Y-%m-%d %H:%M:%S"),
            certificate_valid_to=certificate["tbs_certificate"]["validity"][
                "not_after"
            ].native.strftime("%Y-%m-%d %H:%M:%S"),
            certificate_thumbprint=sha1(cert_data).hexdigest().upper(),
            certificate_algorithm=None,
        )

    def _extract_standard_certificates(self, pe):
        self.log.debug(inspect.currentframe().f_code.co_name)
        address = pe.OPTIONAL_HEADER.DATA_DIRECTORY[
            pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_SECURITY"]
        ].VirtualAddress
        size = pe.OPTIONAL_HEADER.DATA_DIRECTORY[
            pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_SECURITY"]
        ].Size

        addr_8 = address + 8
        signature_data = bytes(
            pe.write()[addr_8 : addr_8 + size]  # noqa E203
        )  # Ensure this is a bytes object
        if pem.detect(signature_data):
            signature_data = pem.unarmor(signature_data)

        content_info = cms.ContentInfo.load(signature_data)
        signed_data = content_info["content"]
        certificates = signed_data["certificates"]

        certificates_list = []
        for cert in certificates:
            cert_info = self._extract_certificate_info(cert.chosen.dump())
            certificates_list.append(cert_info)

        return certificates_list

    def _is_signed(self, pedata):
        address = pedata.OPTIONAL_HEADER.DATA_DIRECTORY[
            pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_SECURITY"]
        ].VirtualAddress
        if address == 0:
            return False
        return True

    def _scan_resources_for_certificates(self):
        """Scan resources for embedded PE files and their certificates"""
        self.log.debug(inspect.currentframe().f_code.co_name)

        try:
            if hasattr(self.pe, "DIRECTORY_ENTRY_RESOURCE"):
                for entry in self.pe.DIRECTORY_ENTRY_RESOURCE.entries:
                    for resource in self._get_resource_data(entry):
                        # Check if resource data might be a PE file
                        resource_magika = Magika().identify_bytes(resource).output.label
                        if resource.startswith(b"MZ") or resource_magika == "pebin":
                            try:
                                embedded_pe = pefile.PE(data=resource)
                                if self._is_signed(embedded_pe):
                                    cert_data = self._extract_standard_certificates(
                                        embedded_pe
                                    )
                                    if cert_data:
                                        # certificates.append(
                                        #     (f"Resource_{entry.id}", cert_data)
                                        # )
                                        self.findings.append(
                                            PEExtraFinding(
                                                context=f"Resource ({sha256(resource).hexdigest()}) is a PE file. Found Code Signing Certificates information inside.",
                                                finding=cert_data,
                                            )
                                        )
                            except Exception as e:
                                self.log.warning(
                                    f"Resource {sha256(resource).hexdigest()} is not a valid PE: {e}"
                                )

                        # Direct certificate pattern matching in resource
                        cert_data = self._find_certificate_patterns(resource)
                        if cert_data:
                            # certificates.append((f"Resource_{entry.id}", cert_data))
                            self.findings.append(
                                PEExtraFinding(
                                    context=f"Resource ({sha256(resource).hexdigest()}) is a PE file.\
                                    Found Code Signing Certificates information inside.",
                                    finding=cert_data,
                                )
                            )

        except Exception as e:
            self.log.error(f"Failed to scan resources: {e}")


    def _scan_overlay_for_certificates(self, overlay_data) -> List[bytes]:
        """Scan PE overlay for certificate data"""
        self.log.debug(inspect.currentframe().f_code.co_name)
        try:
            # Check if overlay is a PE file
            overlay_magika = Magika().identify_bytes(overlay_data).output.ct_label
            if overlay_data.startswith(b"MZ") or overlay_magika == "pebin":
                try:
                    overlay_pe = pefile.PE(data=overlay_data)
                    if self._is_signed(overlay_pe):
                        cert_data = self._extract_standard_certificates(overlay_data)
                        if cert_data:
                            self.findings.append(
                                PEExtraFinding(
                                    context=f"Overlay data ({sha256(overlay_data).hexdigest()}) is a PE file.\
                                    Found Code Signing Certificates information inside.",
                                    finding=cert_data,
                                )
                            )
                except Exception as e:
                    self.log.warning(f"Error looking for certificates in Overlay: {e}")
                    pass

            # Direct certificate pattern matching in overlay
            cert_data = self._find_certificate_patterns(overlay_data)
            if cert_data:
                self.findings.append(
                    PEExtraFinding(
                        context=f"Overlay data ({sha256(overlay_data).hexdigest()}) is a PE file.\
                        Found Code Signing Certificates information inside.",
                        finding=cert_data,
                    )
                )
        except Exception as e:
            self.log.error(f"Failed to scan overlay: {e}")


    def _get_resource_data(self, entry) -> List[bytes]:
        """Recursively get resource data"""
        resources = []
        try:
            if hasattr(entry, "directory"):
                for subentry in entry.directory.entries:
                    resources.extend(self._get_resource_data(subentry))
            else:
                data = self.pe.get_data(
                    entry.data.struct.OffsetToData, entry.data.struct.Size
                )
                resources.append(data)
        except Exception as e:
            self.log.error(f"Failed to get resource data: {e}")
        return resources

    def _find_certificate_patterns(self, data: bytes) -> Optional[bytes]:
        """Find certificate patterns in binary data"""
        # PKCS#7 SignedData OID pattern
        PKCS7_PATTERN = b"\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x07\x02"

        try:
            idx = data.find(PKCS7_PATTERN)
            if idx != -1:
                # Search backwards for ASN.1 sequence marker
                for i in range(idx, max(0, idx - 50), -1):
                    if data[i] == 0x30:  # ASN.1 SEQUENCE
                        try:
                            # Try to parse as X.509 certificate
                            cert = x509.load_der_x509_certificate(
                                data[i:], default_backend()
                            )
                            return data[i:]
                        except Exception:
                            continue
        except Exception as e:
            self.log.error(f"Failed to find certificate patterns: {e}")
        return None

    def prepare_export_data(self, exporter_type: str) -> Any:
        self.log.debug(inspect.currentframe().f_code.co_name)
        if exporter_type == "ElasticsearchExporter":
            return self.findings
        elif exporter_type == "ClickHouseExporter":
            current_time = datetime.now(timezone.utc)
            
            data = [
                [
                    self.sha256,
                    self.md5,
                    self.sha1,
                    finding.context,
                    [asdict(cert) for cert in finding.finding] if finding.finding else None,
                    current_time
                ]
                for finding in self.findings
            ]
            
            column_names = [
                'sha256', 'md5', 'sha1', 'context', 'finding', 'analysis_date'
            ]
            
            if not data:
                return None

            column_type_names = [
                'FixedString(64)', 'FixedString(32)', 'FixedString(40)',
                'String', 'Array(JSON)', 'DateTime64(3, \'UTC\')'
            ]

            return (data, column_names, column_type_names)

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

    def extract(self):
        try:
            self.log.debug(inspect.currentframe().f_code.co_name)
            self._scan_for_certificates()
            if len(self.findings) > 0:
                return self.findings
            return None
        except Exception as e:
            self.log.error(f"Error extracting PE Extras: {e}")
            return None