APP下载

基于Scrapy+LR分类器的暗链检测方法的设计与实现

2021-08-03张培

电脑知识与技术 2021年17期

张培

摘要:随着网页被植入暗链的网络安全事件不断增加,传统基于规则检测暗链的规则库覆盖不全面、低检出率等问题更加凸显。设计一种基于Scrapy和LR分类器的暗链检测方法,通过Scrapy爬取目标网页,利用分类器模型检测是否植入暗链,检测结果用来扩充数据集,迭代更新分类器模型。模型训练中利用网格搜索与交叉验证选择最优超参数,最优模型的f1分数达到0.956。此外随着数据集的扩充,测试集的暗链检测召回率及f1分数逐渐提高。

关键词:暗链;爬虫;Scrapy;LR分类器;sklearn

中图分类号:TP393.08      文献标识码:A

文章编号:1009-3044(2021)17-0236-03

开放科学(资源服务)标识码(OSID):

Design and Implementation for Hidden Hyperlink Detection Based on Scrapy and LR Classifier

ZHANG Pei

(Information Center, Jiangsu University, Zhenjiang 212023, China)

Abstract: With the increasing number of cybersecurity incidents in which hidden hyperlinks are implanted into websites, the problems such as incomplete coverage and low detection of the traditional rule-based detection method have become more prominent. Design of a method based on scrapy and LR classifier, crawl the target webpage through scrapy, which use the trained classifier model to detect whether hidden hyperlinks are implanted, the detection results are used to expand the dataset and iteratively update the classifier model. In model training, grid search and cross-validation are used to select the optimal hyperparameter, and the f1 score of the optimal model can reach 0.956. In addition, with the expansion of the data set, the detection recall rate and f1 score of the test set gradually improved.

Key words: hidden hyperlink; crawler; scrapy; LR classifier; sklearn

1 背景

国家互联网应急中心编写的《2019年中国互联网网络安全报告》中指出2019年我国境内被篡改的网站数量为185573个,其中暗链超过50%[1]。暗链是网页里一种隐藏的链接,常被黑帽用于提升SEO(搜索引擎优化)权重,技术上通常利用网站的漏洞或后门植入赌博彩票、淫秽色情、游戏私服、非法办证、虚假医疗等黑灰色非法产业的网站链接。网站被植入暗链会引起浏览器风险提示、搜索引擎惩罚、用户被欺骗等后果,甚至会被上级部门通报,很大程度上影响单位形象导致信誉受损。

面对网站被偷偷植入暗链的问题,通过定期网页爬虫主动发现并分析可有效减少暗链数目,避免不必要的损失。爬虫是一种可以自动、高效地抓取海量网页用来分析、挖掘的技术,市场上有多种优秀爬虫框架(如Scrapy)可供工作中使用[2-3]。通常我们可以借助规则库、关键字匹配等传统方法检测网页被植入暗链[4-5],但随着植入暗链的网页数量的日渐增多、植入手段更加丰富,传统方法存在的特征覆盖不全面、特征库无法及时更新、检出率低等问题更加凸显。……

登录APP查看全文