Webpage tampering monitoring method and device, equipment and medium
By classifying the web server response body and web page requests, and combining the deep learning model to tamper with resources synchronized HTTP requests, the problem of difficulty in monitoring dynamic web page tampering in the existing technology is solved, and efficient monitoring of static and dynamic web pages is achieved.
Patent Information
- Application Number
- CN202411706702.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-11-26
AI Technical Summary
It is difficult for the existing technology to effectively monitor and detect the tampering behavior of dynamic web pages. The traditional static verification method has problems such as false alarms, missed alarms and easy to crack on dynamic web pages.
By obtaining the response body and web page request returned by the web server, classifying the request, using field data tampering identification for asynchronous AJAX requests, and calling the deep learning model for synchronous HTTP requests for resource tampering monitoring, realizing compatible monitoring of static and dynamic web pages.
It improves the flexibility and efficiency of web page tamper monitoring, reduces the false alarm rate of traditional static verification methods, can monitor the tampering behavior of dynamic web pages in real time, and enhances network security.
Smart Images

Figure CN119814351A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of deep learning technology, and in particular, to a web page tampering monitoring method, device, equipment and medium. Background Art
[0002] With the continuous development of Internet technology, many businesses and services are provided to users in the form of web pages. These web pages usually cover information from all walks of life, including data in important fields such as finance, medical care, and e-commerce. However, the widespread use of web pages has made them face more severe security issues. For example, web page information is tampered with by various means (such as controlling web servers, XSS attacks, etc.), and information is stolen, which has a negative impact on the reputation and interests of enterprises and institutions, and poses a serious security threat to users and related institutions.
[0003] Currently, there are mainstream static web page tampering monitoring solutions such as MD5 numerical verification and DOM (Document Object Model) tree (a tree model representing the structure of HTML or XML documents, this tree structure contains the information and relationship of each element in the page (such as tags, attributes, text content, etc.). Through the DOM tree, the elements in the page can be easily accessed and operated to achieve dynamic modification and interaction of the page content) comparison. Among them, the MD5 algorithm is simple and fast, but there is a numerical collision vulnerability, and it is difficult to ensure the accuracy of detection. The DOM tree represents the structure and content of the web page, and can more accurately detect the changes in specific elements and content from complex web pages. Since the page structure and content of dynamic web pages are varied, the changes may be legitimate interactive behaviors or tampering behaviors. It is difficult to detect the tampering of dynamic web pages using the above mainstream solutions. For dynamic web pages, most of the current related solutions focus on using cryptographic technology to protect the transmission process of dynamic data, such as encrypted transmission, digital certificates, etc. These technologies will increase the complexity of the system, the implementation and maintenance costs are high, and there is also a risk of being attacked by cryptographic algorithm vulnerabilities. Some solutions use timed crawler technology to identify dynamic web page data tampering, which has delay and resource consumption issues.
[0004] To sum up, the current web page tampering monitoring technology still has problems such as missed reports, false alarms, and easy cracking. It is necessary to develop a more efficient and accurate web page anti-tampering method that is compatible with static and dynamic web page tampering behavior monitoring scenarios. This is of great significance for improving network security and user experience. Summary of the invention
[0005] The embodiments of the present invention provide a web page tampering monitoring method, device, equipment and medium to overcome the limitations of traditional static verification methods on dynamic web pages, be compatible with tampering behavior monitoring scenarios of static and dynamic web pages, and improve the flexibility and monitoring efficiency of web page tampering monitoring.
[0006] A first aspect of an embodiment of the present invention provides a method for monitoring webpage tampering, the method comprising:
[0007] Obtaining the response body returned by the Web server to the browser and the web page request corresponding to the response body;
[0008] Classifying the web page request to determine a request category of the web page request;
[0009] For the first web page request whose request category is an asynchronous AJAX request, based on a response body corresponding to the first web page request, identifying a field data tampering behavior, and obtaining a first web page tampering result;
[0010] For the second web page request whose request category is a synchronous HTTP request, a deep learning model is called to monitor tampering of different types of resources in a response body corresponding to the second web page request to obtain a second web page tampering result.
[0011] A second aspect of an embodiment of the present invention provides a webpage tampering monitoring device, the device comprising:
[0012] A first acquisition module is used to acquire a response body returned by the Web server to the browser and a web page request corresponding to the response body;
[0013] A request classification module, used to classify the web page request and determine the request category of the web page request;
[0014] A first monitoring module is used to identify field data tampering behavior based on a response body corresponding to a first web page request whose request category is an asynchronous AJAX request, and obtain a first web page tampering result;
[0015] The second monitoring module is used to call the deep learning model to monitor the tampering of different types of resources in the response body corresponding to the first web page request with the request category of asynchronous AJAX request based on the first web page request and the second web page request with the request category of synchronous HTTP request, so as to obtain the tampering result of the second web page.
[0016] A third aspect of an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the computer program is executed by the processor, the web page tampering monitoring method of the first aspect of the embodiment of the present invention is implemented.
[0017] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the web page tampering monitoring method according to the first aspect of the embodiment of the present invention is implemented.
[0018] In the web page tampering monitoring method provided in an embodiment of the present invention, first, a response body returned by a Web server to a browser and a web page request corresponding to the response body are obtained; secondly, 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 a first web page request of an asynchronous AJAX request, that is, a first web page request for a dynamic web page, field data tampering behavior is identified based on the response body corresponding to the first web page request to obtain a first web page tampering result; for a second web page request of a synchronous HTTP request, that is, a second web page request for a static web page, different types of resources in the response body corresponding to the second web page request are monitored for tampering by calling a deep learning model to obtain a second web page tampering result. In this way, this embodiment 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, selects different monitoring methods based on the judgment results, and monitors the response body of the synchronous HTTP request by calling a trained deep learning model, thereby reducing the false alarm rate of traditional static verification methods. This allows this embodiment to overcome the limitations of traditional static verification methods on dynamic web pages, and is compatible with monitoring scenarios of static and dynamic web pages. Compared with related solutions such as timed crawlers to determine numerical anomalies of dynamic web pages, it has the advantage of higher real-time performance, thereby improving the flexibility and efficiency of web page tampering monitoring. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0020] Figure 1 is a flow chart of a webpage tampering monitoring method shown in one embodiment of the present invention;
[0021] Figure 2 is a schematic diagram of a network model structure of a text monitoring model shown in an embodiment of the present invention;
[0022] Figure 3 is an overall system architecture diagram of a webpage tampering monitoring system shown in one embodiment of the present invention;
[0023] Figure 4 is a structural block diagram of a webpage tampering monitoring device provided by an embodiment of the present invention;
[0024] Figure 5 It is a schematic diagram of an electronic device shown in an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] refer to Figure 1 , Figure 1 FIG. 1 is a flow chart of a webpage tampering monitoring method according to an embodiment of the present invention. Figure 1 As shown, the webpage tampering monitoring method of this embodiment can be applied to a cloud server, and the webpage tampering monitoring method can include the following steps:
[0027] Step S11: Obtain the response body returned by the Web server to the browser and the web page request corresponding to the response body.
[0028] When a browser requests a page from a Web server, it sends a web page request to the Web server. The Web server generates a response body based on the web page request and returns the response body to the browser. The browser parses the page based on 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 web page attacks. Based on this, when performing web page tampering monitoring, this embodiment can obtain the response body returned by the Web server to the browser and the web page request corresponding to the response body.
[0029] In an optional implementation, the response body returned by the Web server to the browser in this embodiment refers to the response body sent by the Web server to the browser but not received by the browser. After determining through this method that the response body has not been tampered with, the response body is returned to the browser to prevent the web page from being tampered with.
[0030] Step S12: classify the web page request to determine the request category of the web page request.
[0031] In this embodiment, it is necessary to classify the web page request corresponding to the response body to determine the request category of the web page request. Among them, the request categories of this embodiment are divided into: asynchronous AJAX request and synchronous HTTP request. Among them, the synchronous HTTP request obtains data by sending a complete page request, which will update the entire page and is a web page request for a static web page; while 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, and is a web page request for a dynamic web page.
[0032] In this embodiment, a static web page refers to fixed content prepared in advance on a 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 it, and a fixed page is displayed to the user. A static web page is usually composed of static files such as HTML, CSS and JavaScript, which do not change when the user accesses it.
[0033] Dynamic web pages refer to the situation where the server dynamically generates content based on the user's needs when the user requests it, and returns the generated results to the user. Dynamic web pages usually include dynamic operations such as database query, user interaction, data processing, etc., and can generate different content based on the different needs of users. They have the characteristics of higher interactivity and real-time update.
[0034] In an optional embodiment, a Python script can be used to classify the request categories of web page requests sent by the browser and received by the web server into synchronous HTTP requests and asynchronous AJAX requests according to the different request header field parameters of the web page requests. Among them, AJAX (Asynchronous JavaScript and XML) request: a technology for creating fast dynamic web pages, which can exchange data with the server through the background without reloading the entire page. Through AJAX technology, asynchronous data transmission can be achieved, so that the web page can send requests to the server and receive responses without affecting the user's operation, thereby achieving real-time updates and a more interactive interface.
[0035] Step S13: for the first web page request whose request category is an asynchronous AJAX request, based on the response body corresponding to the first web page request, identifying the field data tampering behavior, and obtaining the first web page tampering result.
[0036] The first web page request in this embodiment is a web page request with a request category of asynchronous AJAX request. For the first web page request with a 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, and the field data tampering behavior of the response body corresponding to the first web page request can be identified to obtain a first web page tampering result. The first web page tampering result is the web page tampering result of the asynchronous AJAX request, that is, the web page tampering result of the dynamic web page.
[0037] Step S14: For the second web page request whose request category is a synchronous HTTP request, a deep learning model is called to monitor tampering of different types of resources in a response body corresponding to the second web page request to obtain a second web page tampering result.
[0038] The second web page request of this embodiment is a web page request whose request category is a synchronous HTTP request. For the second web page request whose request category is a synchronous HTTP request, this embodiment can call a deep learning model to monitor the tampering of different types of resources in the response body corresponding to the second web page request, and obtain the second web page tampering result. The second web page tampering result is the web page tampering result of the synchronous HTTP request, that is, the web page tampering result of the static web page. Among them, the deep learning model is a pre-trained model for tampering detection of different types of resources in the response body corresponding to the web page request of the synchronous HTTP request, and can accurately identify the tampering result of the static web page.
[0039] In this 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, and selects different monitoring methods based on the determination results. In this way, both dynamic and static web pages can be monitored for tampering. In addition, the response body of the synchronous HTTP request is monitored by calling a trained deep learning model, thereby reducing the false alarm rate of traditional static verification methods, comprehensively monitoring various means by which attackers tamper with web pages, and improving the robustness and adaptability of the system. This embodiment can overcome the limitations of traditional static verification methods on dynamic web pages, and is compatible with monitoring scenarios of static and dynamic web pages. Compared with related solutions such as timed crawlers that determine numerical anomalies in dynamic web pages, it has the advantage of higher real-time performance, thereby improving the flexibility and efficiency of web page tampering monitoring.
[0040] In combination with the above embodiments, in one implementation, an embodiment of the present invention further provides a webpage tampering monitoring method. Specifically, in this embodiment, different types of resources at least include: different types of text resources; the deep learning model at least includes: text monitoring models corresponding to different types of text resources; and the above step S14 "calling the deep learning model to monitor the tampering of different types of resources in the response body corresponding to the second webpage request to obtain the second webpage tampering result" may specifically include steps S21 to S24:
[0041] Step S21: extracting different types of current text resources from the response body corresponding to the second web page request according to the label and / or attribute of the response body corresponding to the second web page request.
[0042] In this embodiment, the response body generally includes a status code, a response header, and different types of current text resources, as well as some static resource files, etc. Different types of current text resources can be extracted from the response body corresponding to the second web page request according to the labels and / or attributes of the response body corresponding to the second web page request. The current text resource is the text resource in the response body corresponding to the second web page request to be identified. For example, using Python scripts, combined with specific labels 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 webpage tampering monitoring method, characterized in that: The method comprises: Obtaining the response body returned by the Web server to the browser and the web page request corresponding to the response body; Classifying the web page request to determine a request category of the web page request; For the first web page request whose request category is an asynchronous AJAX request, based on a response body corresponding to the first web page request, identifying a field data tampering behavior, and obtaining a first web page tampering result; For the second web page request whose request category is a synchronous HTTP request, a deep learning model is called to monitor tampering of different types of resources in a response body corresponding to the second web page request to obtain a second web page tampering result.
2. The webpage tampering monitoring method according to claim 1, characterized in that: Before calling the deep learning model to monitor the tampering of different types of resources in the response body corresponding to the second webpage request to obtain the second webpage tampering result, 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 of the second webpage request are both empty; The calling of the deep learning model to monitor the tampering of different types of resources in the response body corresponding to the second webpage request to obtain the second webpage tampering result includes: When different types of resources in the response body corresponding to the second web page request and different types of resources in the response body corresponding to the previous second web page request of the second web page request are not all empty, 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 to obtain a second web page tampering result.
3. The webpage tampering monitoring method according to claim 1, characterized in that: 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 different types of text resources; the calling of the deep learning model to monitor the tampering of different types of resources in the response body corresponding to the second web page request to obtain the second web page tampering result includes: extracting different types of current text resources from the response body corresponding to the second web page request according to the label and / or attribute of the response body corresponding to the second web page request; Obtaining different types of previous text resources in a response body corresponding to a previous second webpage request of the second webpage request; Calling the text monitoring models corresponding to the different types of text resources respectively, performing tampering monitoring on different types of current text resources and different types of previous text resources, and obtaining tampering results corresponding to different types of text resources respectively; The second webpage tampering result is obtained based at least on the tampering results corresponding to different types of text resources.
4. The webpage tampering monitoring method according to claim 3, characterized in that: The calling of the text monitoring models corresponding to the different types of text resources respectively, performing tampering monitoring on the different types of current text resources and different types of previous text resources, and obtaining the tampering results corresponding to the different types of text resources respectively, includes: Different types of current text resources and different types of previous text resources are respectively input into text monitoring models corresponding to different types of text resources; the text monitoring models corresponding to different types of text resources are respectively trained based on different types of text resources in the response body of the normal response and different types of text resources in the response body after tampering; the text monitoring model at least includes: 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, respectively, text vectorization is performed on different types of current text resources and different types of previous text resources to obtain a first numerical vector corresponding to the current text resource and a second numerical vector corresponding to the previous text resource; Performing feature extraction and compression integration on the first numerical vector through the first convolution pooling layer to obtain first feature information; performing feature extraction and compression integration on the second numerical vector through the second convolution pooling layer to obtain second feature information; Performing feature fusion on the first feature information and the second feature information to obtain a 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.
5. The webpage tampering monitoring method according to claim 3, 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 web page request whose request category is a synchronous HTTP request, extracting the current static image resource from the response body corresponding to the second web page request; Obtain a previous static image resource in a response body corresponding to a previous second webpage request of the second webpage request; Calling the static resource image monitoring model to perform tampering monitoring on the current static image resource and the previous static image resource to obtain tampering results corresponding to the static image resources; The obtaining the second webpage tampering result based on at least the tampering results corresponding to the different types of text resources respectively includes: The second webpage tampering result is obtained based on the tampering results corresponding to different types of text resources and the tampering results corresponding to the static image resources.
6. The webpage tampering monitoring method according to claim 5, characterized in that: The calling of the static resource image monitoring model to perform tampering monitoring on the current static image resource and the previous static image resource to obtain tampering results 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 the normal response and the static image resources in the response body after tampering; the static resource image monitoring model at least includes: a third convolution pooling layer, a fourth convolution pooling layer, a fully connected layer, a sigmoid layer and a binary classifier; the third convolution pooling layer and the fourth convolution pooling layer share weights; Performing feature extraction on the current static picture resource through the third convolution pooling layer to obtain first image feature information; performing feature extraction on the previous static picture resource through the fourth convolution pooling layer to obtain second image feature information; Performing feature fusion on the first image feature information and the second image feature information to obtain an image fusion feature; 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 picture resource.
7. The webpage tampering monitoring method according to any one of claims 1 to 6, characterized in that: The deep learning model is deployed in a GPU instance provided by a cloud server, and the method further includes: When the first webpage tampering result and / or the second webpage tampering result is that the webpage has been tampered with, generating and outputting alarm information; The alarm information includes at least one of the following: the type of web page tampering, the content before and after the tampering, and the discovery time; the type of web page 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.
8. A webpage tampering monitoring device, characterized in that: The device comprises: A first acquisition module is used to acquire a response body returned by the Web server to the browser and a web page request corresponding to the response body; A request classification module, used to classify the web page request and determine the request category of the web page request; A first monitoring module is used to identify field data tampering behavior based on a response body corresponding to a first web page request whose request category is an asynchronous AJAX request, and obtain a first web page tampering result; The second monitoring module is used to call the deep learning model to monitor the tampering of different types of resources in the response body corresponding to the first web page request with the request category of asynchronous AJAX request based on the first web page request and the second web page request with the request category of synchronous HTTP request, so as to obtain the tampering result of the second web page.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the computer program is executed by the processor, the web page tampering monitoring method as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the web page tampering monitoring method as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Client side webpage tampering detecting method based on dynamic and static separation template
CN108182370A
Data tampering monitoring and recognition method and device based on multi-dimensional analysis, electronic equipment and storage medium thereof
CN111967063A
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
Web-page modulation estimation method and web-page modulation estimation system
KR1020090090810A