Zero-shot hidden link detection with large language models via chain-of-thought prompting
Online published: 2026-06-24
Copyright
Website hidden link detection faces significant challenges, as traditional methods often suffer from limited model generalization, heavy reliance on feature engineering, and poor interpretability of detection results. To better address these issues, this study proposes a zero-shot hidden link detection method driven by chain-of-thought prompting in large language models. By leveraging the strong natural language understanding and complex reasoning capabilities of large language models and chain-of-thought prompting strategies specifically designed for hidden link detection scenarios, the proposed method effectively enhances model generalization and innovatively provides interpretable outputs for detection results. Both subjective and objective metrics are employed to quantitatively evaluate the performance of the large language model and to verify the effectiveness of the prompting strategy in hidden link detection. The evaluation metrics include accuracy, precision, recall, and F1. Experimental results show that the proposed method achieves an F1 of 0.98, outperforming the baseline methods. This study provides an effective technical solution for hidden link detection in scenarios lacking high-quality datasets and further lays a foundation for the application of general-purpose large language models in cybersecurity detection tasks.
An Xiangxiang , Guo Lizhi , Zheng Xiaotong . Zero-shot hidden link detection with large language models via chain-of-thought prompting[J]. Journal of Cybersecurity, 2026 . DOI: 10.20172/j.issn.2097-3136.260531
表 1 基于DLD-CoT提示的网站暗链检测方法Table 1 Website Hidden Link Detection Method Based on DLD-CoT Prompting |
| 方法:基于DLD-CoT提示的网站暗链检测方法 |
| 输入:网页源码S; |
| 输出:检测结果E; |
| 1:对输入网页源码S进行预处理,得到规范化源码S_clean; |
| 2:构建任务指令I,明确当前任务为网页暗链检测; |
| 3:引入领域判断标准C; |
| 4:设计推理步骤R,引导模型按照既定流程逐步完成分析: |
| 从S中提取链接实体; |
| 分析链接的结构隐藏行为; |
| 评估链接文本与页面内容的语义相关性; |
| 判断目标域名的安全性; |
| 融合多维分析结果给出判定结果; |
| 5:定义输出格式O: |
| 检测结果 |
| 暗链定位 |
| 判定依据 |
| 风险评估及整改建议 |
| 6:DLD-CoT |
| 7:将DLD-CoT提示和S_clean输入大语言模型,得到检测结果E; |
| 8:输出最终检测结果。 |
表 2 数据集统计信息Table 2 Dataset statistics |
| 数据集来源 | 页面数量 | 含暗链页面 | 正常页面 | 收集日期 |
| 高校网站 | 261 | 132 | 129 | 2023/06-2025/10 |
| 电商网站 | 100 | 43 | 57 | 2024/03-2026/04 |
| 门户网站 | 100 | 52 | 48 | 2024/03-2026/04 |
| 公开数据集 | 259 | 125 | 134 | 2014/01-2017/01 |
| 合成样本 | 80 | 40 | 40 | - |
| 合计 | 800 | 392 | 408 | - |
表 3 推理参数设置Table 3 Inference Parameters |
| 参数名称 | 参数值 |
| Temperature | 0.0 |
| Top-p | 1.0 |
| Max tokens |
表 4 混淆矩阵Table 4 Confusion Matrix |
| 暗链页面 | 正常页面 | |
| 判定为暗链 | TP | FP |
| 判定为正常 | FN | TN |
表 5 暗链检测推理结构及结果Table 5 Reasoning Structure and Results of Hidden Link Detection |
| 推理路径 | 检测结果 | 结论 | |
| LLM | - | 上述代码创建了一个隐藏的链接,通常被称为“暗链”。JavaScript会在页面加载完成后执行,并在文档中添加一个指向http://js-hidden-link.net 的超链接。 | 检测结果正确,无明确判定依据 |
| Zero-Shot-CoT | - | 这段JavaScript用于在页面中添加一个用户看不见的超链接。这种做法符合“暗链”的定义:即隐藏起来不让普通访问者看到但仍然存在于网页代码中的外部链接。 | 检测结果正确,仅依据暗链单一特征判断 |
| Few-Shot-CoT | - | 这段代码用于植入暗链。利用document.createElement创建一个新的锚点元素,并将其添加到网页中;设置样式a.style.display = "none",将这个新创建的链接完全隐藏起来。 | 检测结果正确,推理过程受示例模式约束明显 |
| DLD-CoT | 1.结构隐藏 2.语义可疑 3.域名可疑 4.综合判定 | (1)暗链源码定位 这段代码通过JavaScript动态创建了一个隐藏链接<a href="http://js-hidden-link.net" style="display:none"> buy backlinks</a> (2)暗链信息提取 目标URL为js-hidden-link.net;通过JavaScript动态创建并设置display:none实现完全隐藏;锚文本与页面无任何关联;域名未指向任何可信服务。综合判定为典型的黑帽SEO暗链技术,属于高危暗链。 (3)整改建议 建议对网站所有动态生成的DOM节点进行安全审计;使用Web应用防火墙(WAF)拦截可疑的JavaScript操作。 | 检测结果正确,明确的三维判断依据且有固定输出形式 |
表 6 不同暗链类型下的检测性能Table 6 Detection performance across different hidden link types |
| 暗链类型 | 样本数量 | Accuracy | Precision | Recall | F1值 |
| CSS样式隐藏 | 103 | ||||
| HTML结构隐藏 | 115 | ||||
| JavaScript动态隐藏 | 112 | ||||
| 重定向与中转链路 | 95 | ||||
| 字符编码混淆 | 90 | ||||
| 主题差异度 | 97 | ||||
| 域名可疑 | 96 | ||||
| 复合隐藏结构 | 92 |
表 7 不同数据集来源的检测性能Table 7 Detection performance across different dataset sources |
| 数据集来源 | 样本数量 | Accuracy | Precision | Recall | F1值 |
| 高校网站 | 261 | ||||
| 电商网站 | 100 | ||||
| 门户网站 | 100 | ||||
| 公开数据集 | 259 | ||||
| 合成样本 | 80 |
表 8 误判类型分布统计Table 8 Statistical distribution of misclassification types |
| 误判类型 | 样本数量 | 占比(%) |
| 语义弱偏移 | 9 | 9.3 |
| 复合结构干扰 | 10 | 10.9 |
| 编码/跳转混淆 | 4 | 4.4 |
| 正常页面误判 | 8 | 2.0 |
表 9 可解释性评估结果Table 9 Explainability evaluation results |
| 方法 | 正确性 | 完整性 | 清晰性 | 综合评分 |
| DLD-COT | 4.32 | 4.15 | 4.47 | 4.31 |
| Zero-shot | 2.42 | 2.11 | 3.36 | 2.63 |
| Few-shot | 3.16 | 2.69 | 4.35 | 3.40 |
表 10 DLD-CoT在不同LLM上的检测性能Table 10 Detection performance of dld-cot on different large language models |
| 模型 | DLD-COT | Accuracy | Precision | Recall | F1值 |
| Qwen3-32B | 未使用 | ||||
| 使用 | |||||
| Qwen2.5-7B-Instruct | 未使用 | ||||
| 使用 | |||||
| DeepSeek-V3.2 | 未使用 | ||||
| 使用 |
表 11 DLD-CoT消融实验结果Table 11 Ablation study results of DLD-CoT |
| 消融设置 | Accuracy | Precision | Recall | F1值 |
| DLD-CoT | ||||
| DLD-CoT/I | ||||
| DLD-CoT/C | ||||
| DLD-CoT/R | ||||
| DLD-CoT/O |
表 12 不同方法的综合性能对比Table 12 Comprehensive performance comparison of different methods |
| 检测方法 | F1值 |
| 传统机器学习 | 0.82 |
| 深度学习 | 0.87 |
| LLM+DLD-CoT(本文方法) | 0.98 |
| 1 |
Geng G G , Yang X T , Wang W , et al. A taxonomy of hyperlink hiding techniques[J]. Lecture Notes in Computer Science, 2014: 165-176.
|
| 2 |
邢容. 基于文本识别技术的网页恶意代码检测方法研究[D]. 中国科学院大学, 2012.
Xing R. Research on web malicious code detection methods based on text recognition technology [D]. University of Chinese Academy of Sciences, 2012.
|
| 3 |
孟池洁, 王伟, 耿光刚. 基于统计机器学习的互联网暗链检测方法[J]. 计算机应用研究, 2015, 32 (9): 2779- 2781.
Meng, c J. , Wang W, Geng G G. Statistical machine learning-based method for internet hidden link detection[J]. Computer Applications Research, 2015, 32 (9): 2779- 2781.
|
| 4 |
周文怡, 顾徐波, 施勇, 等. 基于机器学习的网页暗链检测方法[J]. 计算机工程, 2018, 44(10): 23-25.
Zhou W Y, Gu X B, Shi Y, et al. Machine learning-based method for web hidden link detection. computer engineering, 2018, 44(10): 23-25.
|
| 5 |
孟雷. 多域识别构建监督学习模型检测网页暗链[J]. 信息安全与通信保密, 2019, (10): 64- 67.
Meng L. Multi-domain recognition for constructing supervised learning models to detect web hidden links[J]. Information Security And Communications Confidentiality, 2019, (10): 64- 67.
|
| 6 |
杨望, 江咏涵, 张三峰. 基于网页结构与语言特征的垃圾网页链接检测方法[J]. 东北大学学报: 自然科学版, 2020, 41 (8): 1091- 1096.
Yang W, Jiang Y H, Zhang S F. A web spam link detection method based on web page structure and text features[J]. Journal of Northeastern University Natural Science, 2020, 41 (8): 1091- 1096.
|
| 7 |
张紫妍, 韩斌, 姜元昊, 等. 融合差分进化的网页暗链集成分类检测方法[J]. 计算机仿真, 2024, 000(4): 6: 392-396.
Zhang Z Y, Han B, Jiang Y H, et al. Web hidden link detection via an ensemble classification method integrating differential evolution[J]. Computer Simulation, 2024, 000(4): 6: 392-396.
|
| 8 |
袁振. 基于图神经网络的暗链检测方法研究[D]. 南京: 东南大学, 2025.
Yuan Z. Research on hidden link detection method based on graph neural networks [D]. Nanjing: Southeast University, 2025.
|
| 9 |
王耀祖, 李擎, 戴张杰, 等. 大语言模型研究现状与趋势[J]. 工程科学学报, 2024, 46 (8): 1411- 1425.
Wang Y Z, Li Q, Dai Z J, et al. Current status and trends in large language modeling research[J]. Chinese Journal of Engineering, 2024, 46 (8): 1411- 1425.
|
| 10 |
Xu H, WANG S, LI N, et al. Large language models for cyber security: a systematic literature review[J]. ACM Transactions on Software Engineering and Methodology, 2025, 34 (4): 1- 34.
|
| 11 |
Uddin M, Irshad M S, Kandhro I A, et al. Generative AI revolution in cybersecurity: a comprehensive review of threat intelligence and operations[J]. Artificial Intelligence Review, 2025, 58 (8): 236.
|
| 12 |
宋泽楷, 刘锦浩, 郑雯, 等. 大语言模型驱动网络安全威胁检测: 进展与趋势[J]. 信息安全学报, 2025: 1.
Song Z K, Liu J H, Zheng W, et al. Large language models driving cyber security threat detection: progress and trends[J]. Journal of Cyber Security, 2025: 1.
|
| 13 |
张欣, 孙靖超. 基于大语言模型的虚假信息检测框架综述[J]. 计算机科学与探索, 2025, 19 (6): 1416- 1430.
Zhang X, Sun J C. A review of large language model-based frameworks for misinformation detection[J]. Journal of Frontiers of Computer Science & Technology, 2025, 19 (6): 1416- 1430.
|
| 14 |
Decusatis C, Tomo R, Singh A, Et Al. Cybersecurity applications of near-term large language models[J]. Electronics (2079-9292), 2025, 14(13): 3-12.
|
| 15 |
Yaacoub J P A, Noura H N, Salman O, et al. Large language models: applications, limitations, challenges, and recommendations in cybersecurity, digital forensics, and ethical hacking[J]. Annals of Telecommunications, 2025, 80 (11): 933- 973.
|
| 16 |
Bayer M, Kuehn P, Shanehsaz R, et al. Cysecbert: A domain-adapted language model for the cybersecurity domain[J]. ACM Transactions on Privacy and Security, 2024, 27 (2): 1- 20.
|
| 17 |
Bitaab M, Karimi A, Lyu Z, et al. ScamNet: Toward Explainable Large Language Model-Based Fraudulent Shopping Website Detection[C]//Proceedings of the AAAI Conference on Artificial Intelligence. 2025, 39(27): 27841-27848.
|
| 18 |
关永健, 朴乘锴, 王布宏, 等. LEAD-Cyber: 基于开源大模型和全周期本地微调的网络安全垂域大模型[J]. 网络空间安全科学学报, 2025, 3 (4): 94- 110.
Guan Y J, Piao C K, Wang B H, et al. LEAD-Cyber: a cybersecurity vertical domain LLM based on open source LLMs and full-cycle local fine-tuning[J]. Journal of Cybersecurity, 2025, 3 (4): 94- 110.
|
| 19 |
崔金满, 李冬梅, 田萱, 等. 提示学习研究综述[J]. Journal of Computer Engineering & Applications, 2024, 60 (23): 3- 18.
Cui J M, Li D M, Tian X, et al. A survey of prompt learning[J]. Journal of Computer Engineering & Applications, 2024, 60 (23): 3- 18.
|
| 20 |
Wei J, Wang X, Schuurmans D, et al. Chain-of-thought prompting elicits reasoning in large language models[J]. Advances in neural information processing systems, 2022, 35, 24824- 24837.
|
| 21 |
Fu Y, Peng H, Ou L, et al. Specializing smaller language models towards multi-step reasoning[C]//International Conference on Machine Learning. PMLR, 2023: 10421-10430.
|
| 22 |
Li L H, Hessel J, Yu Y, et al. Symbolic chain-of-thought distillation: Small models can also" think" step-by-step[J]. arXiv preprint arXiv: 2306.14050: 2023.
|
| 23 |
康睿哲. 基于思维链的通用语言模型推理能力研究[J]. 人工智能与机器人研究, 2025, 14 (2): 259- 267.
Kang R Z. Research on the reasoning ability of general language model based on chain of thought[J]. Artificial Intelligence and Robotics Research, 2025, 14 (2): 259- 267.
|
| 24 |
Kojima T, Gu S S, Reid M, et al. Large language models are zero-shot reasoners[EB/OL]. (2022-05-24)[2026-04-11]. https://arxiv.org/abs/2205.11916.
|
| 25 |
马冰琦, 周盈海, 王梓宇, 等. 一种基于大语言模型的威胁情报信息抽取方法[J]. 网络空间安全科学学报, 2024, 2 (2): 36- 46.
Ma B Q, Zhou Y H, Wang Z Y, et al. A LLMs-based method for threat intelligence information extraction[J]. Journal of Cybersecurity, 2024, 2 (2): 36- 46.
|
| 26 |
陶江垚, 奚雪峰, 盛胜利, 等. 结构化思维提示增强大语言模型推理能力综述[J]. Journal of Computer Engineering & Applications, 2025, 61(6).
Tao J Y, Xi X F, Sheng S L, et al. Review on Enhancing Reasoning Abilities of Large Language Model Through Structured Thinking Prompts[J]. Computer Engineering and Applications, 2025, 61(6): 64-83.
|
| 27 |
Chen Y, Chen X, HuANG Y, et al. COTVD: A function-level vulnerability detection framework using chain-of-thought reasoning with large language models[J]. Information and Software Technology, 2026, 108043, 2- 10.
|
| 28 |
林博, 王尚文, 毛晓光. 基于思维链的软件漏洞自动修复[J]. 软件学报, 2025, (3): 2207- 2216.
Lin B, Wang S W, Mao X G. Automated software vulnerability repair based on chain-of-thought[J]. Journal of Software, 2025, (3): 2207- 2216.
|
| 29 |
巴泽智, 张辉, 谢铮涵, 等. 大语言模型自动化提示工程技术研究综述[J]. 计算机科学与探索, 2025, 19 (12): 3131- 3152.
Ba Z Z, Zhang H, Xie Z H, et al. Automatic prompt engineering technology for large language models: a survey[J]. Journal of Frontiers of Computer Science and Technology, 2025, 19 (12): 3131- 3152.
|
| 30 |
Yang A, Li A, Yang B, et al. Qwen3 technical report[PP/OL]. arXiv, (2025-05-14)[2026-04-11]. https://arxiv.org/abs/2505.09388.
|
| 31 |
Yang A, Yang B, Zhang B C, et al. Qwen2.5 Technical Report[PP/OL]. arXiv, (2024-12-19)[2026-04-11]. https://arxiv.org/abs/2412.15115.
|
| 32 |
Liu A, Mei A, Lin B, et al. Deepseek-v3.2: Pushing the frontier of open large language models[PP/OL]. arXiv, (2025-12-02)[2026-04-11]. https://arxiv.org/abs/2512.02556.
|
/
| 〈 |
|
〉 |