Xiansheng Yang

37 papers A 1Journal 18Unranked 18
YearRankTypeTitle / Venue / Authors
2025 J jnl
IEEE Internet Things J.
Tianming Huang, Yuan Zhuang, Xiansheng Yang, Xiao Sun, Tengfei Yu, Xiaoxiang Cao
2025 conf
UPINLBS
Hao Zhang, Yuan Zhuang, Tianming Huang, Jiasheng Zhou, Xiansheng Yang
2025 J jnl
IEEE Trans. Mob. Comput.
Xiansheng Yang, Yuan Zhuang, Min Shi, Qian Meng, Jun Xiong, Yue Cao
2025 conf
UPINLBS
Tong Zou, Can Lv, Yuan Zhuang, Xiansheng Yang
2025 J jnl
IEEE Trans. Instrum. Meas.
Jiwei Huang, Yunjiang Lou, Xiaogang Xiong, Xiansheng Yang, Yanjie Li
2025 J jnl
Inf. Fusion
Xiansheng Yang, Hao Zhang, Yuan Zhuang, Yaxin Wang, Min Shi, Yuan Xu
2024 J jnl
IEEE Trans. Aerosp. Electron. Syst.
Xiaoxiang Cao, Yuan Zhuang, Guoliang Chen, Xuan Wang, Xiansheng Yang, Bingpeng Zhou
2024 J jnl
IEEE Internet Things J.
Xiaoxiang Cao, Yuan Zhuang, Xuan Wang, Kai Zhao, Xiansheng Yang
2024 conf
ICCA
Yixin Xie, Qiang Fu, Xiansheng Yang, Zhibin Li, YanJie Li, Yunjiang Lou
2024 J jnl
IEEE Trans. Mob. Comput.
Xiansheng Yang, Yuan Zhuang, Min Shi, Xiao Sun, Xiaoxiang Cao, Bingpeng Zhou
2024 J jnl
IEEE Trans. Neural Networks Learn. Syst.
Xiansheng Yang, Yuan Zhuang, Min Shi, Xiaoxiang Cao, Dong Chen, Yufei Tang
2024 J jnl
CoRR
Xiao Sun, Yuan Zhuang, Xiansheng Yang, Jianzhu Huai, Tianming Huang, Daquan Feng
2023 conf
ICCCS
Yujie Wei, Yuanpeng Zhang, Yaxin Wang, Xiansheng Yang, Yuan Zhuang
2023 J jnl
IEEE Trans. Instrum. Meas.
Xiaoxiang Cao, Xuan Wang, Guoliang Chen, Xiansheng Yang
2023 J jnl
IEEE Trans. Veh. Technol.
Xiansheng Yang, Yuan Zhuang, Fuqiang Gu, Min Shi, Xiaoxiang Cao, You Li, Bingpeng Zhou, Liang Chen
2023 J jnl
Inf. Fusion
Yuan Zhuang, Xiao Sun, You Li, Jianzhu Huai, Luchi Hua, Xiansheng Yang, Xiaoxiang Cao, Peng Zhang, Yue Cao, Longning Qi, Jun Yang, Nashwa El-Bendary, Naser El-Sheimy, John S. Thompson, Ruizhi Chen
2023 J jnl
IEEE Trans. Ind. Electron.
Xiansheng Yang, Xiaogang Xiong, Zhenyu Zou, Yunjiang Lou
2023 conf
CASE
Xiaogang Xiong, Zhenyu Zou, Yunjiang Lou, Xiansheng Yang, Xu Zhu, Fuchun Zheng
2023 J jnl
IEEE Internet Things J.
Xuan Wang, Yuan Zhuang, Zhenghua Zhang, Xiaoxiang Cao, Fen Qin, Xiansheng Yang, Xiao Sun, Min Shi, Zhe Wang
2022 conf
ICIRA (4)
Yilong Tan, Shuang Wu, Wanquan Liu, Xiansheng Yang, Hui-Jie Sun
2022 J jnl
IEEE Trans. Circuits Syst. II Express Briefs
Xiansheng Yang, Xiaogang Xiong, Zhenyu Zou, Yunjiang Lou, Shyam Kamal, Jiangang Li
2022 A conf
IROS
Ruikai Liu, Xiansheng Yang, Ajian Li, Yunjiang Lou
2022 conf
ICIRA (4)
Ying Qu, Xiansheng Yang, Yixin Xie, Yunjiang Lou
2022 conf
ICIRA (4)
Ruikai Liu, Ajian Li, Xiansheng Yang, Yunjiang Lou
2021 conf
RCAR
Yixin Xie, Nan Zhang, Xiansheng Yang, Yunjiang Lou
2021 conf
ICIRA (4)
Xiansheng Yang, Zhenyu Zou, Jinmin Zhang, Yunjiang Lou
2021 conf
RCAR
Nan Zhang, Yixin Xie, Xiansheng Yang, Haopeng Hu, Yunjiang Lou
2021 J jnl
IEEE Access
Sheng Jian, Xiansheng Yang, Xianwei Yuan, Yunjiang Lou, Yao Jiang, Genliang Chen, Guoyuan Liang
2021 J jnl
IEEE Access
Haopeng Hu, Zhiqi Cao, Xiansheng Yang, Hao Xiong, Yunjiang Lou
2021 conf
ICIRA (1)
Ajian Li, Ruikai Liu, Xiansheng Yang, Yunjiang Lou
2020 J jnl
IEEE Trans. Syst. Man Cybern. Syst.
Lei Jiang, Jujun Liu, Dong Zhou, Qian Zhou, Xiansheng Yang, Guanghui Yu
2019 conf
RCAR
Zichen Wang, Xiansheng Yang, Haopeng Hu, Yunjiang Lou
2019 conf
AIM
He Shen, Xiansheng Yang, Haopeng Hu, Qingzhi Mou, Yunjiang Lou
2019 conf
ROBIO
Qingzhi Mou, Xiansheng Yang, Han Zhang, Yunjiang Lou
2019 conf
ROBIO
Dengwei Dong, Xiansheng Yang, Haopeng Hu, Yunjiang Lou
2018 conf
ROBIO
Jingwen Tong, Yunjiang Lou, He Lyu, Yue Liu, Xiansheng Yang
2013 conf
ICIA
Yunjiang Lou, Xiansheng Yang, Ke Li, Xuechao Zhao
redb/extractors/macho_extractors/macho_similarity_hashes.py
← Index redb/extractors/macho_extractors/macho_similarity_hashes.py python
import inspect
from datetime import datetime, timezone
from typing import Any

from redb.extractors.enum import Tag
from redb.extractors.macho_extractor import MachOExtractor


class MachOSimilarityHashExtractor(MachOExtractor):
    """Extract Mach-O similarity hashes using machofile API.

    Similarity hashes are MD5 fingerprints of sorted, deduplicated binary components:
    - dylib_hash: MD5 of dynamic library names
    - import_hash: MD5 of imported function names
    - export_hash: MD5 of exported symbol names
    - entitlement_hash: MD5 of entitlement names and array values
    - symhash: MD5 of external undefined symbols

    For FAT binaries:
    - Inserts one row per architecture slice with per-slice hashes
    - Inserts one row for the FAT container with combined hashes

    For single-arch binaries:
    - Inserts one row with that architecture's hashes

    Note: parent_sha256 and architecture relationships are tracked in redb_basic_properties,
    not duplicated here. Use JOIN with redb_basic_properties when needed.
    """

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

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

    def _extract_similarity_hashes(self, arch_name=None):
        """Extract similarity hashes for a specific architecture."""
        self.log.debug(inspect.currentframe().f_code.co_name)

        if not self.macho:
            return None

        try:
            similarity_hashes = self.macho.get_similarity_hashes(arch=arch_name)
            return similarity_hashes if similarity_hashes else None
        except Exception as e:
            self.log.error(f"Error extracting similarity hashes for arch {arch_name}: {e}")
            return None

    def extract(self):
        self.log.debug(inspect.currentframe().f_code.co_name)
        try:
            if not self.macho:
                return None

            architectures = self.macho.get_architectures()
            if not architectures:
                return None

            if len(architectures) > 1:
                # FAT binary - return combined hashes + per-arch hashes
                results = []

                # First add combined hashes for the FAT container
                all_hashes = self.macho.get_similarity_hashes()
                combined_hashes = all_hashes.get('combined', {}) if all_hashes else {}
                if combined_hashes:
                    combined_hashes['arch_identifier'] = 'fat'
                    results.append(combined_hashes)

                # Then add per-arch hashes
                for arch_name in architectures:
                    hashes = self._extract_similarity_hashes(arch_name)
                    if hashes:
                        hashes['arch_identifier'] = arch_name
                        results.append(hashes)
                return results
            else:
                # Single architecture - return single result
                return self._extract_similarity_hashes(architectures[0])
        except Exception as e:
            self.log.error(f"Error extracting similarity hashes: {e}")
            return None

    def prepare_export_data(self, exporter_type: str) -> Any:
        if exporter_type == "ElasticsearchExporter":
            return self.extract()
        elif exporter_type == "ClickHouseExporter":
            if not self.macho:
                return None

            try:
                architectures = self.macho.get_architectures()
                is_fat = len(architectures) > 1
            except Exception as e:
                self.log.error(f"Could not get architectures: {e}")
                return None

            data = []
            current_time = datetime.now(timezone.utc)

            # For FAT binaries, first insert a row for the container with combined hashes
            if is_fat:
                all_hashes = self.macho.get_similarity_hashes()  # Without arch returns all including 'combined'
                combined_hashes = all_hashes.get('combined', {}) if all_hashes else {}
                if combined_hashes:
                    data.append([
                        self.sha256,                                    # sha256 (FAT container)
                        combined_hashes.get('dylib_hash'),              # dylib_hash
                        combined_hashes.get('import_hash'),             # import_hash
                        combined_hashes.get('export_hash'),             # export_hash
                        combined_hashes.get('entitlement_hash'),        # entitlement_hash
                        combined_hashes.get('symhash'),                 # symhash
                        current_time,                                   # analysis_date
                    ])

            # Insert rows for each architecture slice
            for arch_name in architectures:
                # Get architecture-specific sha256
                try:
                    arch_general_info = self.macho.get_general_info(arch=arch_name)
                    arch_sha256 = arch_general_info.get('SHA256', self.sha256)
                except Exception as e:
                    self.log.warning(f"Could not get arch-specific sha256 for {arch_name}: {e}")
                    arch_sha256 = self.sha256

                # Get similarity hashes for this architecture
                similarity_hashes = self._extract_similarity_hashes(arch_name)
                if not similarity_hashes:
                    continue

                data.append([
                    arch_sha256,                                    # sha256 (arch-specific)
                    similarity_hashes.get('dylib_hash'),            # dylib_hash
                    similarity_hashes.get('import_hash'),           # import_hash
                    similarity_hashes.get('export_hash'),           # export_hash
                    similarity_hashes.get('entitlement_hash'),      # entitlement_hash
                    similarity_hashes.get('symhash'),               # symhash
                    current_time,                                   # analysis_date
                ])

            if not data:
                return None

            column_names = [
                'sha256',
                'macho_dylib_hash', 'macho_import_hash', 'macho_export_hash',
                'macho_entitlement_hash', 'macho_symhash',
                'analysis_date'
            ]

            column_type_names = [
                'FixedString(64)',
                'Nullable(FixedString(32))', 'Nullable(FixedString(32))', 'Nullable(FixedString(32))',
                'Nullable(FixedString(32))', 'Nullable(FixedString(32))',
                'DateTime64(3, \'UTC\')'
            ]

            return (data, column_names, column_type_names)

        return None

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