A webpage tampering monitoring method, device, equipment and medium

By classifying webpage requests and invoking a deep learning model, the tampering behavior of static and dynamic webpages is identified, solving the problems of missed and false alarms in dynamic webpage monitoring in existing technologies, and realizing efficient and flexible webpage tampering monitoring.

CN119814351BActive Publication Date: 2025-11-04CHINA TELECOM CLOUD TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411706702.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-11-04
Estimated Expiration
2044-11-26

AI Technical Summary

Technical Problem

Existing webpage tampering detection technologies suffer from issues such as missed detections, false alarms, and vulnerability to cracking on dynamic webpages. They are also incompatible with detecting tampering behavior on both static and dynamic webpages. Furthermore, existing solutions are highly complex, costly, time-consuming, and resource-intensive.

Method used

By classifying web page requests, different monitoring methods are used for asynchronous AJAX requests and synchronous HTTP requests. Asynchronous requests identify data tampering in fields, while synchronous requests use deep learning models to monitor resource tampering. The deep learning model is combined to monitor tampering of different types of resources.

Benefits of technology

It improves the flexibility and efficiency of webpage tampering detection, reduces the false alarm rate, achieves compatible monitoring of both static and dynamic webpages, and has higher real-time performance and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814351B_ABST
    Figure CN119814351B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a webpage tampering monitoring method, device, equipment and medium. The method comprises: obtaining a response body returned by a Web service end to a browser and a webpage request corresponding to the response body; classifying the webpage request to determine the request category of the webpage request; for a first webpage request with an asynchronous AJAX request category, identifying a field data tampering behavior based on the response body corresponding to the first webpage request to obtain a first webpage tampering result; and for a second webpage request with a synchronous HTTP request category, calling a deep learning model to monitor tampering of different types of resources in the response body corresponding to the second webpage request to obtain a second webpage tampering result. Through the method of the embodiments of the present application, the tampering behavior monitoring scene of static and dynamic webpages can be compatible, and the flexibility and monitoring efficiency of webpage tampering monitoring can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of deep learning, and in particular to a webpage tampering monitoring method, device, equipment and medium. BACKGROUND

[0002] With the continuous development of Internet technology, many businesses and services are provided to users in the form of webpages. These webpages usually cover information of various industries, including data of important fields such as finance, medicine, e-commerce, etc. However, the widespread use of webpages has made them face more serious security problems. For example, using various means (such as controlling web servers, XSS attacks, etc.) to tamper with webpage information, to implement information theft and other behaviors, which has a bad impact on the reputation and interests of enterprises and institutions, and has brought serious security threats to users and related institutions.

[0003] Current mainstream static webpage tampering monitoring schemes include MD5 value verification, DOM (Document Object Model) tree comparison, etc. The MD5 algorithm is simple and fast, but has a numerical collision vulnerability, making it difficult to ensure the accuracy of detection. The DOM tree represents the structure and content of the webpage, and can accurately detect changes in specific elements and content from complex webpages. Since the page structure and content of dynamic webpages change greatly, the changes may be legitimate interactive behavior or tampering behavior, and it is difficult to detect tampering of dynamic webpages using the above mainstream schemes. For dynamic webpages, current related schemes mostly focus on using cryptography to protect the transmission process of dynamic data, such as encrypted transmission, digital certificates, etc. These technologies increase the complexity of the system, have high implementation and maintenance costs, and also have the risk of cryptography algorithm vulnerabilities being attacked. Some schemes use timed crawler technology to identify dynamic webpage data tampering, which has latency and resource consumption problems.

[0004] In summary, the current webpage tampering monitoring technology still has problems such as false negatives, false positives, and vulnerability to cracking, and a more efficient and accurate webpage anti-tampering method needs to be developed to compatible with static and dynamic webpage tampering behavior monitoring scenarios, which is of great significance to improve network security and user experience. SUMMARY

[0005] Embodiments of the present application provide a webpage tampering monitoring method, device, equipment and medium to overcome the limitations of traditional static verification methods on dynamic webpages, compatible with static and dynamic webpage tampering behavior monitoring scenarios, and improve the flexibility and monitoring efficiency of webpage tampering monitoring.

[0006] The first aspect of the embodiments of the present application provides a webpage tampering monitoring method, which comprises:

[0007] obtaining a response body returned by a Web service end to a browser and a webpage request corresponding to the response body;

[0008] classifying the webpage request to determine the request category of the webpage request;

[0009] for a first webpage request with an asynchronous AJAX request as the request category, identifying field data tampering behavior based on the response body corresponding to the first webpage request to obtain a first webpage tampering result;

[0010] for a second webpage request with a synchronous HTTP request as the request category, calling a deep learning model to monitor tampering of different types of resources in the response body corresponding to the second webpage request to obtain a second webpage tampering result.

[0011] The second aspect of the embodiments of the present application provides a webpage tampering monitoring device, which comprises:

[0012] a first obtaining module configured to obtain a response body returned by a Web service end to a browser and a webpage request corresponding to the response body;

[0013] a request classification module configured to classify the webpage request to determine the request category of the webpage request;

[0014] a first monitoring module configured to, for a first webpage request with an asynchronous AJAX request as the request category, identify field data tampering behavior based on the response body corresponding to the first webpage request to obtain a first webpage tampering result;

[0015] a second monitoring module configured to, for a first webpage request with an asynchronous AJAX request as the request category, based on the first webpage request, and for a second webpage request with a synchronous HTTP request as the request category, call a deep learning model to monitor tampering of different types of resources in the response body corresponding to the second webpage request to obtain a second webpage tampering result.

[0016] The third aspect of the embodiments of the present application provides an electronic device, which comprises a memory, a processor and a computer program stored in the memory and running on the processor, and the computer program is executed by the processor to implement the webpage tampering monitoring method of the first aspect of the embodiments of the present application.

[0017] The fourth aspect of the embodiment of the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is executed by a processor, the web page tampering monitoring method of the first aspect of the embodiment of the present application is implemented.

[0018] In the web page tampering monitoring method provided by the embodiment of the present application, first, the response body returned by the Web server to the browser and the web page request corresponding to the response body are obtained. Second, the web page request is classified to determine whether the request category of the web page request is an asynchronous AJAX request or a synchronous HTTP request. For the first web page request of the asynchronous AJAX request, that is, for the first web page request of the dynamic web page, the field data tampering behavior is identified based on the response body corresponding to the first web page request to obtain the first web page tampering result. For the second web page request of the synchronous HTTP request, that is, for the second web page request of the static web page, the tampering monitoring is performed on different types of resources in the response body corresponding to the second web page request by calling the deep learning model to obtain the second web page tampering result. In this way, by classifying the web page request, the embodiment determines whether the Web server receives the synchronous HTTP request for the static web page or the asynchronous AJAX request for the dynamic web page, selects different monitoring methods according to the determination result, and monitors the response body of the synchronous HTTP request by calling the trained deep learning model, thereby reducing the false positive rate of the traditional static checking method. The embodiment can overcome the limitations of the traditional static checking method on dynamic web pages, and is compatible with the monitoring scenarios of static web pages and dynamic web pages. Compared with the related scheme of determining dynamic web page value anomaly by using a timing crawler, the embodiment has the advantage of higher real-time performance, and improves the flexibility and monitoring efficiency of web page tampering monitoring. BRIEF DESCRIPTION OF DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0020] Figure 1 is a flowchart of a web page tampering monitoring method according to an embodiment of the present application;

[0021] Figure 2 is a network model structure diagram of a text monitoring model according to an embodiment of the present application;

[0022] Figure 3 is a whole system architecture diagram of a web page tampering monitoring system according to an embodiment of the present application;

[0023] Figure 4 is a structural block diagram of a webpage tampering monitoring device provided by an embodiment of the present application;

[0024] Figure 5 is a schematic diagram of an electronic device shown by an embodiment of the present application. DETAILED DESCRIPTION

[0025] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0026] Reference Figure 1 , Figure 1 is a flowchart of a webpage tampering monitoring method shown by an embodiment of the present application. As shown in Figure 1 , the webpage tampering monitoring method of the present embodiment can be applied to a cloud server. The webpage tampering monitoring method can include the following steps:

[0027] Step S11: obtaining a response body returned by a Web server to a browser and a webpage request corresponding to the response body.

[0028] When the browser requests a page from the Web server, the browser sends a webpage request to the Web server. The Web server generates a response body according to the webpage request and returns the response body to the browser. The browser parses the page according to the received response body and renders the page for the user to view. In this process, an attacker may tamper with these files to implement various forms of webpage attacks. Based on this, when the webpage tampering is monitored, the present embodiment can obtain the response body returned by the Web server to the browser and the webpage request corresponding to the response body.

[0029] In an optional implementation, the response body returned by the Web server to the browser in the present embodiment refers to the response body sent by the Web server to the browser and not received by the browser. The response body is returned to the browser after it is determined that the response body is not tampered with by the method, so as to avoid webpage tampering.

[0030] Step S12: classifying the webpage request and determining the request category of the webpage request.

[0031] In this embodiment, the response body corresponding to the web page request needs to be classified to determine the request category of the web page request. In this embodiment, the request category is divided into asynchronous AJAX request and synchronous HTTP request. The synchronous HTTP request is to obtain data by sending a complete page request, which updates the entire page and is a static web page request. The asynchronous AJAX request can exchange data with the server and update part of the web page content without affecting the display of the web page, which is a dynamic web page request.

[0032] In this embodiment, static web page refers to fixed content prepared in advance on the server, which does not have the characteristics of interactivity and real-time updating. The content is transmitted from the server to the browser when the user requests, and the user is shown a fixed page. Static web pages are usually composed of HTML, CSS and JavaScript static files, which do not change when the user accesses.

[0033] Dynamic web page refers to the generation of content by the server according to the user's demand when the user requests, and the generated result is returned to the user. Dynamic web pages usually contain database queries, user interaction, data processing and other dynamic operations, and can generate different content according to different user needs, with higher interactivity and real-time updating characteristics.

[0034] In an optional embodiment, the request category of the web page request sent by the browser received by the Web server can be divided into synchronous HTTP request and asynchronous AJAX request using Python script according to the different request header field parameters of the web page request. AJAX (Asynchronous JavaScript and XML) request: a technology for creating fast dynamic web pages, which can exchange data with the server in the background without reloading the entire page. Through AJAX technology, asynchronous data transmission can be realized, so that the web page can send a request to the server and receive a response without affecting the user's operation, thereby realizing real-time updating and more interactive interface.

[0035] Step S13: For the first web page request with the request category of asynchronous AJAX request, identify the field data tampering behavior based on the response body corresponding to the first web page request, and obtain the first web page tampering result.

[0036] The first web page request of the embodiment is a web page request of the request category of asynchronous AJAX request. For the first web page request of the request category of asynchronous AJAX request, tampering identification can be performed on the first web page request based on the response body corresponding to the first web page request, the field data tampering behavior of the response body corresponding to the first web page request is identified, and a first web page tampering result is obtained. The first web page tampering result is a web page tampering result of asynchronous AJAX request, that is, a web page tampering result of a dynamic web page.

[0037] Step S14: For the second web page request of the request category of synchronous HTTP request, a deep learning model is called to monitor tampering of different types of resources in the response body corresponding to the second web page request, and a second web page tampering result is obtained.

[0038] The second web page request of the embodiment is a web page request of the request category of synchronous HTTP request. For the second web page request of the request category of synchronous HTTP request, the embodiment can call a deep learning model to monitor tampering of different types of resources in the response body corresponding to the second web page request, and obtain a second web page tampering result. The second web page tampering result is a web page tampering result of synchronous HTTP request, that is, a web page tampering result of a static web page. The deep learning model is a pre-trained model for detecting tampering of different types of resources in the response body corresponding to the web page request of synchronous HTTP request, which can accurately identify the tampering result of the static web page.

[0039] In the embodiment, the cloud server classifies web page requests to determine whether the web server receives a synchronous HTTP request for a static web page or an asynchronous AJAX request for a dynamic web page. Different monitoring methods are selected according to the determination result. In this way, both dynamic web pages and static web pages can be monitored for tampering. By calling a trained deep learning model to monitor the response body of the synchronous HTTP request, the false positive rate of the traditional static verification method is reduced. The system's robustness and adaptability are improved by monitoring various methods used by attackers to tamper with web pages. The embodiment can overcome the limitations of traditional static verification methods on dynamic web pages and is compatible with static web page and dynamic web page monitoring scenarios. Compared with related solutions such as periodic crawler judgment of dynamic web page value anomaly, the embodiment has the advantage of higher real-time performance, improving the flexibility and efficiency of web page tampering monitoring.

[0040] In combination with the above embodiments, in an implementation, the embodiments of the present application further provide a webpage tampering monitoring method. Specifically, in the present embodiment, the different types of resources at least include different types of text resources; the deep learning model at least includes a text monitoring model corresponding to each type of text resource; and the "calling the deep learning model to perform tampering monitoring on the different types of resources in the response body corresponding to the second webpage request to obtain a second webpage tampering result" in the step S14 can specifically include steps S21-S24:

[0041] Step S21: extracting different types of current text resources from the response body corresponding to the second webpage request according to the tags and / or attributes of the response body.

[0042] In the present embodiment, the response body generally contains a status code, a response header, different types of current text resources, and some static resource files, etc. Different types of current text resources can be extracted from the response body corresponding to the second webpage request according to the tags and / or attributes of the response body. The current text resource is a text resource in the response body corresponding to the second webpage request to be identified. For example, using a Python script, in combination with specific tags and attributes of different types of response bodies, such as <script>、<link>、<style>、等,对Web服务器返回给浏览器的响应体进行不同内容的提取和拼接整合,得到响应体中不同类型的当前文本资源。

[0043] 步骤S22:获取所述第二网页请求的前一次第二网页请求对应的响应体中的不同类型的前一次文本资源。

[0044] 本实施例中,云端服务器会对Web服务器返回给浏览器每个响应体进行存储。在进行静态网页的篡改识别时,还需要获取第二网页请求的前一次第二网页请求对应的响应体中的不同类型的前一次文本资源。

[0045] 具体的,可以根据Web服务器的标识获取存储的该第二网页请求的前一次第二网页请求对应的响应体。其中,该前一次文本资源为待识别的第二网页请求的前一次第二网页请求对应的响应体中的文本资源。在获取到该第二网页请求的前一次第二网页请求对应的响应体中,可以通过上述步骤S21相同的方法,得到该第二网页请求的前一次第二网页请求对应的响应体中的不同类型的前一次文本资源。

[0046] 步骤S23:调用所述不同类型的文本资源各自对应的文本监测模型,对不同类型的当前文本资源和不同类型的前一次文本资源进行篡改监测,得到不同类型的文本资源各自对应的篡改结果。

[0047] 本实施例中,预先针对静态网页对应的响应体中的不同类型的文本资源,训练出不同类型的文本资源各自对应的文本监测模型,以用于对不同类型的文本资源进行篡改监测。

[0048] 本实施例可以调用不同类型的文本资源各自对应的文本监测模型,对不同类型的当前文本资源和不同类型的前一次文本资源进行篡改监测,得到不同类型的文本资源各自对应的篡改结果。

[0049] 在一可选实施方式中,不同类型的文本资源至少包括以下任一者:CSS样式文本、JavaScript脚本和HTML内容。例如,针对CSS样式文本,可以调用CSS样式文本对应的文本监测模型,对CSS样式文本的当前文本资源和CSS样式文本的前一次文本资源进行篡改监测,得到响应体中CSS样式文本对应的篡改结果。针对HTML内容,可以调用HTML内容对应的文本监测模型,对HTML内容的当前文本资源和HTML内容的前一次文本资源进行篡改监测,得到响应体中HTML内容对应的篡改结果。

[0050] 在一具体示例中,如下所示,左边为Web服务端正常响应的响应体,右边为被攻击者篡改后的响应体:

[0051]

[0052] 其中,如下所示,左边为服务端正常响应包括了一个指向"styles / main.css"的样式表文件,右边为将这个资源地址替换为恶意网站的https: / / evil.com / evil.css文件内容:

[0053]

[0054] 以及,如下所示,左边为服务端正常响应包括了一个指向"scripts / app.js"的JavaScript文件,右边为将这个资源地址替换为恶意网站的hhttps: / / evil.com / evil.js文件内容:

[0055]

[0056] 上述右边的响应均为将这两个资源地址替换为恶意网站的地址,还篡改了原始HTML文字内容,并在页面中插入了一个用于盗取用户信息的iframe元素,这些都是常见的网页遭受攻击者恶意篡改的情况。

[0057] 步骤S24:至少基于不同类型的文本资源各自对应的篡改结果,得到所述第二网页篡改结果。

[0058] 本实施例中,在得到不同类型的文本资源各自对应的篡改结果后,可以至少基于不同类型的文本资源各自对应的篡改结果,得到第二网页篡改结果。

[0059] 结合以上实施例,在一种实施方式中,本发明实施例还提供了一种网页篡改监测方法。具体地,在该方法中,上述步骤S23具体可以包括步骤S31至步骤S35:

[0060] 步骤S31:分别将不同类型的当前文本资源和不同类型的前一次文本资源输入不同类型的文本资源各自对应的文本监测模型。

[0061] 本实施例中,可以先分别将不同类型的当前文本资源和不同类型的前一次文本资源,输入不同类型的文本资源各自对应的文本监测模型。例如,针对CSS样式文本的文本资源,是将CSS样式文本的当前文本资源和CSS样式文本的前一次文本资源输入CSS样式文本对应的文本监测模型;针对HTML内容的文本资源,是将HTML内容的当前文本资源和HTML内容的前一次文本资源输入HTML内容对应的文本监测模型。

[0062] 其中,不同类型的文本资源各自对应的文本监测模型是分别基于正常响应的响应体中不同类型的文本资源和篡改后的响应体中不同类型的文本资源训练得到的。例如,HTML内容对应的文本监测模型是基于正常响应的响应体中HTML内容和篡改后的响应体中的HTML内容训练得到的,JavaScript脚本对应的文本监测模型是基于正常响应的响应体中JavaScript脚本和篡改后的响应体中的JavaScript脚本训练得到的,CSS样式文本对应的文本监测模型是基于正常响应的响应体中CSS样式文本和篡改后的响应体中的CSS样式文本训练得到的。

[0063] 本实施例中,不同类型的文本资源各自对应的文本监测模型的模型结构均相同,该文本监测模型至少包括:第一卷积池化层、第二卷积池化层、全连接层、sigmoid层和二分类器。

[0064] 在一优选实施例中,采用深度学习中的文本分类和序列建模技术,选择TextCNN作为第一卷积池化层和第二卷积池化层,其中,TextCNN是一种适用于文本分类任务的深度学习模型,其利用卷积神经网络在文本序列上进行卷积操作,并结合最大池化操作,有效捕捉文本中的局部特征和全局特征,进而确定文本类型。相比于其他复杂的深度学习模型,该模型在结构上相对简单,训练和推断效率较高。

[0065] 步骤S32:通过所述不同类型的文本资源各自对应的文本监测模型,分别对不同类型的当前文本资源和不同类型的前一次文本资源进行文本向量化,得到当前文本资源对应的第一数值向量和前一次文本资源对应的第二数值向量。

[0066] 本实施例中,在不同类型的文本资源各自对应的文本监测模型中,首先需要对不同类型的当前文本资源进行文本向量化,得到当前文本资源对应的第一数值向量,以及,对不同类型的前一次文本资源进行文本向量化,得到前一次文本资源对应的第二数值向量。

[0067] 在一实施例中,在文本向量化中,是使用词嵌入技术,如Word2Vec或者GloVe,将文本数据投影到一个低维稠密空间中的向量表示。这些词嵌入技术能够帮助模型更好地理解文本数据的语义和结构信息,将文本内容转换成数值向量,以便后续处理和学习,提高模型的准确性和泛化能力。

[0068] 步骤S33:通过所述第一卷积池化层对所述第一数值向量进行特征提取和压缩整合,得到第一特征信息;通过所述第二卷积池化层对第二数值向量进行特征提取和压缩整合,得到第二特征信息。

[0069] 本实施例中,得到第一数值向量和第二数值向量后,可以通过第一卷积池化层对第一数值向量进行特征提取和压缩整合,得到第一特征信息;以及,通过第二卷积池化层对第二数值向量进行特征提取和压缩整合,得到第二特征信息。其中,第一卷积池化层和第二卷积池化层共享权重,第一卷积池化层和第二卷积池化层均分别包括卷积层和池化层,使用共享权重的卷积层和池化层对两个文本的数值向量进行特征提取,其中,卷积层可以捕捉文本中的局部特征,而池化层则用于压缩和整合特征信息。

[0070] 步骤S34:对所述第一特征信息和所述第二特征信息进行特征融合,得到融合特征。

[0071] 本实施例中,还需要将第一特征信息和第二特征信息进行特征融合,得到融合特征。具体的融合方式可能涉及向量拼接、相加或其他方式,以便将两个文本的特征信息结合起来。

[0072] 步骤S35:将所述融合特征依次输入所述全连接层、所述sigmoid层和所述二分类器,得到篡改结果。

[0073] 本实施例中,得到融合特征后,将融合特征依次输入全连接层、sigmoid层和二分类器,通过全连接层学习更高级的特征表示,最终使用二分类器进行判断,判断这两个文本是否发生了篡改,得到文本监测模型输出的篡改结果。

[0074] 本实施例提出的文本监测模型的网络结构借鉴了孪生网络的权重共享思路。孪生网络由两个共享权重的子网络组成,对两个输入之间的相似度或差异进行建模,通过距离度量函数来计算相似度或差异。本实施例不采用距离度量函数计算两个输入之间的相似度,而是将两个特征进行拼接,在经过全连接层和sigmoid层判断两个特征是否发生篡改行为。这种结构更侧重于对不同信息的组合和分类,而不是对两个输入之间的相似度进行建模。

[0075] 可以理解的是,针对每个类型的文本资源各自对应的文本监测模型均是通过上述步骤S31-步骤S35进行模型预测处理,从而得到每个类型的文本资源各自对应的篡改结果。

[0076] 如图2所示,图2是本发明一实施例示出的一种文本监测模型的网络模型结构示意图。通过本实施例的文本监测模型可以对Web服务端响应的响应体中不同类型文本进行编码,能够有效捕捉文本中的局部信息和语义特征。其中。该文本监测模型的网络结构设计如下:

[0077] A、输入层:接收两个文本样本(即前一次响应的XXX内容和后一次响应的XXX内容),这里是前后两次第二网页请求返回响应的不同类型的文本资源:JavaScript脚本内容 / HTML内容 / CSS样式内容。

[0078] B、文本向量化:使用词嵌入技术,如Word2Vec或者GloVe,将文本数据投影到一个低维稠密空间中的向量表示。这些词嵌入技术能够帮助模型更好地理解文本数据的语义和结构信息,将文本内容转换成数值向量,以便后续处理和学习,提高模型的准确性和泛化能力。

[0079] C、共享权重的TextCNN卷积层和池化层:使用共享权重的卷积层和池化层(即第一卷积池化层和第二卷积池化层)对两个文本进行特征提取。卷积层可以捕捉文本中的局部特征,而池化层则用于压缩和整合特征信息。

[0080] D、特征融合(concat):将两个文本的特征向量进行融合,具体的融合方式可能涉及向量拼接、相加或其他方式,以便将两个文本的特征信息结合起来。

[0081] E、全连接层和二分类器:将融合后的特征输入到全连接层和二分类器中,通过全连接层学习更高级的特征表示,最终使用二分类器进行判断,判断这两个文本是否发生了篡改。

[0082] 本实施例将前后两次响应的文本同时输入到设计好的模型进行推理,而不是仅依据单次响应的DOM树去判断网页是否被篡改,所发明的深度学习模型更适用于篡改监测场景。

[0083] 此外,在一实施例中,针对文本监测模型的训练可以包括以下步骤:

[0084] 首先,进行数据准备:收集大量网页的服务器正常响应和篡改后的响应体,进行文本提取和同类型文本拼接,拆分出不同类型的文本资源(CSS样式和JavaScript脚本、HTML内容),作为前后内容非空的成对输入样本。

[0085] B、还有一种数据是empty-flag文本和危险文本,作为前后内容有异者的成对输入样本。

[0086] C、对采集的数据进行清洗、特征提取和标注,以供深度学习模型训练使用。

[0087] 其次,进行模型训练和调优:使用上述结构的深度学习模型对训练集进行训练,以学习网页篡改的特征表示和分类能力。在训练过程中,网络会不断优化特征表示和分类器模型,以使得最终的二分类结果能够准确地反映文本的改变情况。通过反复调整模型结构和参数,优化模型在篡改监测任务上的性能。

[0088] 最后,模型应用:将成对的请求对应的响应数据送入训练好的文本监测模型中,包括JavaScript脚本内容、HTML内容、CSS样式内容等,并确保数据经过预处理和编码以符合模型输入要求。利用训练好的深度学习模型进行推理,模型会对输入的请求和响应数据进行分析和判断,输出一个二分类结果,指示是否发生了篡改。

[0089] 结合以上实施例,在另一种实施方式中,本发明实施例还提供了一种网页篡改监测方法。具体地,在本实施例中,所述不同类型的资源还包括:静态图片资源;所述深度学习模型还包括:静态资源图片监测模型;除上述步骤外,还可以包括步骤S41至步骤S43,以及,上述步骤S24具体可以包括步骤S44:

[0090] 步骤S41:针对所述请求类别为同步HTTP请求的第二网页请求,从所述第二网页请求对应的响应体中提取出当前静态图片资源。

[0091] 本实施例中,可以针对请求类别为同步HTTP请求的第二网页请求,从第二网页请求对应的响应体中提取出当前静态图片资源。该当前静态图片资源为待识别的第二网页请求对应的响应体中的静态图片资源。

[0092] 步骤S42:获取所述第二网页请求的前一次第二网页请求对应的响应体中的前一次静态图片资源。

[0093] 本实施例中,在进行静态网页的篡改识别时,还需要获取第二网页请求的前一次第二网页请求对应的响应体中的前一次静态图片资源。具体的,可以根据Web服务器的标识获取存储的该第二网页请求的前一次第二网页请求对应的响应体,从而得到前一次静态图片资源。其中,该前一次静态图片资源为待识别的第二网页请求的前一次第二网页请求对应的响应体中的静态图片资源。

[0094] 在一具体示例中,攻击者还可能对静态网页放回的静态图片资源的地址进行篡改,或对同一个地址下的图片内容进行篡改。如下所示,左边为篡改图片地址前的响应体内容,右边为篡改图片地址后的响应体内容,这些篡改行为都在极大程度上影响了网站的安全性和可信度:

[0095]

[0096] 步骤S43:调用所述静态资源图片监测模型,对所述当前静态图片资源和所述前一次静态图片资源进行篡改监测,得到静态图片资源对应的篡改结果。

[0097] 本实施例中,预先针对静态网页对应的静态图片资源,训练出静态资源图片监测模型,以用于对静态图片资源进行篡改监测。本实施例可以调用静态资源图片监测模型,对获取到的当前静态图片资源和前一次静态图片资源进行篡改监测,得到静态图片资源对应的篡改结果。

[0098] 步骤S44:基于不同类型的文本资源各自对应的篡改结果,和,所述静态图片资源对应的篡改结果,得到所述第二网页篡改结果。

[0099] 本实施例中,可以基于不同类型的文本资源各自对应的篡改结果,和,静态图片资源对应的篡改结果,得到第二网页篡改结果。

[0100] 结合以上实施例,在另一种实施方式中,本发明实施例还提供了一种网页篡改监测方法。在本实施例中,上述步骤S43具体可以包括步骤S51至步骤S54:

[0101] 步骤S51:分别将所述当前静态图片资源和所述前一次静态图片资源输入所述静态资源图片监测模型。

[0102] 本实施例中,静态资源图片监测模型是基于正常响应的响应体中的静态图片资源和篡改后的响应体中的静态图片资源训练得到的;该静态资源图片监测模型至少包括:第三卷积池化层、第四卷积池化层、全连接层、sigmoid层和二分类器;所述第三卷积池化层和所述第四卷积池化层共享权重。其中,本实施例的第三卷积池化层、第四卷积池化层与第一卷积池化层、第二卷积池化层不同,本实施例使用普通的卷积神经网络作为第三卷积池化层、第四卷积池化层进行特征编码,用于抽取图像的空间特征和纹理信息。

[0103] 本实施例中,可以先分别获取到的当前静态图片资源和前一次静态图片资源,输入静态资源图片监测模型中。

[0104] 步骤S52:通过所述第三卷积池化层对所述当前静态图片资源进行特征提取,得到第一图像特征信息;通过所述第四卷积池化层对所述前一次静态图片资源进行特征提取,得到第二图像特征信息。

[0105] 本实施例中,静态资源图片监测模型中不再进行文本向量化,直接通过第三卷积池化层对当前静态图片资源进行特征提取,得到第一图像特征信息;以及通过第四卷积池化层对前一次静态图片资源进行特征提取,得到第二图像特征信息。

[0106] 步骤S53:对所述第一图像特征信息和所述第二图像特征信息进行特征融合,得到图像融合特征。

[0107] 本实施例中,还需要将第一图像特征信息和第二图像特征信息进行特征融合,得到图像融合特征。

[0108] 步骤S54:将所述图像融合特征依次输入所述全连接层、所述sigmoid层和所述二分类器,得到所述静态图片资源对应的篡改结果。

[0109] 本实施例中,得到图像融合特征后,将图像融合特征依次输入全连接层、sigmoid层和二分类器,通过全连接层学习更高级的特征表示,最终使用二分类器进行判断,判断这两个图像是否发生了篡改,得到静态资源图片监测模型输出的该静态图片资源对应的篡改结果。其中,静态资源图片监测模型的训练过程与文本监测模型的训练过程相似,均是通过数据准备、模型训练和调优完成。

[0110] 结合以上实施例,在一种实施方式中,本发明实施例还提供了一种网页篡改监测方法。具体地,在本实施例中,针对请求类别为同步HTTP请求的第二网页请求,在上述步骤S14之前,还可以包括步骤S61,以及,上述步骤S14具体可以包括步骤S62:

[0111] 步骤S61:确定所述第二网页请求对应的响应体中不同类型的资源,和,所述第二网页请求的前一次第二网页请求所对应的响应体中不同类型的资源是否都为空。

[0112] 本实施例中,需要确定第二网页请求对应的响应体中不同类型的资源,和,该第二网页请求的前一次第二网页请求所对应的响应体中不同类型的资源是否都为空。例如,不同类型的资源可以包括:CSS样式文本、JavaScript脚本、HTML内容和静态图片资源。其中,针对CSS样式文本、JavaScript脚本、HTML内容可以确定是否前后两次都为空,针对静态图片资源,可以确定前后两次是否包含相同地址的图片。

[0113] 步骤S62:在所述第二网页请求对应的响应体中不同类型的资源,和,所述第二网页请求的前一次第二网页请求所对应的响应体中不同类型的资源不都为空的情况下,调用深度学习模型对所述第二网页请求对应的响应体中不同类型的资源进行篡改监测,得到第二网页篡改结果。

[0114] 本实施例中,在确定第二网页请求对应的响应体中不同类型的资源,和,第二网页请求的前一次第二网页请求所对应的响应体中不同类型的资源不都为空的情况下,即:在第二网页请求对应的响应体中不同类型的资源,和,第二网页请求的前一次第二网页请求所对应的响应体中不同类型的资源均不为空,或,第二网页请求对应的响应体中不同类型的资源,和,第二网页请求的前一次第二网页请求所对应的响应体中不同类型的资源一者为空一者不为空的情况下,才调用深度学习模型对第二网页请求对应的响应体中不同类型的资源进行篡改监测,得到第二网页篡改结果。其中,针对一者为空一者不为空,将为空的文本内容更新为empty-flag,和另一个非空文本内容一起输入到深度学习模型中。此外,在两者都为空的情况下,则不需要调用对应的深度学习模型。

[0115] 针对静态图片资源,对比出前后两次请求是否包含相同地址的图片。如果有,就将其一起输入到静态资源图片监测模型,判断图片内容是否发生篡改。如果没有,则不做处理。

[0116] 结合以上实施例,在一种实施方式中,本发明实施例还提供了一种网页篡改监测方法。具体地,在该方法中,所述不同类型的文本资源至少包括以下任一者:CSS样式文本、JavaScript脚本和HTML内容;除上述步骤外,还可以包括步骤S71至步骤S74,以及,上述步骤S21中的"从所述第二网页请求对应的响应体中提取出不同类型的当前文本资源”具体包括步骤S75,上述步骤S22具体可以包括步骤S76:

[0117] 步骤S71:针对所述请求类别为同步HTTP请求的第二网页请求,将所述第二网页请求对应的响应体存入第一存储模块的s3对象存储服务器;

[0118] 步骤S72:从所述第一存储模块中获取所述第二网页请求对应的响应体;

[0119] 步骤S73:按照所述第二网页请求对应的响应体的标签和 / 或属性,从所述第二网页请求对应的响应体中提取出CSS样式文本、JavaScript脚本和HTML内容;

[0120] 步骤S74:将所述第二网页请求的网页地址、所述第二网页请求对应的响应体在s3对象存储服务器中的URL、所述CSS样式文本、所述JavaScript脚本、所述HTML内容、第一创建时间和第一更新时间存储在所述第一存储模块的mysql数据库的文本表中。

[0121] 本实施例中,可以针对请求类别为同步HTTP请求的第二网页请求,云端服务器在每接收到一个第二网页请求,均会将该第二网页请求对应的响应体存入第一存储模块的s3对象存储服务器。然后在进行网页篡改监测时,从第一存储模块中获取该第二网页请求对应的响应体,并按照该第二网页请求对应的响应体的标签和 / 或属性,从第二网页请求对应的响应体中提取出CSS样式文本、JavaScript脚本和HTML内容,从而将该第二网页请求的网页地址、该第二网页请求对应的响应体在s3对象存储服务器中的URL、第二网页请求对应的响应体中的CSS样式文本、JavaScript脚本、HTML内容、第一创建时间和第一更新时间存储在第一存储模块的mysql数据库的文本表中。在一示例中,文本表可以为ResponseBody表,该表结构的字段包含id(唯一标识)、page_url(网页地址)、source_content(原始响应体内容)、html_content(HTML内容)、css_styles(CSS样式)、js_scripts(JavaScript脚本)、seq_num(递增的请求序号)、created_time(创建时间戳)、updated_time(更新时间戳)。编写SQL脚本,指定不同字段的特定类型,进行文本表的构建。

[0122] 步骤S75:从所述文本表中拉取所述第二网页请求对应的响应体中的当前CSS样式文本、当前JavaScript脚本和当前HTML内容。

[0123] 本实施例中,是从事先存储的文本表中,依据第二网页请求的标识拉取第二网页请求对应的响应体中的当前CSS样式文本、当前JavaScript脚本和当前HTML内容。

[0124] 步骤S76:从所述文本表中拉取所述第二网页请求的前一次第二网页请求对应的响应体中的前一次CSS样式文本、前一次JavaScript脚本和前一次HTML内容。

[0125] 本实施例中,相似的,针对第二网页请求的前一次第二网页请求,可以从事先存储的文本表中,依据第二网页请求的前一次第二网页请求的标识,拉取第二网页请求的前一次第二网页请求对应的响应体中的前一次CSS样式文本、前一次JavaScript脚本和前一次HTML内容。

[0126] 结合以上实施例,在一种实施方式中,本发明实施例还提供了一种网页篡改监测方法。具体地,在该方法中,除上述步骤外,还可以包括步骤S81至步骤S82,以及,上述步骤S41具体包括步骤S83和步骤S84,上述步骤S42具体包括步骤S85和步骤S86:

[0127] 步骤S81:针对所述请求类别为同步HTTP请求的第二网页请求,将所述第二网页请求对应的响应体中的静态图片资源存入所述第一存储模块的s3对象存储服务器;

[0128] 步骤S82:将所述第二网页请求的网页地址、所述第二网页请求对应的文本表的标识、所述静态图片资源的原始地址、所述静态图片资源在s3对象存储服务器中的URL、第二创建时间和第二更新时间存储在所述第一存储模块的mysql数据库的图像表中;

[0129] 本实施例中,可以针对请求类别为同步HTTP请求的第二网页请求,云端服务器在每接收到一个第二网页请求,若该第二网页请求中包含静态图片资源,这会将第二网页请求对应的响应体中的静态图片资源存入第一存储模块的s3对象存储服务器。然后将该第二网页请求的网页地址、第二网页请求对应的文本表的标识、静态图片资源的原始地址、静态图片资源在s3对象存储服务器中的URL、第二创建时间和第二更新时间存储在第一存储模块的mysql数据库的图像表中。在一示例中,图像表可以为ImageResource表,该表结构的字段包含id(唯一标识)、main_id(对应ResponseBody表的id)、source_image_path(原始响应体中的静态图片地址)、image_url(图片在对象存储服务中的URL)、created_time(创建时间戳)、updated_time(更新时间戳)。编写SQL脚本,指定不同字段的特定类型,进行图像表的构建。

[0130] 步骤S83:从所述图像表中拉取所述第二网页请求对应的响应体中的当前静态图片资源的原始地址和当前静态图片资源在s3对象存储服务器中的URL;

[0131] 步骤S84:基于所述当前静态图片资源在s3对象存储服务器中的URL,从所述s3对象存储服务器中读取所述当前静态图片资源。

[0132] 本实施例中,可以从所述图像表中,依据第二网页请求的标识拉取第二网页请求对应的响应体中的当前静态图片资源的原始地址和当前静态图片资源在s3对象存储服务器中的URL。然后,基于拉取到的当前静态图片资源在s3对象存储服务器中的URL,从s3对象存储服务器中读取当前静态图片资源。

[0133] 步骤S85:从所述图像表中拉取所述第二网页请求的前一次第二网页请求对应的响应体中的前一次静态图片资源的原始地址和前一次静态图片资源在s3对象存储服务器中的URL;

[0134] 步骤S86:基于所述前一次静态图片资源在s3对象存储服务器中的URL,从所述s3对象存储服务器中读取所述前一次静态图片资源。

[0135] 本实施例中,还需要依据第二网页请求的前一次第二网页请求的标识,从图像表中拉取第二网页请求的前一次第二网页请求对应的响应体中的前一次静态图片资源的原始地址和前一次静态图片资源在s3对象存储服务器中的URL;从而依据前一次静态图片资源在s3对象存储服务器中的URL,从s3对象存储服务器中读取所述前一次静态图片资源。

[0136] 本实施例中,将Web服务端响应的响应体和静态图片资源上传到s3服务,该服务适合存储大容量的静态资源文件,具有高度的可靠性和持久性。通过这种方式,可以减少数据库存储的实际内容大小,降低数据库负担。

[0137] 结合以上实施例,在一种实施方式中,本发明实施例还提供了一种网页篡改监测方法。具体地,在该方法中,上述步骤S13中的"基于所述第一网页请求对应的响应体,识别字段数据篡改行为,得到第一网页篡改结果”具体可以包括步骤S91至S94:

[0138] 步骤S91:从所述第一网页请求对应的响应体中提取出特定字段信息;

[0139] 步骤S92:对所述特定字段信息进行数据乱码检测,得到乱码检测结果;

[0140] 步骤S93:对所述特定字段信息进行数值范围异常检测,得到范围异常检测结果;

[0141] 步骤S94:基于所述乱码检测结果和所述范围异常检测结果,得到所述第一网页篡改结果。

[0142] 在一具体示例中,假设在一个电子商务网站上,在用户打开特定商品详情页面时,页面需要刷新获取最新的商品信息,使用jQuery库中的$.ajax()函数来发起一个GET请求。该请求旨在从服务器端获取商品信息,成功获取后更新页面上的商品信息显示,如果请求失败则在控制台输出错误信息。如下所示,为异步AJAX请求的案例:

[0143]

[0144] 其中,以下为上述异步AJAX请求的案例对应的请求内容:

[0145] GET / getProductInfo HTTP / 1.1

[0146] Host:yourwebsite.com

[0147] User-Agent:Mozilla / 5.0(windowsNT10.0;win64;x64)ApplewebKit / 537.36(KHTML,like Gecko)Chrome / 58.0.3029.110 Safari / 537.36

[0148] Accept:* / *

[0149] Accept-Language:en-US,en;q=0.5

[0150] Accept-Encoding:gzip,deflate

[0151] X-requested-with:XMLHttpRequest

[0152] Connection:keep-alive

[0153] 以下为上述异步AJAX请求的案例对应的响应内容:

[0154]

[0155] 由于当前较为流行的异步AJAX请求的响应体是json格式的数据,因此,本实施例中,需要对第一网页请求对应的响应体进行分析,从第一网页请求对应的响应体中提取出特定字段信息,如不同字段的数值。如编写Python脚本,对异步AJAX请求的响应体进行解析,无论是JSON格式还是其他格式,确保能够正确提取需要监测的字段信息。然后对特定字段信息进行数据乱码检测,得到乱码检测结果,例如使用正则表达式或专门的乱码检测工具进行判断,同时,对于数值型数据,验证数据类型和范围是否符合预期。以及,对特定字段信息进行数值范围异常检测,得到范围异常检测结果,例如,利用相关的机器学习或异常检测算法监测字段的数值变化情况,常见的算法包括孤立森林、局部离群因子等,这些算法可以帮助检测数据的异常情况。最后,基于乱码检测结果和范围异常检测结果,得到第一网页篡改结果。示例的,可以是结合上述两项检测结果,得出异步AJAX请求的响应的数值是否存在篡改风险,如果存在篡改,可以将篡改的前后数据记录在数据库中,以备后续分析和追溯。

[0156] 在一可选实施例中,本实施例的应用场景包括但不限于企业等相关机构,可以广泛应用于网络安全、金融、电子商务和新闻媒体等领域,确保网站数据的完整性和信息传递的可信度。

[0157] 例如:1、网络安全领域:监测和检测网站页面被攻击者篡改的行为,保护网站数据的完整性。

[0158] 2.金融机构:监测网页是否被篡改,防止恶意攻击者篡改网页内容,保护用户信息安全。

[0159] 3.电子商务平台:监测网页内容的完整性,防止篡改行为对商家和消费者造成影响。

[0160] 4.新闻媒体机构:确保其网站上发布的新闻和信息未被篡改,提高信息传递的可信度。

[0161] 通过本实施例的方法,不仅能对数据完整性验证:该技术可以被用于验证数据完整性,例如在区块链、数据存储和传输领域,确保数据未被篡改或损坏;还可以进行知识产权保护:在知识产权保护方面,该技术可以用于监测和保护网上的原创内容,防止盗版和篡改行为对知识产权造成侵害。

[0162] 结合以上实施例,在一种实施方式中,本发明实施例还提供了一种网页篡改监测方法。具体地,在该方法中,除上述步骤之外,还可以包括步骤S101:

[0163] 步骤S101:在所述第一网页篡改结果和 / 或所述第二网页篡改结果为网页被篡改的情况下,生成告警信息并输出。

[0164] 本实施例中,深度学习模型(如不同类型的文本资源各自对应的文本监测模型、静态资源图片监测模型)被部署在云端服务器提供的GPU实例中,利用云端服务器强大的计算资源,使用诸如AWS,Azure,Goole Cloud等云计算平台提供的GPU实例来部署深度学习模型,通过API调用或其他方式让服务端与云端进行通信,能够减轻Web服务端负担,高效处理大规模的网页篡改监测任务。

[0165] 本实施例中,在第一网页篡改结果和 / 或第二网页篡改结果为网页被篡改的情况下,生成告警信息并输出。其中,针对第一网页篡改结果,若乱码检测结果和范围异常检测结果有任一结果异常,则确定第一网页篡改结果为网页被篡改。针对第二网页篡改结果,若有任一类型的资源(如不同类型的文本资源和静态图片资源中任一者)被篡改,则确定第二网页篡改结果为网页被篡改。

[0166] 本实施例中,告警信息至少包括以下一者:网页篡改的类型、篡改前后内容、发现时间;网页篡改的类型至少包括以下一者:异步AJAX请求数据字段篡改、同步HTTP请求HTML篡改、同步HTTP请求CSS篡改、同步HTTP请求JavaScript篡改和同步HTTP请求图片篡改。此外,告警信息还可以包括:被篡改部分的前后内容对比。

[0167] 本实施例中告警信息的输出形式包括但不限于:通过电子邮件、短信或系统通知等方式,及时通知相关管理员和用户。本实施例中,如果模型判断出存在篡改行为,系统可以触发报警机制,将结果输出给相关人员或其他系统组件。相关责任人可以通过告警信息快速定位到篡改内容追根溯源,还可以通过查询数据库的历史数据做进一步判断。

[0168] 在本实施例中,在第一网页篡改结果和 / 或第二网页篡改结果为网页未被篡改的情况下,将第一网页请求和 / 或第二网页请求对应的响应体返回至浏览器,浏览器针对该响应体进行页面渲染,展示对应的网页。

[0169] 本实施例中,可以及时通知网站管理员篡改类型和篡改内容,有利于管理员快速定位到篡改信息。此外,响应体存储模块不仅能够及时恢复至上一次保存的未被篡改的响应,还能记录到不同时间段的历史响应内容,这有利于管理者调动排查,进一步追根溯源,落实结果。

[0170] 结合以上实施例,在一实施例中,如图3所示,图3是本发明一实施例示出的一种网页篡改监测系统的整体系统架构图。该网页篡改监测系统(即图3中的云端网页篡改行为监测系统)用于执行上述任一实施例中的网页篡改检测方法。其中,云端网页篡改行为监测系统包括:请求分类模块、监测模块一和监测模块二,该监测模块一包括:第二存储模块、特定数据变动监测模块和告警模块;该监测模块二包括:第一存储模块、响应体数据整合与分析模块和告警模块。

[0171] 本实施例中,浏览器前端向web服务端发送网页请求,并接收web服务端发出的响应体,web服务端通过API调用云端服务器,将网页请求和响应体发送至云端服务器中的云端网页篡改行为监测系统,通过云端网页篡改行为监测系统进行网页检测,在确定网页有篡改行为时,通过告警模型进行告警,在确定网页无篡改行为时,将响应体放回浏览器前端。

[0172] 当浏览器发起请求时,JavaScript框架(如jQuery)会在请求头部中添加该字段,并赋予其特定的值(如"XMLHttpRequest")。在请求分类模块中,可以通过编写的Python脚本,检查请求头部中的"X-Requested-With"字段是否存在并包含特定的值,以此区分是同步HTTP请求或异步AJAX请求。经过该模块对请求进行分类后,系统会将响应体存储到对应的监测模块中,以进行后续篡改行为的判断。

[0173] 在第一存储模块或第二存储模块(即图3中的存储模块)中,使用mysql数据库和Amazon s3对象存储服务进行存储。可以设计特定的表结构用于对特定网页的地址、原始响应体URL(原始响应体在对象存储服务中的URL)和解析后的HTML内容、JavaScript内容、CSS内容、创建时间、更新时间进行存储,并设计另一个表结构对特定网页的图片静态资源原始地址、图片在对象存储服务中的URL、创建时间进行存储。

[0174] 其中,在一示例中,存储模块的具体示例可以包括:

[0175] (1)将对应信息上传至s3对象存储服务器:编写Python脚本,依据如下特定的标签及属性,从原始响应体中获取原始静态图片资源内容,将其上传至s3服务器,并将原始响应体也上传至s3服务器。

[0176] 标签:用于在页面中插入图片,通过src属性指定图片的URL。

[0177] <link>标签:通过<link>标签引入图标等静态资源,比如rel="icon"指定网站图标。

[0178] background-image属性:在CSS中使用background-image属性来设置元素的背景图片,该属性的值就是图片的URL。

[0179] (2)分别进行ResponseBody表和ImageResource表的构建。

[0180] 在监测模块一的特定数据变动监测模块中。服务器接收AJAX请求,会将查询到的字段信息封装作为响应体返回给前端,在该模块中,通过分析该数据,可以得到不同字段的数值,对这些数值进行变动监测,监测内容为其是否为乱码,或者数值是否超出合理范围,以确定是否有网页篡改行为,并在存在网页篡改行为时通过告警模块进行告警。

[0181] 在监测模块二的响应体数据整合与分析模块中,使用Python脚本,结合不同类型响应体的特定标签和属性,如<script>、<link>、<style>、等,对Web服务器返回的响应体进行不同内容的提取和拼接整合,将CSS样式和JavaScript脚本、HTML内容对应写入到设计好的mysql数据表中,将静态图片资源上传到s3服务器中,并将其地址写入数据表中。对上述整合好的数据进行分析,通过判断前后的特定类型响应内容(如CSS样式和JavaScript脚本、HTML内容)是否都为空,或判断前后响应体中是否有相同的图片资源,做出深度学习监测模型的调用决策,将相关数据输入到对应的监测模型中。

[0182] 其中,在一示例中,响应体数据整合与分析模块的具体示例可以包括:

[0183] 1)编写Python脚本,依据如下所示特定标签和属性,读取s3服务中的Web服务端原始响应内容,进行文本提取和同类型文本拼接,拆分出CSS样式和JavaScript脚本、HTML内容,将其写入到ResponseBody表的对应字段中。

[0184] A、获取JavaScript脚本内容:

[0185] <script>标签:通常包含在<head>或<body>中,用于定义页面的JavaScript脚本。

[0186] B、获取CSS样式内容:

[0187] <style>标签:内联样式表,用于定义页面元素的样式。

[0188] <link>标签:引入外部CSS样式表,通过href属性指定外部CSS文件的链接。

[0189] C、获取HTML内容:原始响应体除去上述两类后的剩余部分。该部分应包含静态资源内容,对于静态资源的篡改,除其在服务器中存储的内容外,还有可能是其在返回的响应体中被其他资源替换。

[0190] (2)分析篡改模型调度决策:针对CSS样式和JavaScript脚本、HTML内容这三类数据,编写Python脚本,分析当前请求的文本内容与上一次文本内容是否都为空:如果二者都是空的,不调用监测模型;如果其中一个是空的,将其文本内容更新为empty-flag,和另一个非空JavaScript脚本文本一起输入到监测模型中;如果二者都不是空的,则一起输入到监测模型中。

[0191] 针对静态图片资源,对比出前后两次请求是否包含相同地址的图片。如果有,就将其一起输入到静态资源图片监测模块,判断图片内容是否发生篡改。如果没有,则不做处理。

[0192] 在监测模块二中包括篡改行为识别模块(包含HTML内容文本监测模型、JavaScript脚本文本监测模型、CSS样式文本监测模型、静态资源图片监测模型),可以针对不同的资源类型的前后两次响应,调用事先训练好的HTML内容文本监测模型、JavaScript脚本文本监测模型、CSS样式文本监测模型和 / 或静态资源图片监测模型进行篡改识别,得到篡改结果,从而基于篡改结果判断是否有网页篡改行为,进而判断是否通过告警模块进行告警。

[0193] 在告警模块中,先记录发现的网页篡改事件,包括篡改的类型(异步请求数据字段篡改 / 同步请求HTML篡改 / CSS篡改 / JavaScript篡改 / 图片篡改)、篡改内容、发现时间等信息。然后,通过电子邮件、短信或系统通知等方式,及时通知相关管理员和用户。

[0194] 本实施例在综合比较相关Web防御技术和网页防篡改技术的基础上,提出了一种新的基于深度学习的云端网页篡改监测系统。首先,在Web服务端连接带有GPU加速的云端服务器,利用请求分类处理模块区分出当前请求属于同步获取网页整体的HTTP请求 / 异步获取特定数据的AJAX请求。针对AJAX请求,利用数值变动监测模块,识别出特定字段数据篡改行为。针对同步http请求,调用对应的网络模型对响应体中不同类型的文本和静态图片资源进行篡改监测。其中,Bi-TextCNNforWeb网络结构用于对Web服务器接收到的前一次请求和当前请求返回的JavaScript脚本、HTML内容、CSS样式进行文本特征编码,Bi-ImageCNNforWeb网络结构用于对Web服务器接收到的前一次请求和当前请求返回的静态资源进行特征编码,通过输入大量网页的服务器正常响应和篡改后的响应样本进行训练,使得模型能够学习到复杂的特征表示,更好地识别出复杂的篡改行为。其中,本实施例利用Bi-TextCNNforWeb深度学习模型和Bi-ImageCNNforWeb深度学习模型监测篡改行为。不同于传统意义上的孪生网络,Bi-TextCNNforWeb网络使用共享权重的卷积层和池化层提取文本的特征,然后将特征进行融合并输入到全连接层和二分类器中,从而实现对两个文本是否发生篡改的判断。输入大量网页请求的服务器正常响应和篡改后的响应进行训练,对比DOM树等形式蕴含更为丰富的原始信息。该模型具有较高的灵活性,能够学习到正常响应和被篡改响应的复杂特征表示,从而应对不同类型的网页篡改手段。

[0195] 最后,对各模块监测结果进行综合分析,得到网页是否被篡改以及被篡改具体类型等相关信息,及时告警通知网站管理员,帮助管理员及时采取措施应对篡改行为。本发明创造的目的是为了降低传统静态校验方法的误报率,综合监测攻击者篡改网页的多种手段,提高系统的鲁棒性和适应能力。同时,能够克服传统静态校验方法在动态网页上的局限性,使得系统兼容静态和动态网页的篡改行为监测场景,提高系统的灵活度和监测效率,输出更有利于网站管理员定位问题的篡改监测结果。

[0196] 需要说明的是,对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明实施例并不受所描述的动作顺序的限制,因为依据本发明实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本发明实施例所必须的。

[0197] 基于同一发明构思,本发明一实施例提供了一种网页篡改监测装置400。参考图4,图4是本发明一实施例提供的网页篡改监测装置的结构框图。如图4所示,该网页篡改监测装置400包括:

[0198] 第一获取模块401,用于获取Web服务端返回给浏览器的响应体和所述响应体对应的网页请求;

[0199] 请求分类模块402,用于对所述网页请求进行分类,确定所述网页请求的请求类别;

[0200] 第一监测模块403,用于针对所述请求类别为异步AJAX请求的第一网页请求,基于所述第一网页请求对应的响应体,识别字段数据篡改行为,得到第一网页篡改结果;

[0201] 第二监测模块404,用于针对所述请求类别为同步HTTP请求的第二网页请求,调用深度学习模型对所述第二网页请求对应的响应体中不同类型的资源进行篡改监测,得到第二网页篡改结果。

[0202] 可选地,所述网页篡改监测装置400还包括:

[0203] 判断模块,用于在调用深度学习模型对所述第二网页请求对应的响应体中不同类型的资源进行篡改监测,得到第二网页篡改结果之前,确定所述第二网页请求对应的响应体中不同类型的资源,和,所述第二网页请求的前一次第二网页请求所对应的响应体中不同类型的资源是否都为空;

[0204] 所述第二监测模块404,包括:

[0205] 第二监测子模块,用于在所述第二网页请求对应的响应体中不同类型的资源,和,所述第二网页请求的前一次第二网页请求所对应的响应体中不同类型的资源不都为空的情况下,调用深度学习模型对所述第二网页请求对应的响应体中不同类型的资源进行篡改监测,得到第二网页篡改结果。

[0206] 可选地,所述不同类型的资源至少包括:不同类型的文本资源;所述深度学习模型至少包括:不同类型的文本资源各自对应的文本监测模型;所述第二监测模块404,包括:

[0207] 第一提取模块,用于按照所述第二网页请求对应的响应体的标签和 / 或属性,从所述第二网页请求对应的响应体中提取出不同类型的当前文本资源;

[0208] 第二获取模块,用于获取所述第二网页请求的前一次第二网页请求对应的响应体中的不同类型的前一次文本资源;

[0209] 第一调用模块,用于调用所述不同类型的文本资源各自对应的文本监测模型,对不同类型的当前文本资源和不同类型的前一次文本资源进行篡改监测,得到不同类型的文本资源各自对应的篡改结果;

[0210] 结果确定模块,用于至少基于不同类型的文本资源各自对应的篡改结果,得到所述第二网页篡改结果。

[0211] 可选地,所述第一调用模块,包括:

[0212] 文本输入模块,用于分别将不同类型的当前文本资源和不同类型的前一次文本资源输入不同类型的文本资源各自对应的文本监测模型;所述不同类型的文本资源各自对应的文本监测模型是分别基于正常响应的响应体中不同类型的文本资源和篡改后的响应体中不同类型的文本资源训练得到的;所述文本监测模型至少包括:第一卷积池化层、第二卷积池化层、全连接层、sigmoid层和二分类器;所述第一卷积池化层和所述第二卷积池化层共享权重;

[0213] 文本向量化模块,用于通过所述不同类型的文本资源各自对应的文本监测模型,分别对不同类型的当前文本资源和不同类型的前一次文本资源进行文本向量化,得到当前文本资源对应的第一数值向量和前一次文本资源对应的第二数值向量;

[0214] 第一特征提取模块,用于通过所述第一卷积池化层对所述第一数值向量进行特征提取和压缩整合,得到第一特征信息;通过所述第二卷积池化层对第二数值向量进行特征提取和压缩整合,得到第二特征信息;

[0215] 第一融合模块,用于对所述第一特征信息和所述第二特征信息进行特征融合,得到融合特征;

[0216] 第一输入模块,用于将所述融合特征依次输入所述全连接层、所述sigmoid层和所述二分类器,得到篡改结果。

[0217] 可选地,所述不同类型的资源还包括:静态图片资源;所述深度学习模型还包括:静态资源图片监测模型;所述网页篡改监测装置400还包括:

[0218] 第二提取模块,用于针对所述请求类别为同步HTTP请求的第二网页请求,从所述第二网页请求对应的响应体中提取出当前静态图片资源;

[0219] 第三获取模块,用于获取所述第二网页请求的前一次第二网页请求对应的响应体中的前一次静态图片资源;

[0220] 第二调用模块,用于调用所述静态资源图片监测模型,对所述当前静态图片资源和所述前一次静态图片资源进行篡改监测,得到静态图片资源对应的篡改结果;

[0221] 所述结果确定模块,包括:

[0222] 结果确定子模块,用于基于不同类型的文本资源各自对应的篡改结果,和,所述静态图片资源对应的篡改结果,得到所述第二网页篡改结果。

[0223] 可选地,所述第二调用模块,包括:

[0224] 图片输入模块,用于分别将所述当前静态图片资源和所述前一次静态图片资源输入所述静态资源图片监测模型;所述静态资源图片监测模型是基于正常响应的响应体中的静态图片资源和篡改后的响应体中的静态图片资源训练得到的;所述静态资源图片监测模型至少包括:第三卷积池化层、第四卷积池化层、全连接层、sigmoid层和二分类器;所述第三卷积池化层和所述第四卷积池化层共享权重;

[0225] 第二特征提取模块,用于通过所述第三卷积池化层对所述当前静态图片资源进行特征提取,得到第一图像特征信息;通过所述第四卷积池化层对所述前一次静态图片资源进行特征提取,得到第二图像特征信息;

[0226] 第二融合模块,用于对所述第一图像特征信息和所述第二图像特征信息进行特征融合,得到图像融合特征;

[0227] 第二输入模块,用于将所述图像融合特征依次输入所述全连接层、所述sigmoid层和所述二分类器,得到所述静态图片资源对应的篡改结果。

[0228] 可选地,所述深度学习模型被部署在云端服务器提供的GPU实例中,所述网页篡改监测装置400还包括:

[0229] 告警输出模块,用于在所述第一网页篡改结果和 / 或所述第二网页篡改结果为网页被篡改的情况下,生成告警信息并输出;

[0230] 所述告警信息至少包括以下一者:网页篡改的类型、篡改前后内容、发现时间;所述网页篡改的类型至少包括以下一者:异步AJAX请求数据字段篡改、同步HTTP请求HTML篡改、同步HTTP请求CSS篡改、同步HTTP请求JavaScript篡改和同步HTTP请求图片篡改。

[0231] 基于同一发明构思,本发明另一实施例提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现本发明上述任一实施例所述的网页篡改监测方法中的步骤。

[0232] 基于同一发明构思,本发明另一实施例提供一种电子设备500,如图5所示。图5是本发明一实施例示出的一种电子设备的示意图。该电子设备包括存储器502、处理器501及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行时实现本发明上述任一实施例所述的网页篡改监测方法中的步骤。

[0233] 对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。

[0234] 本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。

[0235] 以上对本发明所提供的一种网页篡改监测方法、装置、设备及介质,进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。< / script>

Claims

1. A method for detecting website tampering, characterized in that, The method includes: Obtain the response body returned by the web server to the browser and the web page request corresponding to the response body; The web page requests are categorized to determine the request category of each web page request; For the first webpage request whose request type is asynchronous AJAX request, based on the response body corresponding to the first webpage request, identify field data tampering behavior and obtain the first webpage tampering result; For the second webpage request, which is a synchronous HTTP request, a deep learning model is invoked to monitor the tampering of different types of resources in the response body corresponding to the second webpage request, and the tampering result of the second webpage is obtained. The step of identifying field data tampering behavior and obtaining the first webpage tampering result based on the response body corresponding to the first webpage request includes: Extract specific field information from the response body corresponding to the first webpage request; Perform data garbled character detection on the specific field information to obtain the garbled character detection result; Perform numerical range anomaly detection on the specific field information to obtain the range anomaly detection result; Based on the garbled text detection results and the range anomaly detection results, the first webpage tampering result is obtained; The different types of resources include at least: different types of text resources; the deep learning model includes at least: text detection models corresponding to each of the different types of text resources; the step of calling the deep learning model to detect tampering of different types of resources in the response body corresponding to the second webpage request, and obtaining the tampering result of the second webpage, includes: Based on the tags and / or attributes of the response body corresponding to the second web page request, extract different types of current text resources from the response body corresponding to the second web page request; Retrieve different types of previous text resources from the response body of the previous second webpage request; The text monitoring models corresponding to the different types of text resources are invoked to monitor the tampering of the current text resources of different types and the previous text resources of different types, so as to obtain the tampering results corresponding to the different types of text resources. The second webpage tampering result is obtained based at least on the tampering results corresponding to different types of text resources; The step involves calling the text monitoring models corresponding to the different types of text resources to perform tampering monitoring on the current text resources and the previous text resources of different types, obtaining the tampering results corresponding to the different types of text resources, including: Different types of current text resources and different types of previous text resources are respectively input into the text detection models corresponding to different types of text resources; the text detection models corresponding to different types of text resources are trained based on different types of text resources in the response body of a normal response and different types of text resources in the response body of a tampered response; the text detection model includes at least: a first convolutional pooling layer, a second convolutional pooling layer, a fully connected layer, a sigmoid layer and a binary classifier; the first convolutional pooling layer and the second convolutional pooling layer share weights; Using the text monitoring models corresponding to the different types of text resources, text vectorization is performed on the current text resources of different types and the previous text resources of different types to obtain the first numerical vector corresponding to the current text resource and the second numerical vector corresponding to the previous text resource. The first numerical vector is subjected to feature extraction and compression integration through the first convolutional pooling layer to obtain the first feature information; the second numerical vector is subjected to feature extraction and compression integration through the second convolutional pooling layer to obtain the second feature information. The first feature information and the second feature information are fused to obtain the fused feature; The fused features are sequentially input into the fully connected layer, the sigmoid layer, and the binary classifier to obtain the tampering result.

2. The webpage tampering monitoring method according to claim 1, characterized in that, Before calling a deep learning model to detect tampering of different types of resources in the response body corresponding to the second webpage request and obtaining the tampering result of the second webpage, the method further includes: Determine the different types of resources in the response body corresponding to the second webpage request, and whether the different types of resources in the response body corresponding to the previous second webpage request are all empty; The process involves using a deep learning model to monitor for tampering with different types of resources in the response body corresponding to the second webpage request, thereby obtaining the tampering results of the second webpage, including: If different types of resources in the response body corresponding to the second webpage request are not all empty, and if different types of resources in the response body corresponding to the previous second webpage request are not all empty, a deep learning model is invoked to monitor the tampering of different types of resources in the response body corresponding to the second webpage request, and the tampering result of the second webpage is obtained.

3. The webpage tampering monitoring method according to claim 1, characterized in that, The different types of resources also include: static image resources; the deep learning model also includes: a static resource image monitoring model; the method also includes: For the second webpage request, which is a synchronous HTTP request, extract the current static image resource from the response body corresponding to the second webpage request; Retrieve the previous static image resource from the response body of the previous second webpage request; The static resource image monitoring model is invoked to monitor for tampering of the current static image resource and the previous static image resource, and the tampering result corresponding to the static image resource is obtained. The process of obtaining the second webpage tampering result based at least on the tampering results corresponding to different types of text resources includes: Based on the tampering results corresponding to different types of text resources and the tampering results corresponding to the static image resources, the second webpage tampering result is obtained.

4. The webpage tampering monitoring method according to claim 3, characterized in that, The step of calling the static resource image monitoring model to monitor the tampering of the current static image resource and the previous static image resource, and obtaining the tampering result corresponding to the static image resource, includes: The current static image resource and the previous static image resource are respectively input into the static resource image monitoring model; the static resource image monitoring model is trained based on the static image resources in the response body of a normal response and the static image resources in the response body of a tampered response; the static resource image monitoring model includes at least: a third convolutional pooling layer, a fourth convolutional pooling layer, a fully connected layer, a sigmoid layer, and a binary classifier; the third convolutional pooling layer and the fourth convolutional pooling layer share weights; The third convolutional pooling layer extracts features from the current static image resource to obtain first image feature information; the fourth convolutional pooling layer extracts features from the previous static image resource to obtain second image feature information. The first image feature information and the second image feature information are fused to obtain image fusion features; The image fusion features are sequentially input into the fully connected layer, the sigmoid layer, and the binary classifier to obtain the tampering result corresponding to the static image resource.

5. The webpage tampering detection method according to any one of claims 1 to 4, characterized in that, The deep learning model is deployed on a GPU instance provided by a cloud server, and the method further includes: If the first webpage tampering result and / or the second webpage tampering result are that the webpage has been tampered with, an alarm message is generated and output; The alarm information includes at least one of the following: the type of webpage tampering, the content before and after tampering, and the time of discovery; the type of webpage tampering includes at least one of the following: asynchronous AJAX request data field tampering, synchronous HTTP request HTML tampering, synchronous HTTP request CSS tampering, synchronous HTTP request JavaScript tampering, and synchronous HTTP request image tampering.

6. A webpage tampering monitoring device, characterized in that, The device includes: The first acquisition module is used to acquire the response body returned by the Web server to the browser and the web page request corresponding to the response body; The request classification module is used to classify the web page requests and determine the request category of the web page requests; The first monitoring module is used to identify field data tampering behavior and obtain the first webpage tampering result based on the response body corresponding to the first webpage request, which is an asynchronous AJAX request. The second monitoring module is used to monitor the tampering of different types of resources in the response body of the second webpage request based on the first webpage request, which is an asynchronous AJAX request, and to monitor the second webpage request, which is a synchronous HTTP request, based on the first webpage request. The module calls a deep learning model to monitor the tampering of different types of resources in the response body of the second webpage request and obtains the tampering result of the second webpage. The first monitoring module includes: The third extraction module is used to extract specific field information from the response body corresponding to the first webpage request; The first detection module is used to perform data garbled character detection on the specific field information and obtain the garbled character detection result. The second detection module is used to perform numerical range anomaly detection on the specific field information and obtain the range anomaly detection result. The tampering determination module is used to obtain the first webpage tampering result based on the garbled character detection result and the range anomaly detection result; The different types of resources include at least: different types of text resources; the deep learning model includes at least: text monitoring models corresponding to each different type of text resource; the second monitoring module includes: The first extraction module is used to extract different types of current text resources from the response body corresponding to the second web page request according to the tags and / or attributes of the response body corresponding to the second web page request. The second acquisition module is used to acquire different types of previous text resources in the response body corresponding to the previous second web page request of the second web page request. The first calling module is used to call the text monitoring model corresponding to each of the different types of text resources, to perform tampering monitoring on the current text resources of different types and the previous text resources of different types, and to obtain the tampering results corresponding to each of the different types of text resources. The result determination module is used to obtain the second webpage tampering result based at least on the tampering results corresponding to different types of text resources; The first calling module includes: The text input module is used to input different types of current text resources and different types of previous text resources into the text detection models corresponding to the different types of text resources respectively; the text detection models corresponding to the different types of text resources are trained based on different types of text resources in the response body of a normal response and different types of text resources in the response body of a tampered response; the text detection model includes at least: a first convolutional pooling layer, a second convolutional pooling layer, a fully connected layer, a sigmoid layer and a binary classifier; the first convolutional pooling layer and the second convolutional pooling layer share weights; The text vectorization module is used to perform text vectorization on the current text resource of different types and the previous text resource of different types respectively through the text monitoring model corresponding to the different types of text resources, so as to obtain the first numerical vector corresponding to the current text resource and the second numerical vector corresponding to the previous text resource. The first feature extraction module is used to extract and compress the first numerical vector through the first convolutional pooling layer to obtain first feature information; and to extract and compress the second numerical vector through the second convolutional pooling layer to obtain second feature information. The first fusion module is used to fuse the first feature information and the second feature information to obtain fused features; The first input module is used to sequentially input the fused features into the fully connected layer, the sigmoid layer, and the binary classifier to obtain the tampering result.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by the processor, it implements the webpage tampering detection method as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the webpage tampering detection method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Client side webpage tampering detecting method based on dynamic and static separation template

    CN108182370A

  • Webpage tamper-proofing method and device, equipment and storage medium

    CN114091118A

  • Method, appratus and computer-readable recording medium for processing web page by referring to a degree of learning with respect to web page and a kind of web page to thereby assist the detection of abnormality in web page

    KR101542737B1