Page 289 - 《软件学报》2025年第7期
P. 289
3210 软件学报 2025 年第 36 卷第 7 期
and call graph optimization. Firstly, API clustering is performed before malware detection to generate cluster centers that reflect API
functionality. To make clustering results more accurate, this study obtains embeddings fully reflecting the semantic similarity of APIs by
designing API sentences to summarize vital features such as API names and permissions and using NLP tools to mine the semantic
information of API sentences. Then, call graphs are extracted from apps and optimized by removing unknown methods while preserving
the connectivity among API nodes. Call graph optimization enables detection methods to extract more robust contextual information of
APIs which reflects the mode of app behavior. DroidSA extracts pairs of function calls from the optimized call graphs and abstracts the
APIs in the pairs into cluster centers obtained in API clustering to better adjust to the changes in Android frameworks and malware.
Finally, one-hot encoding is used to generate feature vectors, and the best-performing classifier is selected from random forests, support
vector machines, and the k-nearest neighbors algorithm for malware detection. Experimental results demonstrate that DroidSA achieves an
average F1-Measure of 96.7% for malware detection. Under the experimental setup where temporal bias is eliminated, DroidSA trained
with apps from 2012 to 2013 achieves an average F1-Measure of 82.6% when detecting malware developed from 2014 to 2018. Compared
with the state-of-the-art detection methods MaMaDroid and MalScan, DroidSA stably maintains high detection metrics with minimal
impact from temporal changes and effectively detects evolved malware.
Key words: malware detection; API semantics; model aging; function call graph; machine learning
安卓平台广泛普及的同时伴生了恶意软件的快速增长, 虽然机器学习方法在恶意软件检测领域取得了出色成
绩 [1−4] , 但持续进化的恶意软件仍给检测工作造成严重的困扰 [5,6] . 恶意软件开发者通过改变软件恶意行为的实现
方式以逃避现有的检测方法 [7] , 具体体现在新开发的恶意软件中存在大量旧恶意软件中未出现的 API, 这导致新
开发的恶意软件与旧恶意软件在特征分布上有着显著区别.
根据特征类型不同, 可将现有安卓恶意软件检测方法划分为基于 API 频率信息的检测方法和基于 API 上下
文信息的检测方法. 基于 API 频率信息的检测方法 [8−10] 漏报率高且鲁棒性差, 检测模型易受到恶意攻击. 基于 API
上下文信息的检测方法 [11,12] 能更准确识别软件的恶意行为, 但由于缺乏对函数调用图中大量未知函数的合适处理
方式, 难以有效提取 API 的上下文信息. 此外, 上述两类检测方法均未考虑软件中 API 的频繁变化, 导致使用旧软
件训练的分类器难以检测进化后的恶意软件 (观念迁移样本), 性能也随时间不断下降, 这种现象被称为模型老化.
API 聚类将功能相似的 API 归为一类, 在恶意软件检测阶段使用 API 聚类中心替换特征向量中的 API 能使
分类器有效识别训练时未出现的 API, 使检测方法适应安卓框架和恶意软件中 API 的变化. 现有 API 聚类方法从
包名、参数、返回值等特征中提取 API 语义信息, 忽略 API 的方法名和权限等关键特征, 难以全面提取 API 语义
信息, 导致聚类结果对分类器的性能提升有限. Mariconti 等人 [13] 提出一种构建恶意行为马尔可夫链的安卓恶意软
件检测方法 MaMaDroid, 根据包名对 API 进行聚类, 使检测方法能够识别现有包中出现的新 API. 但相同包中的
API 不一定都具有相同的功能, MaMaDroid 也无法识别新添加包中的 API. Pendlebury 等人 [5] 通过实验发现: 在消
除时间偏差的实验设置下, MaMaDroid 的 F1 值仅 3 个月后就从 90% 以上下降到 58%.
针对上述问题, 本文提出一种基于 API 聚类和调用图优化的安卓恶意软件检测方法 DroidSA (droid slow
aging). 首先, 在恶意软件检测之前进行 API 聚类, 生成概括 API 特征的 API 句子, 使用自然语言处理工具挖掘
API 句子的语义信息, 生成嵌入向量并进行聚类, 获得代表 API 功能的聚类中心. 然后, 从软件中提取函数调用图
并对调用图进行优化, 删除图中难以识别的未知函数, 同时保留 API 节点之间的连接性. 其次, 从优化后的调用图
中提取函数调用对并将调用对中 API 抽象为 API 聚类中心, 将其他函数抽象为包. 最后, 使用独热编码生成特征
向量并使用机器学习分类器进行恶意软件检测.
本文的主要贡献如下.
(1) 提出一种基于语义距离的 API 聚类方法. 通过设计 API 句子概括 API 的特征, API 句子不仅概括 API 的
方法名、权限等重要特征, 还能将特征数量不一致的 API 统一映射到固定大小的特征向量. 使用自然语言处理工
具对 API 句子中蕴含的丰富语义信息进行充分挖掘, 进而更全面地提取 API 语义信息, 使聚类结果更为准确.
(2) 提出一种调用图优化方法. 调用图优化方法删除函数调用图中难以识别的未知函数节点并保留 API 节点
之间的连接性. 调用图中任意两个 API 节点 (API X 和 API Y ) 之间若存在一条全部由未知函数节点组成的路径, 则
在优化后的调用图中 API X 直接调用 API Y . 调用图优化使检测方法能提取到更多更准确反映软件行为逻辑的 API
上下文信息.

