Fraud-related webpage real-time anomaly detection method based on deep reinforcement learning
By constructing a visual adjacency graph and graph neural network through deep reinforcement learning, the problem of performance degradation in real-time detection of dynamic web pages by traditional detection methods is solved, achieving high robustness and fast detection of fraudulent web pages.
Patent Information
- Application Number
- CN202511725811.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-24
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-11-24
AI Technical Summary
Traditional webpage detection methods struggle to handle the structural changes of dynamic webpages, leading to a decline in real-time detection performance and an inability to reliably identify deceptive intent in fraudulent webpages.
By using deep reinforcement learning methods, a visual adjacency graph is constructed, discrete curvature and anomaly index are calculated, and graph neural networks are combined to perform real-time anomaly detection and adaptively update webpage structure changes.
It achieves real-time detection stability and discrimination accuracy in complex and dynamic environments, improving the robustness and speed of detecting fraudulent web pages.
Smart Images

Figure CN121193543B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of reinforcement learning technology, and more specifically, to a real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning. Background Technology
[0002] With the increasing sophistication and automation of online fraud methods, fraudulent web pages are exhibiting a high degree of diversity and deception in their structure and presentation. Traditional detection methods typically rely on static URL features, keyword rules, or overall page fingerprint comparison. While these methods are computationally simple, they struggle to cope with the development of dynamic web page technologies. For example, modern web pages widely employ front-end component frameworks, dynamic content loading, and asynchronous rendering technologies, meaning the content presented on a page can be completely different at different times. Because fraudulent web pages often embed resources from multiple sites (such as advertisements, statistical scripts, and external components), the page structure exhibits significant layering and encapsulation at both the visual and logical levels. This makes detection results based on traditional features or rules unstable and easily affected by dynamic page changes.
[0003] In practical analysis, it was found that the rendering result of a webpage is not entirely determined by a single source code, but is influenced by multiple domains and rendering contexts. After a webpage is segmented into independent visual units, each unit may originate from different embedding layers or external components. When the detection system can only capture the visible portion of the page and cannot obtain the isolated or deferred internal structure, the overall topological relationship of the page will be partially broken or missing. This structural defect causes significant deviations in the detection model's extraction of spatial relationships or layout information: the interaction paths of some important areas are truncated, resulting in incomplete model judgment. Simultaneously, the differences in the visible area presented by the page under different devices, resolutions, or loading times cause the same webpage to exhibit extremely high uncertainty in multiple detections. This makes it difficult for the detection algorithm to reliably identify local patterns with deceptive intent, and significantly degrades real-time discrimination performance.
[0004] Because web pages involve mechanisms such as external script calls, asynchronous loading, and dynamic encapsulation during rendering, detection systems deal with a partially observable page model. The information gap between the visible and hidden parts causes a systematic shift in the analysis model built upon page structural relationships. This shift not only leads to an imbalance in the feature space but also increases the variance of the detection results over time. When systems prioritize real-time performance and shorten the sampling period, this contradiction between bias and variance becomes even more pronounced: sampling too early means key structures haven't yet appeared; waiting for loading to complete sacrifices response speed. Therefore, real-time detection faces a technical bottleneck between insufficient observation and response delay, becoming a critical technical challenge that urgently needs to be overcome in the field of fraudulent web page detection. Summary of the Invention
[0005] This invention provides a real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning, which solves the technical problems mentioned in the background art.
[0006] This invention provides a real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning, including:
[0007] S1. Render the target webpage using a webpage rendering tool, obtain a set of visual blocks through visual segmentation, and construct a visual adjacency graph based on the adjacency relationship of the visual blocks, with the visual blocks as nodes.
[0008] S2, identify the encapsulation boundary of the webpage, and filter out the boundary neighborhood edge set in the visual adjacency graph based on the graph distance from the node to the encapsulation boundary;
[0009] S3, calculate the discrete curvature of each edge in the visual adjacency graph, and obtain the anomaly index by the ratio of the negative curvature mass density of the boundary neighborhood edge set to the rest edge set;
[0010] S4. Construct a state vector based on the anomaly index and its statistics. Select micro-probe actions through a preset deep reinforcement learning strategy. Iteratively update the anomaly index and state vector until the strategy outputs a termination instruction and locks the current adjacency graph.
[0011] S5 constructs node and edge features based on an adjacency graph with locked discrete curvature, and inputs the anomaly index into a graph neural network. After message passing and feature reading, it outputs the probability of fraud risk.
[0012] The beneficial effects of this invention include: by introducing discrete curvature calculation into the visual adjacency graph established after webpage visual segmentation, and constructing an anomaly index using the ratio of negative curvature mass density of the boundary region to the internal region, combined with a deep reinforcement learning strategy for adaptive sampling and real-time updating of the webpage's dynamic rendering process, continuous perception of webpage structural changes and suppression of abnormal fluctuations are achieved, thereby significantly improving the real-time detection stability and discrimination accuracy of fraudulent webpages in complex dynamic environments. This invention, through the collaborative modeling of discrete curvature, anomaly index, and graph neural networks, extends the traditional static detection method into a dynamic geometric learning mechanism with self-learning and self-adjustment capabilities. It can effectively identify structurally abnormal webpages without relying on rule matching or prior templates, possessing comprehensive technical advantages such as low computational overhead, fast detection speed, strong real-time performance, and high robustness. Attached Figure Description
[0013] Figure 1 This is a flowchart of the real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning, as proposed in this invention. Detailed Implementation
[0014] The subject matter described herein will now be discussed with reference to exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and implement the subject matter described herein, and changes may be made to the function and arrangement of the elements discussed without departing from the scope of this specification. Various processes or components may be omitted, substituted, or added as needed in the examples. Furthermore, features described in some examples may be combined in other examples.
[0015] like Figure 1 As shown, a real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning includes:
[0016] S1. Render the target webpage using a webpage rendering tool, obtain a set of visual blocks through visual segmentation, and construct a visual adjacency graph based on the adjacency relationship of the visual blocks, with the visual blocks as nodes.
[0017] S2, identify the encapsulation boundary of the webpage, and filter out the boundary neighborhood edge set in the visual adjacency graph based on the graph distance from the node to the encapsulation boundary;
[0018] S3, calculate the discrete curvature of each edge in the visual adjacency graph, and obtain the anomaly index by the ratio of the negative curvature mass density of the boundary neighborhood edge set to the rest edge set;
[0019] S4. Construct a state vector based on the anomaly index and its statistics. Select micro-probe actions through a preset deep reinforcement learning strategy. Iteratively update the anomaly index and state vector until the strategy outputs a termination instruction and locks the current adjacency graph.
[0020] S5 constructs node and edge features based on an adjacency graph with locked discrete curvature, and inputs the anomaly index into a graph neural network. After message passing and feature reading, it outputs the probability of fraud risk.
[0021] In one embodiment of the present invention, a target webpage is rendered using a webpage rendering tool, a set of visual blocks is obtained through visual segmentation, and a visual adjacency graph is constructed using the visual blocks as nodes and based on the adjacency relationships of the visual blocks, including:
[0022] Use a web page rendering tool to render the target web page to obtain a visible layout for segmentation;
[0023] Perform visual segmentation on the visible layout to obtain a set of visual blocks;
[0024] Determine the bounding rectangle for each visual block and record the coordinates of the left, right, top, and bottom boundaries of each bounding rectangle;
[0025] Calculate the horizontal spacing between the bounding rectangles of the two visual blocks. The horizontal spacing is the larger of 0 and the difference between the left boundary coordinate of the first bounding rectangle and the right boundary coordinate of the second bounding rectangle. Then compare the larger of 0 and the difference between the left boundary coordinate of the second bounding rectangle and the right boundary coordinate of the first bounding rectangle with the maximum value obtained.
[0026] Calculate the vertical spacing between the bounding rectangles of the two visual blocks. The vertical spacing is the larger of 0 and the difference between the upper boundary coordinates of the first bounding rectangle and the lower boundary coordinates of the second bounding rectangle. Then compare the larger of 0 and the difference between the upper boundary coordinates of the second bounding rectangle and the lower boundary coordinates of the first bounding rectangle with the maximum value obtained.
[0027] Calculate the infinite norm distance between the bounding rectangles of two visual blocks. The infinite norm distance is the maximum value of the horizontal spacing and the vertical spacing.
[0028] When the infinite norm distance between the bounding rectangles of two different visual blocks is 0, an edge is established between the corresponding nodes of the two visual blocks to form an edge set.
[0029] A visual adjacency graph is constructed by using the set of visual blocks as nodes and the set of edges as edges.
[0030] Web page rendering tools are tools that can simulate a browser to parse web pages and output a visual structure (such as headless Chrome and PhantomJS). They need to support dynamic JS execution to restore the real page. The visible layout is the pixel-level page structure that the user can see after rendering, without hidden DOM elements (such as content with display:none).
[0031] Visual segmentation is the process of dividing a visible layout into independent units based on visual consistency (color, texture, boundary), which requires the use of VIPS (visual block segmentation) type algorithms; a visual block set is the set of independent visual units obtained after segmentation (such as a single button, a piece of text, or the pixel area corresponding to an image).
[0032] The circumscribed rectangle is the smallest rectangle that encloses all pixels of a single visual block; the coordinate reference is the top left corner of the page as the origin, the positive x-axis is horizontal to the right, and the positive y-axis is vertical downward; the left boundary coordinate is the x-value of the leftmost pixel of the rectangle, the right boundary coordinate is the x-value of the rightmost pixel of the rectangle, the top boundary coordinate is the y-value of the topmost pixel of the rectangle, and the bottom boundary coordinate is the y-value of the bottommost pixel of the rectangle.
[0033] The horizontal spacing is the minimum distance between two rectangles in the horizontal direction. If they overlap or touch in the horizontal direction, it is 0; otherwise, it is the width of the horizontal gap. Specifically, the first step is to calculate the first value, taking the larger value between 0 and (the left boundary coordinate of the first bounding rectangle minus the right boundary coordinate of the second bounding rectangle); the second step is to calculate the second value, taking the larger value between 0 and (the left boundary coordinate of the second bounding rectangle minus the right boundary coordinate of the first bounding rectangle); the third step is to set the horizontal spacing to the maximum value between the first value from the first step and the second value from the second step.
[0034] The vertical spacing is the minimum distance between two rectangles in the vertical direction. If they overlap or touch in the vertical direction, it is 0; otherwise, it is the vertical gap height. Specifically, the first step is to calculate the third value, taking the larger value between 0 and (the upper boundary coordinate of the first outer rectangle minus the lower boundary coordinate of the second outer rectangle); the second step is to calculate the fourth value, taking the larger value between 0 and (the upper boundary coordinate of the second outer rectangle minus the lower boundary coordinate of the first outer rectangle); the third step is to set the vertical spacing to the maximum value between the third value in the first step and the fourth value in the second step.
[0035] The infinite norm distance is an indicator that measures the overall adjacency of two rectangles, reflecting the maximum distance between them in the horizontal or vertical direction. A value of 0 indicates that the two rectangles are in contact or overlap in at least one direction. Specifically, the infinite norm distance is equal to the maximum value of the horizontal and vertical distances.
[0036] An edge set is a set of nodes (visual blocks) in a visual adjacency graph that represents the adjacency relationships between nodes (visual blocks). An edge is established only when two visual blocks are visually in contact or overlap.
[0037] A visual adjacency graph is a graph model of the visual structure of a webpage, where nodes correspond to visual blocks and edges correspond to the adjacency relationships between visual blocks.
[0038] In one embodiment of the present invention, identifying the encapsulation boundary of a webpage and filtering out a set of boundary neighborhood edges in the visual adjacency graph based on the graph distance from a node to the encapsulation boundary includes:
[0039] Extract the outer frame of the inline frame and the outer edge of the component host from the webpage rendering result to form a set of encapsulation boundaries;
[0040] For each encapsulation boundary element in the encapsulation boundary set, determine the bounding rectangle and record the left, right, top, and bottom boundary coordinates of the bounding rectangle for each encapsulation boundary element.
[0041] For each visual block in the visual block set, obtain the coordinates of the left boundary, right boundary, top boundary, and bottom boundary of the bounding rectangle of that visual block;
[0042] Calculate the lateral spacing between the outer rectangle of the visual block and the outer rectangle of each encapsulation boundary element: Calculate the first value, which is the larger of 0 and the difference between the left boundary coordinate of the visual block's outer rectangle and the right boundary coordinate of the encapsulation boundary element's outer rectangle; calculate the second value, which is the larger of 0 and the difference between the left boundary coordinate of the encapsulation boundary element's outer rectangle and the right boundary coordinate of the visual block's outer rectangle; the lateral spacing is the maximum of the first and second values;
[0043] Calculate the vertical spacing between the outer rectangle of the visual block and the outer rectangle of each encapsulation boundary element: Calculate the third value, which is the larger of 0 and the difference between the upper boundary coordinate of the visual block's outer rectangle and the lower boundary coordinate of the encapsulation boundary element's outer rectangle; calculate the fourth value, which is the larger of 0 and the difference between the upper boundary coordinate of the encapsulation boundary element's outer rectangle and the lower boundary coordinate of the visual block's outer rectangle; the vertical spacing is the maximum of the third and fourth values;
[0044] Calculate the infinite norm distance between the bounding rectangle of the visual block and the bounding rectangle of each encapsulation boundary element. The infinite norm distance is the maximum value of the corresponding horizontal and vertical spacing.
[0045] When there exists any encapsulation boundary element such that the infinite norm distance between the outer rectangle of the visual block and the outer rectangle of the encapsulation boundary element is 0, the node corresponding to the visual block is added to the edge node set.
[0046] In a visual adjacency graph, the graph distance between any two nodes is calculated. The graph distance is the number of edges contained in the shortest path between the two nodes.
[0047] For each node in the visual adjacency graph, calculate the graph distance from the node to the encapsulation boundary. The graph distance from the node to the encapsulation boundary is the minimum graph distance from the node to any node in the set of adjacent nodes.
[0048] For each edge in the visual adjacency graph, determine whether the minimum graph distance between the two endpoints of the edge and the encapsulation boundary is less than or equal to 1; if the minimum value is less than or equal to 1, add the edge to the boundary neighborhood edge set.
[0049] An inline frame is an iframe element in a webpage. Its outer frame is the visible rectangular boundary (including the area corresponding to the border and padding) of the iframe after the page is rendered. Specifically, the rectangular area returned by the getBoundingClientRect() method of the iframe tag is obtained through the DOM API of the rendering tool, and this area is the outer frame.
[0050] The component host is the shadowhost element of the ShadowDOM (such as a DOM node with the attachShadow() method). Its outer edge is the visual boundary of the shadowhost on the page (excluding the internal ShadowDOM content). Specifically, the outer edge is the rectangular area returned by the getBoundingClientRect() method of the shadowhost element obtained through the DOM API of the rendering tool.
[0051] The encapsulation boundary set is a collection of all extracted inline frame outlines and component host outlines, with each element corresponding to a visual boundary of an encapsulation structure.
[0052] The enclosing rectangle of a bounding element is the smallest rectangle that surrounds its outer frame / outer edge. The coordinate reference is the top left corner of the page as the origin, with the x-axis pointing to the right and the y-axis pointing downwards. The coordinates of the left / right / top / bottom boundaries are the x / y values of the leftmost / right / top / bottom pixels of the rectangle, respectively.
[0053] The horizontal spacing is the minimum horizontal distance between the visual block and the encapsulation boundary element. If they overlap or touch horizontally, the horizontal spacing is 0. Specifically, the first step is to calculate the first value, taking the larger of 0 and (the left boundary coordinate of the visual block minus the right boundary coordinate of the encapsulation boundary element). The second step is to calculate the second value, taking the larger of 0 and (the left boundary coordinate of the encapsulation boundary element minus the right boundary coordinate of the visual block). The third step is to set the horizontal spacing to the maximum value between the first value in the first step and the second value in the second step.
[0054] The vertical spacing is the minimum distance between the visual block and the encapsulation boundary element in the vertical direction. If they overlap or touch vertically, it is 0. Specifically, the first step is to calculate the third value, taking the larger value between 0 and (the upper boundary coordinate of the visual block minus the lower boundary coordinate of the encapsulation boundary element); the second step is to calculate the fourth value, taking the larger value between 0 and (the upper boundary coordinate of the encapsulation boundary element minus the lower boundary coordinate of the visual block); the third step is to set the vertical spacing to the maximum value between the third value in the first step and the fourth value in the second step.
[0055] The set of edge nodes is the set of all visual block nodes that are visually in contact with or overlap with at least one encapsulation boundary element (with an infinity norm distance of 0).
[0056] Graph distance is the number of edges in the shortest connected path between two nodes in a visual adjacency graph. If the two nodes are not connected, the graph distance is recorded as infinity. Specifically, a breadth-first search algorithm is used to traverse the adjacent nodes layer by layer, starting from one of the nodes, and record the number of edges traversed when reaching the other node. This number of edges is the graph distance.
[0057] The graph distance from a node to the encapsulation boundary is the graph distance from the node to the nearest node in the set of adjacent nodes, reflecting the graph structural distance between the node and the encapsulation boundary. Specifically, the first step is to calculate the graph distance from the node to each node in the set of adjacent nodes (according to the graph distance calculation method); the second step is to find that the graph distance from the node to the encapsulation boundary is equal to the minimum value among these graph distances; if the set of adjacent nodes is empty, the graph distance is recorded as infinity.
[0058] The boundary neighborhood edge set is the set of edges in the visual adjacency graph whose endpoints are close to the encapsulation boundary (graph distance to the encapsulation boundary ≤ 1).
[0059] In one embodiment of the present invention, calculating the discrete curvature of each edge of the visual adjacency graph includes:
[0060] For each edge in the visual adjacency graph, determine that the two endpoints of the edge are the first node and the second node, respectively;
[0061] Calculate the degree of the first node by counting the number of all edges connected to the first node in the visual adjacency graph to obtain the degree of the first node;
[0062] Calculate the degree of the second node by counting the number of all edges connected to the second node in the visual adjacency graph to obtain the degree of the second node;
[0063] Calculating the number of shared triangles includes: finding all nodes in the visual adjacency graph that are connected to both the first node and the second node, counting the number of these nodes, and obtaining the number of shared triangles;
[0064] Set the basic term constant to four and the trigonometric weighting constant to three;
[0065] The discrete curvature is calculated by subtracting the degree of the first node from the basic constant, then subtracting the degree of the second node, and finally adding the product of the triangular weighting constant and the number of shared triangles to obtain the discrete curvature of the edge.
[0066] The first node and the second node are two different nodes connected by an edge in the visual adjacency graph, each corresponding to two independent visual blocks. The node identities can be arbitrarily assigned (without any order requirement).
[0067] The degree of the first node is the total number of edges in the visual adjacency graph that have the first node as an endpoint, reflecting the density of the node's adjacency. Specifically, by traversing all edges in the visual adjacency graph and counting the number of edges that have the first node as an endpoint, this number is the degree of the first node.
[0068] The degree of the second node is the total number of edges in the visual adjacency graph that have that node as an endpoint. The calculation logic is exactly the same as that of the first node. Specifically, all edges in the visual adjacency graph are traversed, and the number of edges that include the second node as an endpoint is counted. This number is the degree of the second node.
[0069] The shared triangle number is the total number of nodes that are simultaneously adjacent to both the first and second nodes (connected by edges). Each shared node forms a triangle structure with the first and second nodes (the three nodes are connected in pairs), and the shared node does not include the first and second nodes themselves. Specifically, the first step is to obtain the set of all nodes connected to the first node and the set of all nodes connected to the second node, respectively. The second step is to find the intersection of the two sets (the nodes that exist in both sets). The third step is to count the number of nodes in the intersection, which is the shared triangle number.
[0070] The fundamental constant is the basic offset for calculating discrete curvature. It is used to balance the negative influence of node degree on curvature, so that the curvature value can effectively distinguish between normal and abnormal structures. Specifically, it is determined by training on visual adjacency graph data of fraudulent and normal web pages. The curvature difference between abnormal and normal regions is most significant at this value. If it is adapted to specific web page types such as e-commerce and finance, it can be adjusted within the range of three to five.
[0071] The triangular weighting constant is a coefficient that enhances the positive contribution of the number of shared triangles to curvature, used to highlight the impact of local dense connections (triangular structures) on the stability of the graph structure. Specifically, through comparative experiments, it is verified that when the value is three, it can suppress the interference of isolated nodes to the greatest extent and accurately capture the structural defects at the encapsulation boundary. If dealing with highly complex web pages (such as multiple nested iframes), it can be adjusted within the range of two to four.
[0072] Discrete curvature is an index that quantifies the regularity of the local graph structure where the edge is located. A negative value indicates a loose structure (possibly with abnormal defects), while a positive value indicates a dense structure (normal). Specifically, discrete curvature equals the basic constant minus the degree of the first node, minus the degree of the second node, and finally added to the result (triangular weighting constant multiplied by the number of shared triangles).
[0073] In one embodiment of the present invention, an anomaly index is obtained by the ratio of the negative curvature mass density of the boundary neighborhood edge set to that of the remaining edge sets, including:
[0074] Determine the remaining edge set, which is the set of edges remaining after removing the boundary neighborhood edge set from the visual adjacency edge set of the visual adjacency graph;
[0075] For each edge in the visual adjacent edge set, obtain the discrete curvature of the edge and calculate the negative curvature unit of the edge, including: taking the negative value of the discrete curvature of the edge and taking the larger value between the negative value and zero as the negative curvature unit of the edge.
[0076] The total negative curvature mass of the boundary neighborhood edge set is calculated by summing the negative curvature units corresponding to each edge in the boundary neighborhood edge set.
[0077] Calculate the total negative curvature mass of the remaining edge set, including: summing the negative curvature units corresponding to each edge in the remaining edge set to obtain the total negative curvature mass of the remaining edge set;
[0078] Calculating the negative curvature mass density of the boundary neighborhood edge set includes: counting the number of edges in the boundary neighborhood edge set, and dividing the total negative curvature mass of the boundary neighborhood edge set by this number to obtain the negative curvature mass density of the boundary neighborhood edge set.
[0079] The calculation of the negative curvature mass density of the remaining edge set includes: counting the number of edges in the remaining edge set, dividing the total negative curvature mass of the remaining edge set by the number of edges to obtain the negative curvature mass density of the remaining edge set; and setting a stability constant, the value of which is 10 to the power of negative 6.
[0080] The anomaly index is calculated by dividing the negative curvature mass density of the boundary neighborhood edge set by the sum of the negative curvature mass density of the remaining edge sets and the stability constant.
[0081] The remaining edge set is the set of edges from non-boundary neighborhoods in the visual adjacency graph, corresponding to the visual block association relationships within the webpage's inner domain (far from the encapsulation boundary). It is used to contrast with the edge set of the boundary neighborhood and highlight structural anomalies.
[0082] Negative curvature units are indicators that filter and quantify the negative curvature contribution of edges, retaining only the absolute value when the discrete curvature is negative (the negative curvature unit is zero when the discrete curvature is positive), and are used to focus on edges with loose structures. Specifically, the first step is to take the negative value of the discrete curvature of the edge; the second step is to compare the size of the negative value with zero; the third step is to take the larger value of the two, which is the negative curvature unit of the edge.
[0083] The total negative curvature mass of the boundary neighborhood edge set is obtained by summing the negative curvature units corresponding to all edges in the boundary neighborhood edge set. Specifically, the total negative curvature mass of the boundary neighborhood edge set is the sum of the negative curvature units of all edges in the boundary neighborhood, reflecting the overall looseness of the boundary region structure. Specifically, each edge in the boundary neighborhood edge set is traversed, the negative curvature units of each edge are obtained, and all negative curvature units are added together. The sum obtained is the total negative curvature mass of the boundary neighborhood edge set.
[0084] The total negative curvature mass of the remaining edge set is the sum of the negative curvature units of all edges in the inner domain edge set, reflecting the overall looseness of the inner domain structure; specifically, traversing each edge in the remaining edge set, obtaining the negative curvature units of each edge, and adding all the negative curvature units together, the sum is the total negative curvature mass of the remaining edge set.
[0085] The negative curvature mass density of the boundary neighborhood edge set is the average negative curvature contribution of a unit edge within the boundary neighborhood. It eliminates the influence of differences in the number of edges on the total amount and facilitates comparison with the inner region. Specifically, the first step is to count the total number of edges in the boundary neighborhood edge set. The second step is to divide the total negative curvature mass of the boundary neighborhood edge set by this number. The result is the negative curvature mass density of the boundary neighborhood edge set.
[0086] The negative curvature mass density of the remaining edge set is the average negative curvature contribution per unit edge in the interior domain, serving as a benchmark for boundary density comparison. Specifically, the first step is to count the total number of edges in the remaining edge set; the second step is to divide the total negative curvature mass of the remaining edge set by this number, and the result is the negative curvature mass density of the remaining edge set.
[0087] The stability constant is a tiny value that avoids the division becoming meaningless due to the negative curvature mass density of the remaining edge sets being zero, while not affecting the calculation accuracy of the density ratio. Specifically, through experimental verification, when the value is 10 to the power of -6, it can completely avoid the division-to-zero error and ensure that the error in the anomaly index calculation is less than 0.001%, which is suitable for more than 99% of web page scenarios. If dealing with web pages with extremely sparse inner domains (such as a single iframe accounting for more than 80%), it can be adjusted to 10 to the power of -5, and the error can still be kept within 0.01%.
[0088] It should be noted that the anomaly index is used to quantify the degree of structural anomaly at the encapsulation boundary of a fraudulent webpage (such as the outer frame of a cross-domain iframe or the outer edge of the host of a ShadowDOM component). Essentially, it describes the relative amplification factor of structural looseness caused by unobservable coupling edges (such as DOM structure breakage caused by cross-domain issues or internal associations obscured by component encapsulation) by comparing the negative curvature quality density of the neighborhood edge set of the encapsulation boundary with that of the webpage's inner domain edge set. Specifically, the anomaly index uses the negative curvature mass density of the boundary neighborhood edge set (the average structural looseness contribution per unit edge; the more concentrated the negative curvature, the higher the density, reflecting a looser structure) as the numerator, and the sum of the negative curvature mass density of the inner domain edge set and the stability constant (to avoid division by zero errors when the inner domain density is zero; it is taken as 10 to the power of -6, which does not affect the calculation accuracy) as the denominator. This ratio eliminates the interference of differences in the overall complexity of the webpage. For example, in normal webpages, the structural looseness of the boundary and the inner domain is similar, and the anomaly index is usually less than 1.5. However, fraudulent webpages often hide key structures through cross-domain iframes and other means, resulting in a concentration of negative curvature in the boundary neighborhood (severe structural defects), and the anomaly index is often greater than 3.0. The larger the anomaly index, the more significant the structural defects in the boundary region, and the higher the risk of the webpage being fraudulent.
[0089] In one embodiment of the present invention, a state vector is constructed based on anomaly indices and their statistics, including:
[0090] Set the current moment of continuous sampling as the time step;
[0091] The anomaly index calculated at each time step is determined as the anomaly index of the corresponding time step.
[0092] The initial sampling time is selected as the zero time step, the anomaly index calculated at the zero time step is used as the initial exponential moving average of the anomaly index, and zero is set as the initial exponential moving absolute deviation of the anomaly index.
[0093] Set a smoothing coefficient, the value of which is greater than zero and less than or equal to one;
[0094] For each target time step after the zero time step, calculate the exponential moving average of that target time step, including: first, calculate a first difference by subtracting the smoothing coefficient; multiply the first difference by the exponential moving average of the previous time step to obtain a first product; then multiply the smoothing coefficient by the outlier exponent of that target time step to obtain a second product; add the first product and the second product to obtain the exponential moving average of that target time step.
[0095] The calculation of the exponential moving absolute deviation of the target time step includes: first, calculating the difference between the abnormal exponent of the target time step and the exponential moving mean of the previous time step, and taking the absolute value of the difference to obtain the absolute value of the deviation; then multiplying the first difference by the exponential moving absolute deviation of the previous time step to obtain the third product; multiplying the absolute value of the deviation by the smoothing coefficient to obtain the fourth product; and adding the third product and the fourth product to obtain the exponential moving absolute deviation of the target time step.
[0096] Extract the anomaly index, the exponential moving mean, and the exponential moving absolute deviation of the target time step in sequence to form the state vector of the target time step.
[0097] A time step is a unit of time for continuous sampling during the dynamic rendering process of a webpage. Each time step corresponds to a complete cycle of webpage rendering and anomaly index calculation, and is used to track the temporal changes of the anomaly index.
[0098] The zero time step is the starting moment of continuous sampling, corresponding to the moment when the webpage is first rendered and the first anomaly index is calculated.
[0099] The initial exponential moving average is the outlier exponential value at time step zero.
[0100] The initial exponential sliding absolute deviation is the deviation baseline value set at the zero time step (with a value of zero). Since there is no mean value from the previous time step at the zero time step, the actual deviation cannot be calculated. Therefore, it is set to zero to start the subsequent time series calculation.
[0101] The smoothing coefficient is a parameter that controls the weight of time-series statistics (moving mean, absolute deviation) on the current abnormal index and historical statistics. The larger the value, the stronger the influence of the current data (the faster the response), and the smaller the value, the stronger the influence of historical data (the higher the stability). Specifically, based on the dynamic rendering characteristics of web pages, a smoothing coefficient of 0.3-0.7 is used in normal scenarios (0.3-0.5 for static web pages and 0.5-0.7 for dynamically loaded web pages). Within this range, the statistics can both track index changes and suppress instantaneous fluctuations.
[0102] The target time step is any sampling moment after the zero time step (such as time steps 1, 2, 3...N). The moving average and moving absolute deviation at this moment need to be calculated to construct the time series state.
[0103] The exponential moving average of the target time step is the average value after time-series smoothing of the outlier index, reflecting the overall trend of the outlier index and suppressing instantaneous noise. Specifically, the first step is to calculate the result by subtracting the smoothing coefficient, which is recorded as the first difference. The second step is to multiply the first difference by the exponential moving average of the previous time step, which is recorded as the first product. The third step is to multiply the smoothing coefficient by the outlier index of the current target time step, which is recorded as the second product. The fourth step is to add the first product and the second product together, and the result is the exponential moving average of the target time step.
[0104] The first difference is the complementary value of the smoothing coefficient, representing the weight of the historical statistic (the moving mean / absolute deviation of the previous time step) in the calculation of the current statistic; specifically, the first difference is equal to one minus the smoothing coefficient.
[0105] The first product is the weighted contribution of historical statistics (the moving average at the previous time step) to the calculation of the current moving average; specifically, the first product equals the first difference multiplied by the exponential moving average of the previous time step.
[0106] The second product is the weighted contribution of the current data (the anomaly index at the target time step) to the calculation of the current moving average; specifically, the second product equals the smoothing coefficient multiplied by the anomaly index at the target time step.
[0107] The exponential moving absolute deviation of the target time step is a time-series smoothed value of the deviation between the outlier exponent and the moving mean, reflecting the stability of the outlier exponent's fluctuations. Specifically, the first step is to calculate the difference between the outlier exponent of the target time step and the exponential moving mean of the previous time step, and take the absolute value of this difference as the absolute deviation value. The second step is to multiply the first difference by the exponential moving absolute deviation of the previous time step, and take the third product. The third step is to multiply the absolute deviation value by the smoothing coefficient, and take the fourth product. The fourth step is to add the third product and the fourth product together, and the result is the exponential moving absolute deviation of the target time step.
[0108] The absolute value of the deviation is the absolute difference between the current anomaly index and the historical smoothed mean. It is used to measure the fluctuation range of single-step data and avoid the cancellation of positive and negative deviations. Specifically, the absolute value of the deviation is equal to the absolute value of the difference between the anomaly index of the target time step and the exponential moving mean of the previous time step.
[0109] The third product is the weighted contribution of historical statistics (the previous time step's sliding absolute deviation) to the current sliding absolute deviation calculation; specifically, the third product equals the first difference multiplied by the exponential sliding absolute deviation of the previous time step.
[0110] The fourth product is the weighted contribution of the current fluctuation data (absolute value of deviation) in the current sliding absolute deviation calculation; specifically, the fourth product equals the smoothing coefficient multiplied by the absolute value of deviation.
[0111] The state vector is a combination of temporal features used to input a deep reinforcement learning (DRL) policy. It includes the current value, trend value, and fluctuation value, allowing the policy to simultaneously perceive the current level, trend, and stability of the anomaly index, thereby improving the accuracy of action selection.
[0112] In one embodiment of the present invention, a micro-probe action is selected by a preset deep reinforcement learning strategy, and the anomaly index and state vector are updated iteratively until the strategy outputs a termination instruction and locks the current adjacency graph, including:
[0113] Set a set of micro-probe actions, which includes four actions: viewport width increase, viewport width decrease, brief wait, and submit termination.
[0114] Set a preset deep reinforcement learning strategy, which is a function that maps the state vector of the current time step to any action in the set of micro-probe actions;
[0115] Set the viewport width to the webpage viewport width corresponding to the current time step, set the adjustment step size to a fixed increment and the value of the adjustment step size to be greater than zero, and set the waiting time to a fixed time and the waiting time to be greater than zero.
[0116] The loop process is executed, and the loop process is as follows:
[0117] D1 maps the state vector of the current time step to the target action selected at the current time step by using a preset deep reinforcement learning strategy.
[0118] D2, execute the target action of the current time step and update the viewport width, including: if the target action is to increase the viewport width, add the viewport width of the current time step to the adjustment step size to obtain the viewport width of the next time step; if the target action is to decrease the viewport width, subtract the adjustment step size from the viewport width of the current time step to obtain the viewport width of the next time step; if the target action is a short wait, maintain the viewport width of the current time step as the viewport width of the next time step and maintain the wait duration; if the target action is to submit and terminate, do not update the viewport width.
[0119] D3, determine whether the target action of the current time step is to commit to termination;
[0120] D4. If the target action is not a submission termination, re-render and visually segment the target webpage within the viewport width of the next time step to construct the visual adjacency graph of the next time step; calculate the anomaly index and the exponential moving average and absolute deviation of the exponential moving average of the next time step to construct the state vector of the next time step; set the next time step as the new current time step and return to D1 to re-execute.
[0121] D5. If the target action is to submit and terminate, stop the loop process and determine the visual adjacency graph corresponding to the current time step as the locked adjacency graph.
[0122] The micro-probe action set is the complete set of actions that can be selected by the deep reinforcement learning strategy. It is used to dynamically adjust the rendering state of the webpage to stabilize the anomaly index. The four actions correspond to three types of functions: actively adjusting the display range, waiting for dynamic loading, terminating optimization, etc., covering adaptation scenarios of dynamic changes in webpages.
[0123] Increasing the viewport width is an action that increases the width of the webpage rendering viewport. This is used to trigger responsive layout changes on the webpage, expose encapsulation boundaries or visual blocks that are not displayed due to insufficient width, and avoid missing hidden cross-domain iframes.
[0124] Lowering the viewport width is an action to reduce the width of the webpage rendering viewport. It is used to verify the stability of the encapsulation boundary in narrow screen mode and to eliminate abnormal index misjudgments caused by excessive stretching in wide screens.
[0125] A short wait is an action that keeps the viewport width constant and waits for a fixed duration. It is used to adapt to asynchronous loading of web pages (such as lazy-loaded iframes and dynamic scripts) and ensures that the abnormal index is calculated only after the dynamic content is rendered, thus avoiding index fluctuations caused by incomplete loading.
[0126] Submitting to terminate is an action that stops the loop optimization and locks the current visual adjacency graph. It is used to terminate sampling after the anomaly index stabilizes, balancing the real-time performance and accuracy of detection, and avoiding excessive iteration that consumes resources.
[0127] The preset deep reinforcement learning strategy is a model that has the ability to map states to actions after training. The core objective is to select micro-probe actions to make the anomaly index stabilize quickly. It is trained using DQN (Deep Q Network) or PPO (Proximal Policy Optimization) algorithms. The training data consists of 100,000 sets of temporal state-action-reward data for fraudulent and normal web pages. The reward function is set as -anomaly index sliding absolute deviation (the smaller the deviation, the higher the reward).
[0128] The adjustment step size is a fixed increment (unit: pixels) when the viewport width is adjusted up / down. It is used to control the width adjustment range, avoiding drastic layout changes due to an excessively large step size or inefficient iteration due to an excessively small step size. Specifically, based on common screen resolution differences (1920 / 1366 / 1024 pixels), the usual value is 50-200 pixels. The initial width is 200 pixels for 1920 pixels, 150 pixels for 1366 pixels, and 100 pixels for 1024 pixels. Specifically, the adjustment step size is set according to the initial viewport width: 200 pixels when the initial width is ≥1920 pixels, 150 pixels when the initial width is ≤1366 and <1920 pixels, and 100 pixels when the initial width is <1366 pixels.
[0129] The waiting time is the duration of a short waiting action (in milliseconds) used to ensure that asynchronous content on a webpage is loaded. Specifically, it is used to calculate the average loading time of dynamic webpages (including iframes and AJAX loading), with a typical value of 100-500 milliseconds. For webpages containing cross-domain iframes, the waiting time is 300-500 milliseconds, and for purely static webpages, it is 100-200 milliseconds. Specifically, the waiting time is set according to the webpage type: 300-500 milliseconds when a cross-domain iframe is detected, and 100-200 milliseconds when no cross-domain iframe is detected.
[0130] The loop process is a logic that dynamically optimizes the anomaly index through a deep reinforcement learning strategy. It runs in the order of selecting an action → executing the action → determining termination → updating the state → looping until the anomaly index stabilizes.
[0131] The target action is the optimal micro-probe action output by the policy at the current time step, which is determined by the state vector (anomaly index, moving mean, and moving absolute deviation). Actions that can reduce the fluctuation of the anomaly index are given priority.
[0132] The viewport width of the next time step is the width used for re-rendering the webpage after the target action is executed, and it is dynamically adjusted according to the action type. Specifically, if the target action is to increase the viewport width, the viewport width of the next time step is equal to the viewport width of the current time step plus the adjustment step size; if the target action is to decrease the viewport width, the viewport width of the next time step is equal to the viewport width of the current time step minus the adjustment step size; if the target action is a short wait, the viewport width of the next time step is equal to the viewport width of the current time step; if the target action is to submit and terminate, the viewport width of the next time step is not calculated.
[0133] The locked adjacency graph is the final visual adjacency graph determined after the anomaly index stabilizes.
[0134] In one embodiment of the present invention, node and edge features are constructed based on an adjacency graph with locked discrete curvature, and an anomaly index is input into a graph neural network. After message passing and feature reading, the probability of fraud risk is output, including:
[0135] Get the set of locked nodes and the set of locked edges corresponding to the locked adjacency graph;
[0136] For each edge in the locked edge set, obtain the discrete curvature corresponding to the edge, and determine the discrete curvature as the edge feature of the edge;
[0137] For each node in the locked set of nodes, count the degree of the node, sum the discrete curvatures of all the adjacent edges of the node to obtain the curvature sum value, and divide the curvature sum value by the degree of the node to obtain the node feature of the node.
[0138] Extract the anomaly index calculated at the time step corresponding to the submission termination action, and determine the anomaly index as a graph-level attribute;
[0139] The number of layers in the graph neural network is set to a positive integer. A weight matrix is set for each layer of the graph neural network. The modified linear unit is set to a non-linear function, which takes the larger value between the input value and zero. A temperature coefficient is set and the value of the temperature coefficient is greater than zero.
[0140] Use the node features of each node as the initial features of that node in the first layer of the graph neural network;
[0141] For each layer in the graph neural network, the attention weight corresponding to each edge of that layer is calculated, including: first, calculating the product of the discrete curvature and the temperature coefficient of the edge, and obtaining the natural exponent value corresponding to the product; then, accumulating the natural exponent values corresponding to all adjacent edges of the node to which the current edge belongs; and dividing the natural exponent value corresponding to the current edge by the accumulated value to obtain the attention weight corresponding to the edge.
[0142] Update the features of each node in the layer, including: for each node, accumulate the attention weights corresponding to each adjacent edge of the node, the product of the previous layer features of the node at the other end of the edge and the corresponding layer weight matrix, and input the accumulated result into the modified linear unit to obtain the features of the current layer of the node;
[0143] After completing the feature update of all layers, count the total number of nodes in the locked node set, sum the features of the last layer of all nodes to obtain the total feature value, and divide the total feature value by the total number of nodes to obtain the readout vector;
[0144] The readout vector is concatenated with the graph-level attributes to obtain the connection vector;
[0145] Define a weight vector and a bias scalar, calculate the product of the weight vector and the connection vector, and add the product to the bias scalar to obtain the combined value;
[0146] Calculate the negative composite value of the Natural Index, divide 1 by the sum of 1 and the Natural Index value, and obtain the probability of the target webpage being involved in fraud.
[0147] The locked node set is the set of all nodes in the locked visual adjacency graph, and each node corresponds to the visual block obtained by the final segmentation after the webpage is stabilized.
[0148] The locked edge set is the set of all edges in the locked visual adjacency graph, and each edge corresponds to the adjacency relationship between two visual blocks.
[0149] Node features are an index that averages the discrete curvature of the adjacent edges of a node, reflecting the degree of anomaly in the overall structure around the node. Specifically, the first step is to count the degree of the node; the second step is to sum the discrete curvature of all the adjacent edges of the node to obtain the cumulative curvature value; the third step is to divide the cumulative curvature value by the degree of the node, and the result is the node feature.
[0150] The number of layers in a graph neural network is the number of times features are passed and abstracted. Too few layers cannot capture deep structural relationships, while too many layers can easily lead to gradient vanishing. Specifically, based on the verification of 50,000 sets of fraudulent / normal web page data, the conventional value is 2-4 layers. 2 layers are suitable for simple web pages (single iframe / no ShadowDOM), and 4 layers are suitable for complex web pages (multiple nested iframes).
[0151] The weight matrix is a parameter matrix used for feature transformation in each layer of a graph neural network. Its dimension is the feature dimension of the current layer × the feature dimension of the next layer. It is used to map node features to a higher-dimensional space to capture complex relationships. Specifically, Xavier initialization is used (initial values are calculated according to the feature dimension to avoid gradient vanishing). For example, if the input feature dimension is 1 (node features) and the next layer dimension is 64, then the weight matrix dimension is 1×64. The initial values are randomly sampled from a normal distribution with a mean of 0 and a variance of 2 / (1+64).
[0152] The Corrected Linear Unit (ReLU) is a function that introduces nonlinear feature transformation to address the problem that linear models cannot fit complex structural anomalies. During computation, negative values in the input are discarded, and positive values are retained.
[0153] The temperature coefficient is a parameter that adjusts the smoothness of the attention weight distribution. The smaller the value, the more significant the weight difference (focusing on abnormal edges), and the larger the value, the more uniform the weight (avoiding overfitting). Specifically, the normal value is 0.1-1.0, 0.3-0.5 is used when detecting fraudulent web pages (enhancing the weight of abnormal edges), and 0.7-1.0 is used when detecting normal web pages (reducing false positives).
[0154] The initial features are the input features of the first layer of the graph neural network. The node features are directly used without any additional transformation. The initial features are associated with the degree of anomaly in the surrounding structure of the node.
[0155] Attention weight is an indicator that measures the importance of an edge in feature propagation. The smaller the discrete curvature (the looser the structure), the greater the weight, so that the features of abnormal edges are propagated first. Specifically, the first step is to calculate the product of the discrete curvature and the temperature coefficient of the edge; the second step is to calculate the natural exponent value of the product; the third step is to accumulate the natural exponent values of all adjacent edges of the node to which the current edge belongs; the fourth step is to divide the natural exponent value of the current edge by the accumulated value, and the result is the attention weight of the edge.
[0156] The updated node features are abstract features that integrate the features of adjacent nodes and the importance of edges, and can capture abnormal correlations in local structures. Specifically, the first step is to calculate the result of (the attention weight of the edge) multiplied by (the previous layer feature of the node at the other end of the edge) multiplied by (the weight matrix of the corresponding layer) for each adjacent edge of the node. The second step is to accumulate the above results for all adjacent edges to obtain the accumulated result. The third step is to input the accumulated result into the corrected linear unit, and the output result is the feature of the current layer of the node.
[0157] The readout vector is a global aggregation of the final features of all nodes, reflecting the deep structural features of the entire graph. Specifically, the first step is to count the total number of nodes in the locked node set; the second step is to accumulate the features of the last layer of all nodes to obtain the total feature value; the third step is to divide the total feature value by the total number of nodes, and the result is the readout vector.
[0158] The connection vector is a feature that integrates local aggregation features (readout vector) and global anomaly indicators (graph-level attributes). It is used to supplement global structural information and avoid losing the overall anomaly tendency by relying solely on node aggregation. Specifically, it is concatenated according to feature dimensions. For example, if the readout vector dimension is 64 and the graph-level attribute dimension is 1, then the connection vector dimension is 65.
[0159] The weight vector is a parameter vector used by the output layer of a graph neural network to map connection vectors to single values. Its dimension is the same as that of the connection vectors and it is used to synthesize all the features of the connection vectors. Specifically, it is initialized using He (adapted to the ReLU activation function). For example, if the dimension of the connection vector is 65, then the dimension of the weight vector is 65×1. The initial values are randomly sampled from a normal distribution with a mean of 0 and a variance of 2 / 65.
[0160] The bias scalar is a parameter used by the output layer to adjust the baseline of the composite value, avoiding the offset caused by the weight vector relying solely on the feature dimension; specifically, the initial value is set to 0.1 (based on the risk probability distribution of fraudulent web pages for calibration, reducing the initial bias).
[0161] The composite value is an intermediate result after linear transformation of the connection vector, which is used to calculate the risk probability in subsequent calculations. Specifically, the first step is to calculate the product of the weight vector and the connection vector (multiplying the corresponding dimensions and then summing them); the second step is to add the product to the bias scalar, and the result is the composite value.
[0162] The probability of being involved in fraud is an indicator that quantifies the likelihood of a webpage being involved in fraud. It ranges from 0 to 1, with a higher value indicating a higher risk. Specifically, the first step is to calculate the negative composite value of the natural index (i.e., calculate the natural index after taking the negative of the composite value); the second step is to divide 1 by (the sum of 1 and the natural index value), and the result is the probability of being involved in fraud.
[0163] It should be noted that the pre-training process of the graph neural network aims to learn general webpage structural features and reduce the difficulty of fine-tuning fraud detection. The specific process includes: First, constructing a pre-training dataset, collecting locked adjacency graphs of over 100,000 normal webpages covering news, e-commerce, finance, and other fields, as well as a small number of webpages labeled as fraudulent. For each graph, extract node features (mean of discrete curvature of adjacent edges), edge features (discrete curvature), and graph-level attributes (anomaly index), ensuring that the data covers different structural scenarios such as single iframes and multi-nested ShadowDOMs. Second, designing self-supervised pre-training tasks, including node-level mask feature recovery (randomly masking 30% of node features, allowing the GNN to predict mask values through adjacent edge features and graph-level attributes), and edge-level adjacency relationship prediction (randomly masking 30% of node features, allowing the GNN to predict mask values through adjacent edge features and graph-level attributes), and edge-level adjacency relationship prediction (randomly masking 30% of node features, allowing the GNN to predict mask values through adjacent edge features and graph-level attributes). The algorithm first removes 10% of edges, allowing the GNN to determine edge existence based on end-node features and local curvature. Then, it performs graph-level webpage classification (classifying webpages into 5 domains, without fraud labels, allowing the GNN to learn structural commonalities across different domains). Next, it initializes the GNN parameters (using Xavier for the weight matrix, He for the weight vector, and a temperature coefficient of 0.4), employing the Adam optimizer with the weighted sum of mask loss (MSE), adjacency prediction loss (cross-entropy), and type classification loss (cross-entropy) as the objective function. It iteratively trains on the pre-training dataset, updating parameters in each round until the loss value changes by less than 0.001 for 10 consecutive rounds (convergence). Finally, it saves the pre-trained GNN model (including weight matrices for each layer and the temperature coefficient).
[0164] The embodiments of this example have been described above. However, this example is not limited to the specific implementation methods described above. The specific implementation methods described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms based on the guidance of this example, and all of them are within the protection scope of this example.
Claims
1. A real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning, characterized in that, include: S1. Render the target webpage using a webpage rendering tool, obtain a set of visual blocks through visual segmentation, and construct a visual adjacency graph based on the adjacency relationship of the visual blocks, with the visual blocks as nodes. S2, identify the encapsulation boundary of the webpage, and filter out the boundary neighborhood edge set in the visual adjacency graph based on the graph distance from the node to the encapsulation boundary; S3 calculates the discrete curvature of each edge in the visual adjacency graph. The anomaly index is obtained by comparing the negative curvature quality density of the boundary neighborhood edge set with that of the remaining edge sets. This index includes: For each edge in the visual adjacency graph, determine that the two endpoints of the edge are the first node and the second node, respectively; Calculate the degree of the first node by counting the number of all edges connected to the first node in the visual adjacency graph to obtain the degree of the first node; Calculate the degree of the second node by counting the number of all edges connected to the second node in the visual adjacency graph to obtain the degree of the second node; Calculating the number of shared triangles includes: finding all nodes in the visual adjacency graph that are connected to both the first node and the second node, counting the number of these nodes, and obtaining the number of shared triangles; Set the basic term constant to four and the trigonometric weighting constant to three; The discrete curvature is calculated by subtracting the degree of the first node from the basic constant, then subtracting the degree of the second node, and finally adding the product of the triangular weighting constant and the number of shared triangles to obtain the discrete curvature of the edge. Determine the remaining edge set, which is the set of edges remaining after removing the boundary neighborhood edge set from the visual adjacency edge set of the visual adjacency graph; For each edge in the visual adjacent edge set, obtain the discrete curvature of the edge and calculate the negative curvature unit of the edge, including: taking the negative value of the discrete curvature of the edge and taking the larger value between the negative value and zero as the negative curvature unit of the edge. The total negative curvature mass of the boundary neighborhood edge set is calculated by summing the negative curvature units corresponding to each edge in the boundary neighborhood edge set. Calculate the total negative curvature mass of the remaining edge set, including: summing the negative curvature units corresponding to each edge in the remaining edge set to obtain the total negative curvature mass of the remaining edge set; Calculating the negative curvature mass density of the boundary neighborhood edge set includes: counting the number of edges in the boundary neighborhood edge set, and dividing the total negative curvature mass of the boundary neighborhood edge set by this number to obtain the negative curvature mass density of the boundary neighborhood edge set. The calculation of the negative curvature mass density of the remaining edge set includes: counting the number of edges in the remaining edge set, dividing the total negative curvature mass of the remaining edge set by the number of edges to obtain the negative curvature mass density of the remaining edge set; and setting a stability constant, the value of which is 10 to the power of negative 6. The anomaly index is calculated by dividing the negative curvature mass density of the boundary neighborhood edge set by the sum of the negative curvature mass density of the remaining edge sets and the stability constant. S4. Construct a state vector based on the anomaly index and its statistics. Select micro-probe actions through a preset deep reinforcement learning strategy. Iteratively update the anomaly index and state vector until the strategy outputs a termination instruction and locks the current adjacency graph. S5 constructs node and edge features based on an adjacency graph with locked discrete curvature, and inputs the anomaly index into a graph neural network. After message passing and feature reading, it outputs the probability of fraud risk.
2. The real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning according to claim 1, characterized in that, The target webpage is rendered using a webpage rendering tool. A set of visual blocks is obtained through visual segmentation. A visual adjacency graph is constructed using these visual blocks as nodes and based on their adjacency relationships. This graph includes: Use a web page rendering tool to render the target web page to obtain a visible layout for segmentation; Perform visual segmentation on the visible layout to obtain a set of visual blocks; Determine the bounding rectangle for each visual block and record the coordinates of the left, right, top, and bottom boundaries of each bounding rectangle; Calculate the horizontal spacing between the bounding rectangles of the two visual blocks. The horizontal spacing is the larger of 0 and the difference between the left boundary coordinate of the first bounding rectangle and the right boundary coordinate of the second bounding rectangle. Then compare the larger of 0 and the difference between the left boundary coordinate of the second bounding rectangle and the right boundary coordinate of the first bounding rectangle with the maximum value obtained. Calculate the vertical spacing between the bounding rectangles of the two visual blocks. The vertical spacing is the larger of 0 and the difference between the upper boundary coordinates of the first bounding rectangle and the lower boundary coordinates of the second bounding rectangle. Then compare the larger of 0 and the difference between the upper boundary coordinates of the second bounding rectangle and the lower boundary coordinates of the first bounding rectangle with the maximum value obtained. Calculate the infinite norm distance between the bounding rectangles of two visual blocks. The infinite norm distance is the maximum value of the horizontal spacing and the vertical spacing. When the infinite norm distance between the bounding rectangles of two different visual blocks is 0, an edge is established between the corresponding nodes of the two visual blocks to form an edge set. A visual adjacency graph is constructed by using the set of visual blocks as nodes and the set of edges as edges.
3. The real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning according to claim 2, characterized in that, Identify the encapsulation boundaries of web pages, and based on the graph distance from nodes to these boundaries, filter out the boundary neighborhood edge set in the visual adjacency graph, including: Extract the outer frame of the inline frame and the outer edge of the component host from the webpage rendering result to form a set of encapsulation boundaries; For each encapsulation boundary element in the encapsulation boundary set, determine the bounding rectangle and record the left, right, top, and bottom boundary coordinates of the bounding rectangle for each encapsulation boundary element. For each visual block in the visual block set, obtain the coordinates of the left boundary, right boundary, top boundary, and bottom boundary of the bounding rectangle of that visual block; Calculate the lateral spacing between the outer rectangle of the visual block and the outer rectangle of each encapsulation boundary element: Calculate the first value, which is the larger of 0 and the difference between the left boundary coordinate of the visual block's outer rectangle and the right boundary coordinate of the encapsulation boundary element's outer rectangle; calculate the second value, which is the larger of 0 and the difference between the left boundary coordinate of the encapsulation boundary element's outer rectangle and the right boundary coordinate of the visual block's outer rectangle; the lateral spacing is the maximum of the first and second values; Calculate the vertical spacing between the outer rectangle of the visual block and the outer rectangle of each encapsulation boundary element: Calculate the third value, which is the larger of 0 and the difference between the upper boundary coordinate of the visual block's outer rectangle and the lower boundary coordinate of the encapsulation boundary element's outer rectangle; calculate the fourth value, which is the larger of 0 and the difference between the upper boundary coordinate of the encapsulation boundary element's outer rectangle and the lower boundary coordinate of the visual block's outer rectangle; the vertical spacing is the maximum of the third and fourth values; Calculate the infinite norm distance between the bounding rectangle of the visual block and the bounding rectangle of each encapsulation boundary element. The infinite norm distance is the maximum value of the corresponding horizontal and vertical spacing. When there exists any encapsulation boundary element such that the infinite norm distance between the outer rectangle of the visual block and the outer rectangle of the encapsulation boundary element is 0, the node corresponding to the visual block is added to the edge node set. In a visual adjacency graph, the graph distance between any two nodes is calculated. The graph distance is the number of edges contained in the shortest path between the two nodes. For each node in the visual adjacency graph, calculate the graph distance from the node to the encapsulation boundary. The graph distance from the node to the encapsulation boundary is the minimum graph distance from the node to any node in the set of adjacent nodes. For each edge in the visual adjacency graph, determine whether the minimum graph distance between the two endpoints of the edge and the encapsulation boundary is less than or equal to 1; if the minimum value is less than or equal to 1, add the edge to the boundary neighborhood edge set.
4. The real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning according to claim 3, characterized in that, A state vector is constructed based on anomaly indices and their statistics, including: Set the current moment of continuous sampling as the time step; The anomaly index calculated at each time step is determined as the anomaly index of the corresponding time step. The initial sampling time is selected as the zero time step, the anomaly index calculated at the zero time step is used as the initial exponential moving average of the anomaly index, and zero is set as the initial exponential moving absolute deviation of the anomaly index. Set a smoothing coefficient, the value of which is greater than zero and less than or equal to one; For each target time step after the zero time step, calculate the exponential moving average of that target time step, including: first, calculate a first difference by subtracting the smoothing coefficient; multiply the first difference by the exponential moving average of the previous time step to obtain a first product; then multiply the smoothing coefficient by the outlier exponent of that target time step to obtain a second product; add the first product and the second product to obtain the exponential moving average of that target time step. The calculation of the exponential moving absolute deviation of the target time step includes: first, calculating the difference between the abnormal exponent of the target time step and the exponential moving mean of the previous time step, and taking the absolute value of the difference to obtain the absolute value of the deviation; then multiplying the first difference by the exponential moving absolute deviation of the previous time step to obtain the third product; multiplying the absolute value of the deviation by the smoothing coefficient to obtain the fourth product; and adding the third product and the fourth product to obtain the exponential moving absolute deviation of the target time step. Extract the anomaly index, the exponential moving mean, and the exponential moving absolute deviation of the target time step in sequence to form the state vector of the target time step.
5. The real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning according to claim 4, characterized in that, Micro-probe actions are selected using a pre-defined deep reinforcement learning strategy. The anomaly index and state vector are updated iteratively until the strategy outputs a termination instruction and locks the current adjacency graph, including: Set a set of micro-probe actions, which includes four actions: viewport width increase, viewport width decrease, brief wait, and submit termination. Set a preset deep reinforcement learning strategy, which is a function that maps the state vector of the current time step to any action in the set of micro-probe actions; Set the viewport width to the webpage viewport width corresponding to the current time step, set the adjustment step size to a fixed increment and the value of the adjustment step size to be greater than zero, and set the waiting time to a fixed time and the waiting time to be greater than zero. The loop process is executed, and the loop process is as follows: D1 maps the state vector of the current time step to the target action selected at the current time step by using a preset deep reinforcement learning strategy. D2, execute the target action of the current time step and update the viewport width, including: if the target action is to increase the viewport width, add the viewport width of the current time step to the adjustment step size to obtain the viewport width of the next time step; if the target action is to decrease the viewport width, subtract the adjustment step size from the viewport width of the current time step to obtain the viewport width of the next time step; if the target action is a short wait, maintain the viewport width of the current time step as the viewport width of the next time step and maintain the wait duration; if the target action is to submit and terminate, do not update the viewport width. D3, determine whether the target action of the current time step is to commit to termination; D4. If the target action is not a submission termination, re-render and visually segment the target webpage within the viewport width of the next time step to construct the visual adjacency graph of the next time step; calculate the anomaly index and the exponential moving average and absolute deviation of the exponential moving average of the next time step to construct the state vector of the next time step; set the next time step as the new current time step and return to D1 to re-execute. D5. If the target action is to submit and terminate, stop the loop process and determine the visual adjacency graph corresponding to the current time step as the locked adjacency graph.
6. The real-time anomaly detection method for fraudulent web pages based on deep reinforcement learning according to claim 5, characterized in that, Node and edge features are constructed based on an adjacency graph with locked discrete curvature. This is then combined with an anomaly index input graph neural network, and after message passing and feature readout, the output outputs a probability of fraud risk, including: Get the set of locked nodes and the set of locked edges corresponding to the locked adjacency graph; For each edge in the locked edge set, obtain the discrete curvature corresponding to the edge, and determine the discrete curvature as the edge feature of the edge; For each node in the locked set of nodes, count the degree of the node, sum the discrete curvatures of all the adjacent edges of the node to obtain the curvature sum value, and divide the curvature sum value by the degree of the node to obtain the node feature of the node. Extract the anomaly index calculated at the time step corresponding to the submission termination action, and determine the anomaly index as a graph-level attribute; The number of layers in the graph neural network is set to a positive integer. A weight matrix is set for each layer of the graph neural network. The modified linear unit is set to a non-linear function, which takes the larger value between the input value and zero. A temperature coefficient is set and the value of the temperature coefficient is greater than zero. Use the node features of each node as the initial features of that node in the first layer of the graph neural network; For each layer in the graph neural network, the attention weight corresponding to each edge of that layer is calculated, including: first, calculating the product of the discrete curvature and the temperature coefficient of the edge, and obtaining the natural exponent value corresponding to the product; then, accumulating the natural exponent values corresponding to all adjacent edges of the node to which the current edge belongs; and dividing the natural exponent value corresponding to the current edge by the accumulated value to obtain the attention weight corresponding to the edge. Update the features of each node in the layer, including: for each node, accumulate the attention weights corresponding to each adjacent edge of the node, the product of the previous layer features of the node at the other end of the edge and the corresponding layer weight matrix, and input the accumulated result into the modified linear unit to obtain the features of the current layer of the node; After completing the feature update of all layers, count the total number of nodes in the locked node set, sum the features of the last layer of all nodes to obtain the total feature value, and divide the total feature value by the total number of nodes to obtain the readout vector; The readout vector is concatenated with the graph-level attributes to obtain the connection vector; Define a weight vector and a bias scalar, calculate the product of the weight vector and the connection vector, and add the product to the bias scalar to obtain the combined value; Calculate the negative composite value of the Natural Index, divide 1 by the sum of 1 and the Natural Index value, and obtain the probability of the target webpage being involved in fraud.
Citation Information
Patent Citations
Unsupervised attribute network anomaly detection method and system based on view-level graph comparative learning
CN117201122A
Telecommunication fraud identification method and device, equipment, storage medium and product
CN120951093A