Anti-crawler tracing method and system based on font file rearrangement
By using random glyph encoding and glyph outline sorting watermarking technology, a unique font file is generated and a user ID watermark is embedded, which solves the problem of web crawlers crawling key data and realizes anti-crawler tracing and behavior blocking against pirate websites.
Patent Information
- Application Number
- CN202411981957.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-12-31
AI Technical Summary
Existing technologies are insufficient to effectively prevent web crawlers from scraping critical data from web pages, and there is a lack of traceability mechanisms on pirated websites.
By combining random glyph encoding with glyph outline sorting watermarking technology, a unique font file is generated, embedding a user ID watermark to prevent crawling behavior of pirate websites, and blocking pirate accounts through CRC verification.
It enables anti-scraping and source tracing of pirated websites, enhances data security, can promptly block piracy, and has a highly concealed watermark that is not easily cracked.
Smart Images

Figure CN119782598B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer science and network security, and in particular to an anti-crawler tracing method and system based on font file re-arrangement. Background Technology
[0002] A web crawler is a program that automatically extracts web pages. It downloads web pages from the World Wide Web for search engines and is an important component of search engines. However, when web crawlers are abused, too much homogeneous content appears on the internet, and original content is not protected. At the same time, some key data on web pages, such as contact information on recruitment websites and information that can be found for free on company websites, have become targets for malicious crawlers. How to prevent key data on web pages from being crawled has become an urgent problem to be solved.
[0003] Currently, web anti-crawler technology mainly involves targeted blocking by analyzing the characteristics of crawler behavior when accessing web pages, or by graphical representation of sensitive text, or by using random glyph encoding to obfuscate numbers to achieve the purpose of anti-crawler.
[0004] However, methods for blocking crawler behavior are easily bypassed by using multiple IP proxies and reducing the frequency of data collection; text-to-graphic methods are easily cracked by OCR technology; and while random character encoding technology can effectively prevent key numbers from being collected by crawlers, there is a lack of technical means to trace the content when the entire page is crawled and used to create a pirated website.
[0005] In view of this, the present invention is hereby proposed. Summary of the Invention
[0006] This invention proposes an anti-crawler tracing method and system based on font file re-arrangement. The proposed anti-crawler tracing method generates different webpage font codes for each user. By combining random glyph encoding technology with innovative glyph outline sorting watermarking technology, it achieves anti-crawler and source tracing blocking against pirated websites.
[0007] In a first aspect, this invention proposes an anti-crawler tracing method based on font file re-arrangement, comprising:
[0008] S11. The user logs into the website and browses the HTML format web pages that the website needs to protect;
[0009] S12. Perform structural analysis on the HTML-formatted webpage, locate the CSS style area and the HTML tag area that needs content protection, and further analyze to determine the font style used in the content protection area of the HTML-formatted webpage;
[0010] S13. Select a random scrambling algorithm to generate a random scrambling seed, generate a Unicode encoding sequence according to the character Unicode encoding range, and use the random scrambling algorithm to scramble the Unicode encoding sequence to generate a character encoding mapping table;
[0011] S14. Parse the font file corresponding to the font style used in the content protection area of the HTML-formatted webpage, parse the character mapping table cmap in the font file, and replace the Unicode encoding corresponding to the glyph name glyph with the character encoding mapping table to obtain the scrambled font file;
[0012] S15. The scrambled font file is deeply compressed using a font subsetation program to obtain glyph information that retains only the characters used in the HTML format web page content protection area. The glyph names in the glyph information are renamed according to the order of character appearance to obtain the glyph storage table of the subsetted font file of the scrambled font file.
[0013] S16. Assign a unique numerical identifier as a watermark identifier to each logged-in user of the website. The watermark identifier consists of N bits of binary encoded watermark information, specifically calculated as follows:
[0014] The number of website users is set to a, and the watermark information capacity is b, where b = 2^c and b ≥ a. Calculate d-bit CRC checksums, and concatenate c and d to equal N, i.e., N = c + d.
[0015] Where parameters a, b, c, d, and N are all real numbers greater than 0;
[0016] S17. Parse the glyph storage table of the subset font file, sequentially read the glyph data of each character in the glyph storage table of the subset font file, and embed the watermark in the following manner:
[0017] S171. No watermark embedding is performed on single-outline glyphs;
[0018] S172. Embed 1-bit watermark information into the glyphs of multiple contours, sorted according to the coordinates of the contour's starting point. When the embedded watermark information bit is "0", store it in sorted order; when the embedded watermark information bit is "1", store it in reverse order. Repeatedly embed the unique numerical watermark identifier assigned to the logged-in user until the watermark embedding is complete, resulting in a watermark font file; S18. Encode the watermark font file into a base64 string, write a custom CSS definition using a preset writing method, and modify the font-family attribute of the font style used in the HTML format webpage content protection area to a custom font name. The preset writing method is as follows:
[0019] / * Define a custom font * /
[0020] @font-face{
[0021] font-family:'MyCustomFont';
[0022] src:url('data:font / ttf; charset=utf-8; base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype');
[0023] font-weight:normal;
[0024] font-style:normal;
[0025] }
[0026] S19. Traverse the text characters in the HTML format webpage content protection area, and replace the Unicode encoding of the text characters according to the character encoding mapping table;
[0027] S20. The HTML-formatted webpage output response, after completing the S11-S19 processes, is sent to the logged-in user.
[0028] Furthermore, the random scrambling algorithm in S13 can be any one of the Xorshift algorithm, LCG algorithm, or Mersenne rotation algorithm.
[0029] Furthermore, the font file in S14 can be any of the following: ttf, ttc, or otf.
[0030] Furthermore, the font subsetter in S15 can be any of FontSmaller, hb-subset, or AssFontSubset.
[0031] Furthermore, the sorting according to the coordinates of the starting point of the contour as described in S172 can be sorted first by the horizontal coordinate and then by the vertical coordinate, with the smaller coordinate values appearing first, or sorted first by the vertical coordinate and then by the horizontal coordinate, with the smaller coordinate values appearing first.
[0032] Secondly, this invention proposes a method for tracing and blocking pirated websites, employing an anti-crawler tracing method based on font file rearrangement as described in the first aspect, including:
[0033] S21. The user logs into the pirated website and browses the HTML format webpage of the pirated website;
[0034] S22. Perform structural parsing on the HTML-formatted webpage, locate the embedded fonts in the CSS style area, and the embedded fonts are encoded using base64;
[0035] S23. Convert the base64 encoded embedded font into a binary font file;
[0036] S24. Parse the glyph storage table in the binary font file, sequentially read the glyph data of each character in the glyph storage table, exclude the glyph of one outline, and extract the watermark information bit by bit from the storage order of the glyph outline according to the reverse operation of watermark embedding and splice it into complete watermark information and CRC check code. The watermark information that passes the CRC check is considered to be successfully extracted; otherwise, continue to read the remaining characters for extraction.
[0037] S25. By querying the user account with the unique numerical ID corresponding to the system user account stolen by the pirate website crawler from the legitimate website through the watermark information, the user account is banned from continuing to access the legitimate website, thus blocking the user account's piracy behavior.
[0038] Thirdly, this invention proposes an anti-crawler tracing system based on font file re-arrangement, employing the anti-crawler tracing method based on font file re-arrangement as described in the first aspect, including:
[0039] Font style acquisition module D31: When a user logs into the website and browses the HTML format webpage that needs to be protected, the HTML format webpage is structurally parsed to locate the CSS style area and the HTML tag area that needs content protection, and the font style used in the content protection area of the HTML format webpage is further analyzed.
[0040] Character encoding mapping table generation module D32: Selects a random scrambling algorithm to generate a random scrambling seed, generates a Unicode encoding sequence according to the character Unicode encoding range, and uses the random scrambling algorithm to scramble the Unicode encoding sequence to generate a character encoding mapping table;
[0041] The scrambled font file acquisition module D33 parses the font file corresponding to the font style used in the content protection area of the HTML-formatted webpage, parses the character mapping table cmap in the font file, and replaces the Unicode encoding corresponding to the glyph name glyph with the character encoding mapping table to obtain the scrambled font file.
[0042] Module D34 for obtaining the glyph storage table: Performs deep compression on the scrambled font file using a font subsetization program to obtain glyph information that retains only the characters used in the HTML-formatted webpage content protection area. Renames the glyph names in the glyph information according to the order of character appearance to obtain the glyph storage table of the subsetted font file. Module D35 for generating the watermark font file: Assigns a unique numerical identifier to each logged-in user of the website as a watermark identifier. The watermark identifier consists of N-bit binary encoded watermark information, specifically calculated as follows:
[0043] The number of website users is set to a, and the watermark information capacity is b, where b = 2^c and b ≥ a. Calculate d-bit CRC checksums, and concatenate c and d to equal N, i.e., N = c + d.
[0044] Where parameters a, b, c, d, and N are all real numbers greater than 0;
[0045] The glyph storage table of the subset font file is parsed, and the glyph data of each character in the glyph storage table of the subset font file is read sequentially. Watermark embedding is performed in the following manner:
[0046] Watermark embedding is not performed on single-outline glyphs;
[0047] Embed 1-bit watermark information into the glyphs of multiple contours, sort them according to the coordinates of the starting point of the contours. When the watermark information bit is "0", it is stored in the sorted order. When the watermark information bit is "1", it is stored in the reverse order. The unique numerical watermark identifier information assigned to the logged-in user is embedded in a loop until the watermark embedding is completed, and the watermark font file is obtained.
[0048] Webpage output response module D36: Encodes the watermark font file into a base64 string, writes CSS to define a custom font according to a preset writing method, and modifies the font-family property of the font style used in the content protection area of the HTML-formatted webpage to the custom font name, wherein the preset writing method is:
[0049] / * Define a custom font * /
[0050] @font-face{
[0051] font-family:'MyCustomFont';
[0052] src:url('data:font / ttf; charset=utf-8; base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype');
[0053] font-weight:normal;
[0054] font-style:normal;
[0055] }
[0056] Traverse the text characters in the HTML-formatted webpage content protection area, and replace the Unicode encoding of the text characters according to the character encoding mapping table;
[0057] The HTML-formatted webpage response, after completing the above process, will be sent to the logged-in user.
[0058] Fourthly, this invention proposes a system for tracing and blocking pirate websites, employing the method for tracing and blocking pirate websites as described in the second aspect, comprising:
[0059] Webpage structure parsing module D41: The user logs into the pirate website and browses the HTML format webpage of the pirate website;
[0060] Font file conversion module D42: performs structural parsing on the HTML format webpage, locates the embedded fonts in the CSS style area, the embedded fonts are encoded in base64; and converts the base64 encoded embedded fonts into binary font files;
[0061] Watermark information extraction module D43: Parses the glyph storage table in the binary font file, sequentially reads the glyph data of each character in the glyph storage table, excludes a glyph of one outline, and extracts the watermark information bit by bit from the storage order of the glyph outline according to the reverse operation of watermark embedding and splices it into complete watermark information and CRC check code. Watermark information that passes the CRC check is considered to be successfully extracted; otherwise, it continues to read the remaining characters for extraction.
[0062] Tracing and blocking module D44: Query the user account with the unique numerical ID corresponding to the system user account stolen by the pirate website crawler from the legitimate website through the watermark information, block the user account's permission to continue accessing the legitimate website, and block the user account's piracy behavior.
[0063] Fifthly, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method for embedding watermarks into compressed data as described above.
[0064] In a sixth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for embedding watermarks into compressed data as described above.
[0065] Compared with the prior art, the beneficial effects of the present invention are:
[0066] The character outline sorting watermark proposed in this invention has strong concealment and is not easily detected by pirates. Moreover, the watermark's traceability capability compensates for the problem of full-page piracy that cannot be solved by simply scrambling the code, and can promptly block piracy.
[0067] Furthermore, this invention combines various random scrambling algorithms, character mapping table (cmap) replacement, font subsetation, and glyph renaming techniques, making it virtually impossible for pirates to reverse-engineer and reconstruct the scrambling code from the collected data, thus enhancing security. Attached Figure Description
[0068] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention. It is obvious that the drawings described below are merely some embodiments of the invention, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0069] Figure 1 This is an example diagram of the character shape with multiple contours proposed in this invention.
[0070] Figure 2 This is a schematic diagram of the anti-crawler tracing method based on font file re-arrangement proposed in this invention.
[0071] Figure 3 This is a schematic diagram of the anti-crawler tracing system based on font file re-arrangement proposed in this invention.
[0072] Figure labeling: D31 Font style acquisition module; D32 Character encoding mapping table generation module; D33 Scrambled font file acquisition module; D34 Glyph storage table acquisition module; D35 Watermark font file generation module; D36 Web page output response module. Detailed Implementation
[0073] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0074] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms, and “multiple” generally includes at least two unless the context clearly indicates otherwise.
[0075] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0076] Depending on the context, the words “if” or “suppose” as used here can be interpreted as “when” or “in response to determination” or “in response to detection.” Similarly, depending on the context, the phrases “if determination” or “if detection (of the stated condition or event)” can be interpreted as “when determination” or “in response to determination” or “when detection (of the stated condition or event)” or “in response to detection (of the stated condition or event).”
[0077] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that an article or device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such an article or device. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the article or device that includes said element.
[0078] For ease of understanding, such as Figure 1 As shown, the terms mentioned in this invention will be explained.
[0079] Glyph data consists of corner points and control points of several closed contours. These corner points and control points define the curves and straight lines of the glyphs, thus forming the shape of each character in the font. For common fonts such as Chinese and English, the storage order of each contour has no impact on the rendering and display of the characters.
[0080] Glyphs with a single contour: It refers to that the entire character is composed of a continuous contour without obvious internal segmentation. For example, the characters "日" and "月" both belong to glyphs with a single contour. Their structures are simple and usually consist of several continuous strokes, forming a closed or semi-closed shape.
[0081] Glyphs with multiple contours: It refers to that there are obvious internal segmentations in the character, and it is composed of two or more independent parts. For example, the characters "昌" and "明" both belong to glyphs with more than one contour.
[0082] The optional embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0083] In the first aspect, as Figure 1 shown, the present invention proposes an anti-crawler traceability method based on font file rearrangement, including:
[0084] S11. The user logs in to the website and browses the HTML-formatted web page to be protected on the website;
[0085] S12. Parse the structure of the HTML-formatted web page, locate the CSS style area and the HTML tag area that needs content protection, and further analyze to obtain the font style used in the content protection area of the HTML-formatted web page;
[0086] S13. Select a random scrambling algorithm to generate a random scrambling seed, generate a Unicode encoding sequence according to the character Unicode encoding range, and use the random scrambling algorithm to scramble the Unicode encoding sequence to generate a character encoding mapping table;
[0087] S14. Parse the font file corresponding to the font style used in the content protection area of the HTML-formatted web page, parse the character mapping table cmap table in the font file, and replace the Unicode encoding corresponding to the glyph name glyph with the character encoding mapping table to obtain a scrambled font file;
[0088] S15. Use a font subsetting program to deeply compress the scrambled font file to obtain only the glyph information of the characters used in the content protection area of the HTML-formatted web page, and rename the glyph names in the glyph information in the order of character appearance to obtain the glyph storage table of the subset font file of the scrambled font file;
[0089] S16. Assign a unique digital number to the logged-in user of the website as a watermark identifier, and the watermark identifier is composed of binary encoded watermark information of N bits. The specific calculation method is:
[0090] S16. Assign a unique digital number to the logged-in user of the website as a watermark identifier, and the watermark identifier is composed of binary encoded watermark information of N bits. The specific calculation method is:
[0091] The number of website users is set to a, and the watermark information capacity is b, where b = 2^c and b ≥ a. Calculate d-bit CRC checksums, and concatenate c and d to equal N, i.e., N = c + d.
[0092] Where parameters a, b, c, d, and N are all real numbers greater than 0;
[0093] S17. Parse the glyph storage table of the subset font file, sequentially read the glyph data of each character in the glyph storage table of the subset font file, and embed the watermark in the following manner:
[0094] S171. No watermark embedding is performed on single-outline glyphs;
[0095] S172. Embed 1-bit watermark information into the glyphs of multiple contours, sorted according to the coordinates of the contour's starting point. When the embedded watermark information bit is "0", store it in sorted order; when the embedded watermark information bit is "1", store it in reverse order. Repeatedly embed the unique numerical watermark identifier assigned to the logged-in user until the watermark embedding is complete, resulting in a watermark font file; S18. Encode the watermark font file into a base64 string, write a custom CSS definition using a preset writing method, and modify the font-family attribute of the font style used in the HTML format webpage content protection area to a custom font name. The preset writing method is as follows:
[0096] / * Define a custom font * /
[0097] @font-face{
[0098] font-family:'MyCustomFont';
[0099] src:url('data:font / ttf; charset=utf-8; base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype');
[0100] font-weight:normal;
[0101] font-style:normal;
[0102] }
[0103] S19. Traverse the text characters in the HTML format webpage content protection area, and replace the Unicode encoding of the text characters according to the character encoding mapping table;
[0104] S20. The HTML-formatted webpage output response, after completing the S11-S19 processes, is sent to the logged-in user.
[0105] CSS, short for Cascading Style Sheets, is a markup language used to describe the appearance and formatting of web pages. It allows developers to control the styles of HTML elements, such as fonts, colors, and spacing, by writing CSS code, thus achieving separation of content and presentation. CSS not only makes web pages more visually appealing but also improves page loading speed and maintainability.
[0106] In S13, the random scrambling algorithm is used to scramble the Unicode encoding sequence, and the random scrambling seed described in S13 is used to generate the character encoding mapping table.
[0107] CRC (Cyclic Redundancy Checksum) is an error correction technique, representing a cyclic redundancy checksum. It is one of the most commonly used error-checking codes in the field of data communication. The lengths of its information field and check field can be arbitrarily specified, but the CRC standards defined by both communicating parties must be consistent. It is mainly used to detect or verify errors that may occur after data transmission or storage.
[0108] Font subsetting is a process that significantly reduces the size of a font file by removing unnecessary characters and retaining only a specific set of characters. This is crucial for improving webpage loading speed and optimizing user experience, especially on mobile devices and under poor network conditions.
[0109] In S15, renaming the glyph names according to the order of character appearance is to prevent attackers from reconstructing the original font file from the subsetted font file.
[0110] Furthermore, the random scrambling algorithm in S13 can be any one of the Xorshift algorithm, LCG algorithm, or Mersenne rotation algorithm.
[0111] Furthermore, the font file in S14 can be any of the following: ttf, ttc, or otf.
[0112] Furthermore, the font subsetter in S15 can be any of FontSmaller, hb-subset, or AssFontSubset.
[0113] Furthermore, the sorting according to the coordinates of the starting point of the contour as described in S172 can be sorted first by the horizontal coordinate and then by the vertical coordinate, with the smaller coordinate values appearing first, or sorted first by the vertical coordinate and then by the horizontal coordinate, with the smaller coordinate values appearing first.
[0114] To facilitate understanding, the calculation method for the unique numerical identifier of logged-in users in S16 as the watermark identifier will be explained.
[0115] Assuming the number of users on the website is a = 100 million, then...
[0116] The watermark information capacity 'b' needs to reach 2^27, or 27 bits in length.
[0117] Calculate the 5-bit CRC checksum.
[0118] The data is concatenated to form a binary code for the watermark information, which is N = 27 bits + 5 bits = 32 bits.
[0119] When a user logs into the website and browses the page content that needs to be protected, the anti-crawler tracing method based on font file re-encoding described in the first aspect will be executed, converting the original web page content into garbled content after font re-encoding. Only by loading the embedded fonts in the web page can the content be read normally.
[0120] Secondly, this invention proposes a method for tracing and blocking pirated websites, employing an anti-crawler tracing method based on font file rearrangement as described in the first aspect, including:
[0121] S21. The user logs into the pirated website and browses the HTML format webpage of the pirated website;
[0122] S22. Perform structural parsing on the HTML-formatted webpage, locate the embedded fonts in the CSS style area, and the embedded fonts are encoded using base64;
[0123] S23. Convert the base64 encoded embedded font into a binary font file;
[0124] S24. Parse the glyph storage table in the binary font file, sequentially read the glyph data of each character in the glyph storage table, exclude the glyph of one outline, and extract the watermark information bit by bit from the storage order of the glyph outline according to the reverse operation of watermark embedding and splice it into complete watermark information and CRC check code. The watermark information that passes the CRC check is considered to be successfully extracted; otherwise, continue to read the remaining characters for extraction.
[0125] S25. By querying the user account with the unique numerical ID corresponding to the system user account stolen by the pirate website crawler from the legitimate website through the watermark information, the user account is banned from continuing to access the legitimate website, thus blocking the user account's piracy behavior.
[0126] When it is discovered that the website's webpage content has been scraped verbatim by a pirate website, this process can be executed to trace the login user account that collected the content through watermark information, promptly ban the relevant account, and block its piracy behavior.
[0127] Thirdly, such as Figure 3 As shown, this invention proposes an anti-crawler tracing system based on font file re-arrangement, employing the anti-crawler tracing method based on font file re-arrangement as described in the first aspect, including:
[0128] Font style acquisition module D31: When a user logs into the website and browses the HTML format webpage that needs to be protected, the HTML format webpage is structurally parsed to locate the CSS style area and the HTML tag area that needs content protection, and the font style used in the content protection area of the HTML format webpage is further analyzed.
[0129] Character encoding mapping table generation module D32: Selects a random scrambling algorithm to generate a random scrambling seed, generates a Unicode encoding sequence according to the character Unicode encoding range, and uses the random scrambling algorithm to scramble the Unicode encoding sequence to generate a character encoding mapping table;
[0130] The scrambled font file acquisition module D33 parses the font file corresponding to the font style used in the content protection area of the HTML-formatted webpage, parses the character mapping table cmap in the font file, and replaces the Unicode encoding corresponding to the glyph name glyph with the character encoding mapping table to obtain the scrambled font file.
[0131] Module D34 for obtaining the glyph storage table: Performs deep compression on the scrambled font file using a font subsetization program to obtain glyph information that retains only the characters used in the HTML-formatted webpage content protection area. Renames the glyph names in the glyph information according to the order of character appearance to obtain the glyph storage table of the subsetted font file. Module D35 for generating the watermark font file: Assigns a unique numerical identifier to each logged-in user of the website as a watermark identifier. The watermark identifier consists of N-bit binary encoded watermark information, specifically calculated as follows:
[0132] The number of website users is set to a, and the watermark information capacity is b, where b = 2^c and b ≥ a. Calculate d-bit CRC checksums, and concatenate c and d to equal N, i.e., N = c + d.
[0133] Where parameters a, b, c, d, and N are all real numbers greater than 0;
[0134] The glyph storage table of the subset font file is parsed, and the glyph data of each character in the glyph storage table of the subset font file is read sequentially. Watermark embedding is performed in the following manner:
[0135] Watermark embedding is not performed on single-outline glyphs;
[0136] Embed 1-bit watermark information into the glyphs of multiple contours, sort them according to the coordinates of the starting point of the contours. When the watermark information bit is "0", it is stored in the sorted order. When the watermark information bit is "1", it is stored in the reverse order. The unique numerical watermark identifier information assigned to the logged-in user is embedded in a loop until the watermark embedding is completed, and the watermark font file is obtained.
[0137] Webpage output response module D36: Encodes the watermark font file into a base64 string, writes CSS to define a custom font according to a preset writing method, and modifies the font-family property of the font style used in the content protection area of the HTML-formatted webpage to the custom font name, wherein the preset writing method is:
[0138] / * Define a custom font * /
[0139] @font-face{
[0140] font-family:'MyCustomFont';
[0141] src:url('data:font / ttf; charset=utf-8; base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype');
[0142] font-weight:normal;
[0143] font-style:normal;
[0144] }
[0145] Traverse the text characters in the HTML-formatted webpage content protection area, and replace the Unicode encoding of the text characters according to the character encoding mapping table;
[0146] The HTML-formatted webpage response, after completing the above process, will be sent to the logged-in user.
[0147] Fourthly, this invention proposes a system for tracing and blocking pirate websites, employing the method for tracing and blocking pirate websites as described in the second aspect, comprising:
[0148] Webpage structure parsing module D41: The user logs into the pirate website and browses the HTML format webpage of the pirate website;
[0149] Font file conversion module D42: performs structural parsing on the HTML format webpage, locates the embedded fonts in the CSS style area, the embedded fonts are encoded in base64; and converts the base64 encoded embedded fonts into binary font files;
[0150] Watermark information extraction module D43: Parses the glyph storage table in the binary font file, sequentially reads the glyph data of each character in the glyph storage table, excludes a glyph of one outline, and extracts the watermark information bit by bit from the storage order of the glyph outline according to the reverse operation of watermark embedding and splices it into complete watermark information and CRC check code. Watermark information that passes the CRC check is considered to be successfully extracted; otherwise, it continues to read the remaining characters for extraction.
[0151] Tracing and blocking module D44: Query the user account with the unique numerical ID corresponding to the system user account stolen by the pirate website crawler from the legitimate website through the watermark information, block the user account's permission to continue accessing the legitimate website, and block the user account's piracy behavior.
[0152] Fifthly, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method for embedding watermarks into compressed data as described above.
[0153] In a sixth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for embedding watermarks into compressed data as described above.
[0154] Specifically, a system or apparatus equipped with a storage medium may be provided, on which software program code implementing the functions of any of the embodiments described above is stored, and the computer (or CPU or MPU) of the system or apparatus may read and execute the program code stored in the storage medium.
[0155] In this case, the program code read from the storage medium can itself implement the function of any of the above embodiments, and therefore the program code and the storage medium storing the program code constitute part of the present invention.
[0156] Storage media embodiments for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer via a communication network.
[0157] Furthermore, it should be clear that not only can the program code read by the computer be executed, but also the operating system or other components operating on the computer can be instructed based on the program code to perform some or all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0158] Furthermore, it is understood that the program code read from the storage medium is written to the memory set in the expansion board inserted into the computer or to the memory set in the expansion unit connected to the computer. Then, based on the instructions of the program code, the CPU or other components installed on the expansion board or expansion unit execute some and all of the actual operations, thereby realizing the function of any of the embodiments described above.
[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for anti-crawler tracing based on font file re-arrangement, characterized in that, include: S11. The user logs into the website and browses the HTML format web pages that the website needs to protect; S12. Perform structural analysis on the HTML-formatted webpage, locate the CSS style area and the HTML tag area that requires content protection, and analyze the font style used in the content protection area of the HTML-formatted webpage. S13. Select a random scrambling algorithm to generate a random scrambling seed, generate a Unicode encoding sequence according to the character Unicode encoding range, and use the random scrambling algorithm to scramble the Unicode encoding sequence to generate a character encoding mapping table; S14. Parse the font file corresponding to the font style used in the content protection area of the HTML-formatted webpage, parse the character mapping table cmap in the font file, and replace the Unicode encoding corresponding to the glyph name glyph with the character encoding mapping table to obtain the scrambled font file; S15. The scrambled font file is deeply compressed using a font subsetation program to obtain glyph information that retains only the characters used in the HTML format web page content protection area. The glyph names in the glyph information are renamed according to the order of character appearance to obtain the glyph storage table of the subsetted font file of the scrambled font file. S16. Assign a unique numerical identifier to each logged-in user of the website as a watermark identifier; S17. Parse the glyph storage table of the subset font file, sequentially read the glyph data of each character in the glyph storage table of the subset font file, and perform watermark embedding to obtain a watermark font file; S18. Encode the watermark font file into a base64 string, write CSS to define a custom font, and modify the font-family property of the font style used in the content protection area of the HTML-formatted webpage to a custom font name; S19. Traverse the text characters in the HTML format webpage content protection area, and replace the Unicode encoding of the text characters according to the character encoding mapping table; S20. The HTML-formatted webpage output response, after completing the S11-S19 processes, is sent to the logged-in user.
2. The anti-crawler tracing method based on font file re-arrangement according to claim 1, characterized in that, The watermark identifier described in S16 consists of N bits of binary encoded watermark information, which is calculated as follows: The number of website users is set to a, and the watermark information capacity is b, where b = 2^c and b ≥ a. Calculate d-bit CRC checksums, and concatenate c and d to equal N, i.e., N = c + d. Where parameters a, b, c, d, and N are all real numbers greater than 0.
3. The anti-crawler tracing method based on font file re-arrangement according to claim 1, characterized in that, The watermark embedding described in S17 results in a watermark font file, including: S171. No watermark embedding is performed on single-outline glyphs; S172. Embed 1-bit watermark information into the glyphs of multiple contours, sort them according to the coordinates of the starting point of the contours. When the embedded watermark information bit is "0", store it in sorted order. When the embedded watermark information bit is "1", store it in reverse order. Embed the unique numerical watermark identifier information assigned to the logged-in user in a loop until the watermark embedding is completed, and obtain the watermark font file.
4. The anti-crawler tracing method based on font file re-arrangement according to claim 1, characterized in that, include: The random scrambling algorithm in S13 is any one of the following: Xorshift algorithm, LCG algorithm, or Mersenne rotation algorithm.
5. The anti-crawler tracing method based on font file re-arrangement according to claim 1, characterized in that, include: The font files in S14 can be any of the following: ttf, ttc, and otf.
6. The anti-crawler tracing method based on font file re-arrangement according to claim 1, characterized in that, include: The font subsetter in S15 can be any one of FontSmaller, hb-subset, or AssFontSubset.
7. The anti-crawler tracing method based on font file re-arrangement according to claim 1, characterized in that, include: The sorting according to the coordinates of the starting point of the contour as described in S172 can be either sorted by the horizontal coordinate first and then by the vertical coordinate, with smaller coordinate values appearing first, or sorted by the vertical coordinate first and then by the horizontal coordinate, with smaller coordinate values appearing first.
8. A method for tracing and blocking pirated websites, employing the anti-crawler tracing method based on font file rearrangement as described in any one of claims 1-7, characterized in that, include: S21. The user logs into the pirated website and browses the HTML format webpage of the pirated website; S22. Perform structural parsing on the HTML-formatted webpage, locate the embedded fonts in the CSS style area, and the embedded fonts are encoded using base64; S23. Convert the base64 encoded embedded font into a binary font file; S24. Parse the glyph storage table in the binary font file, sequentially read the glyph data of each character in the glyph storage table, exclude the glyph of one outline, and extract the watermark information bit by bit from the storage order of the glyph outline according to the reverse operation of watermark embedding and splice it into complete watermark information and CRC check code. The watermark information that passes the CRC check is considered to be successfully extracted; otherwise, continue to read the remaining characters for extraction. S25. By querying the user account with the unique numerical ID corresponding to the system user account stolen by the pirate website crawler from the legitimate website through the watermark information, the user account is banned from continuing to access the legitimate website, thus blocking the user account's piracy behavior.
9. A system for tracing anti-crawler origins based on font file re-arrangement, employing the anti-crawler origination method for font file re-arrangement as described in any one of claims 1-7, comprising: Font style acquisition module: When a user logs into the website, they browse the HTML-formatted web pages that the website needs to protect. The HTML-formatted webpage is structurally parsed to locate the CSS style area and the HTML tag area that requires content protection, and the font style used in the content protection area of the HTML-formatted webpage is analyzed. Character encoding mapping table generation module: Selects a random scrambling algorithm to generate a random scrambling seed, generates a Unicode encoding sequence based on the character Unicode encoding range, and uses the random scrambling algorithm to scramble the Unicode encoding sequence to generate a character encoding mapping table; The scrambled font file acquisition module parses the font file corresponding to the font style used in the content protection area of the HTML-formatted webpage, parses the character mapping table cmap in the font file, and replaces the Unicode encoding corresponding to the glyph name with the character encoding mapping table to obtain the scrambled font file. The glyph storage table acquisition module: The scrambled font file is deeply compressed using a font subsetation program to obtain glyph information that retains only the characters used in the HTML format web page content protection area. The glyph names in the glyph information are renamed according to the order of character appearance to obtain the glyph storage table of the subsetted font file of the scrambled font file. Watermark font file generation module: Assigns a unique numerical code as a watermark identifier to the logged-in user of the website; The glyph storage table of the subset font file is parsed, the glyph data of each character in the glyph storage table of the subset font file is read sequentially, and watermark embedding is performed to obtain a watermark font file; Webpage output response module: Encodes the watermark font file into a base64 string, writes CSS to define a custom font, and modifies the font-family property of the font style used in the content protection area of the HTML-formatted webpage to a custom font name; Traverse the text characters in the HTML-formatted webpage content protection area, and replace the Unicode encoding of the text characters according to the character encoding mapping table; The HTML-formatted webpage response, after completing the above process, will be sent to the logged-in user.
10. A system for tracing and blocking pirate websites, employing the method for tracing and blocking pirate websites as described in claim 8, comprising: Webpage structure parsing module: Users log in to pirate websites and browse the HTML format webpages of the pirate websites; Font file conversion module: performs structural parsing on the HTML format webpage, locates the embedded fonts in the CSS style area, the embedded fonts are encoded in base64; and converts the base64 encoded embedded fonts into binary font files; Watermark information extraction module: Parses the glyph storage table in the binary font file, sequentially reads the glyph data of each character in the glyph storage table, excludes a glyph of one outline, and extracts watermark information bit by bit from the storage order of glyph outline according to the reverse operation of watermark embedding and splices it into complete watermark information and CRC check code. Watermark information that passes CRC check is considered to be successfully extracted; otherwise, the remaining characters are read for extraction. Tracing and blocking module: By querying the user account with the unique number corresponding to the system user account stolen by the pirate website crawler from the legitimate website through the watermark information, the module blocks the user account's permission to continue accessing the legitimate website, thus blocking the user account's piracy behavior.
Citation Information
Patent Citations
Anti-crawler data processing method, device, system and storage medium
CN110990799A
Content Validation And Coding For Search Engine Optimization
US20180165364A1