Anti-crawler tracing method and system based on font file rearrangement
Through the method of font file reorganization, combined with random glyph encoding and glyph outline sorting watermark technology, the problem that the existing technology is difficult to prevent pirated websites and traceable crawler behavior is solved, and effective anti-crawler and traceability blocking of pirated websites is achieved.
Patent Information
- Application Number
- CN202411981957.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-31
AI Technical Summary
Existing anti-crawler technology is difficult to effectively prevent the emergence of pirated websites and the traceability of crawler behavior.
Through the method of font file reorganization, combined with random glyph encoding technology and glyph outline sorting watermark technology, different web font encodings are generated for each user, thereby realizing anti-crawling and traceability blocking of pirated websites.
It realizes effective traceability and blocking of pirated websites, enhances security, and makes up for the problem of piracy on the entire web page that cannot be solved by simply messing up coding.
Smart Images

Figure CN119782598A_ABST
Abstract
Description
Technical Field
[0001] The present 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-formatting. Background Art
[0002] Web crawlers are programs that automatically extract web pages. They download web pages from the World Wide Web for search engines and are an important part of search engines. However, when web crawlers are abused, there are too many homogeneous things on the Internet, and original content cannot be protected. At the same time, some key data on web pages, such as user contact information on recruitment websites and free information on company homepages, have also become targets for some malicious crawlers to frantically crawl. How to prevent key data on web pages from being crawled by crawlers has become an urgent problem that needs to be solved.
[0003] Currently, web anti-crawler technology mainly analyzes the behavioral characteristics of crawlers accessing web pages to conduct targeted bans, or uses methods such as graphing sensitive text. There are also methods that use random glyph encoding to confuse numbers to achieve anti-crawler purposes.
[0004] However, crawler behavior blocking methods can be easily bypassed by methods such as multi-IP proxy and reducing the collection frequency; text graphics methods can be easily cracked by OCR technology; although random glyph encoding technology can effectively prevent key numbers from being collected by crawlers, there is a lack of technical means to trace when the page content is crawled as a whole and made into a pirated website.
[0005] In view of this, the present invention is proposed. Summary of the invention
[0006] The present invention proposes an anti-crawler tracing method and system based on font file re-arrangement. The anti-crawler tracing method based on font file re-arrangement proposed by the present invention can generate different webpage font encodings for each user, and realizes anti-crawler and tracing blocking for pirated websites by combining random glyph encoding technology with innovative glyph outline sorting watermark technology.
[0007] In a first aspect, the present invention proposes an anti-crawler tracing method based on font file re-arrangement, comprising: S11. The user logs in to the website and browses the HTML page of the website to be protected; S12. The HTML-formatted web page is structurally parsed to locate the CSS style area and the HTML tag area that needs content protection, and further analyze the font style used in the HTML-formatted web page content protection area; S13. Select a random scrambling algorithm to generate a random scrambling seed, generate a Unicode code sequence according to the character Unicode code range, scramble the Unicode code sequence using the random scrambling algorithm, and generate a character encoding mapping table; S14. Parsing the font file corresponding to the font style used in the protected area of the HTML web page content, parsing the character map cmap table in the font file, replacing the Unicode code corresponding to the glyph name glyph with the character code mapping table to obtain a scrambled font file; S15. The scrambled font file is deeply compressed using a font subsetting program to obtain glyph information of characters used in the protected area of the web page content in the HTML format, and the glyph names in the glyph information are renamed in the order in which the characters appear to obtain a glyph storage table of a subset font file of the scrambled font file; S16. Assign a unique digital number as a watermark identifier to the logged-in user of the website. The watermark identifier is composed of N bits of binary coded watermark information. The specific calculation method is: The number of website users is preset to be a, the watermark information capacity is preset to be b, where b=2^c and b≥a, a d-bit CRC check code is calculated, and the concatenation of c and d is equal to N, that is, N=c+d; Among them, parameters a, b, c, d, and N are all real numbers greater than 0; S17. Parsing the glyph storage table of the subset font file, sequentially reading the glyph data of each character in the glyph storage table of the subset font file, and embedding the watermark in the following manner, including: S171. Do not embed watermark into single outline glyphs; S172. Embed 1-bit watermark information into the glyphs of multiple contours, sort them according to the coordinates of the starting points of the contours, store them in the sorted order when the embedded watermark information bit is "0", and store them in the reverse order when the embedded watermark information bit is "1", and cyclically embed the unique digital number watermark identification information assigned to the logged-in user until the watermark embedding is completed, and obtain the watermark font file; S18. Encode the watermark font file into a base64 string, write a CSS definition custom font in a preset writing method, and modify the font-family attribute of the font style used in the content protection area of the HTML format web page to the custom font name, wherein the preset writing method is: / *Define custom font* / @font-face{ font-family:'MyCustomFont'; src:url('data:font / ttf; charset=utf-8; base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype'); font-weight:normal; font-style:normal; } S19. Traverse the text characters in the protected area of the HTML-formatted web page content, and replace the unicode encoding of the text characters after encoding conversion according to the character encoding mapping table; S20. Output the HTML-formatted web page after executing the S11-S19 process to the logged-in user in response.
[0008] Furthermore, the random scrambling algorithm in S13 may be any one of the Xorshift algorithm, the LCG algorithm, and the Mersenne twister algorithm.
[0009] Furthermore, the font file in S14 is any one of ttf, ttc, and otf.
[0010] Furthermore, the font subsetting program in S15 may be any one of FontSmaller, hb-subset, and AssFontSubset.
[0011] Furthermore, the sorting according to the coordinates of the starting points of the contours in S172 may be sorting by the horizontal coordinate first and then by the vertical coordinate with smaller coordinate values being placed first, or sorting by the vertical coordinate first and then by the horizontal coordinate with smaller coordinate values being placed first.
[0012] In a second aspect, the present invention proposes a method for tracing and blocking pirated websites, using an anti-crawler tracing method based on font file re-arrangement as described in the first aspect, comprising: S21. The user logs in to the pirated website and browses the HTML page of the pirated website; S22. The HTML-formatted web page is structurally parsed to locate the embedded font in the CSS style area, where the embedded font is encoded using base64; S23. Convert the embedded font encoded in base64 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 inverse 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 extracted successfully, otherwise continue to read the remaining characters for extraction; S25. Use the watermark information to query the user account with the unique digital number corresponding to the system user account of the legitimate website stolen by the pirated website crawler, ban the user account from continuing to access the legitimate website, and block the user account from pirating.
[0013] In a third aspect, the present invention proposes an anti-crawler source tracing system based on font file re-formatting, which adopts the anti-crawler source tracing method based on font file re-formatting as described in the first aspect, including: Font style acquisition module D31: a user logs in to a website and browses a web page in HTML format that needs to be protected; the HTML web page is structurally parsed to locate the CSS style area and the HTML tag area that needs content protection, and further analyzes to obtain the font style used in the content protection area of the HTML web page; 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, scrambles the Unicode encoding sequence using the random scrambling algorithm, and generates a character encoding mapping table; The scrambled font file acquisition module D33: parses the font file corresponding to the font style used in the protected area of the webpage content in HTML format, parses the character mapping table cmap in the font file, replaces the Unicode code corresponding to the glyph name glyph with the character code mapping table, and obtains the scrambled font file; The glyph storage table acquisition module D34: deeply compresses the scrambled font file using a font subset program to obtain the glyph information of the characters used in the protected area of the web page content in the HTML format, renames the glyph names in the glyph information according to the order in which the characters appear, and obtains the glyph storage table of the subset font file of the scrambled font file; the watermark font file generation module D35: assigns a unique digital number as a watermark identifier to the logged-in user of the website, and the watermark identifier is composed of N-bit binary coded watermark information, and the specific calculation method is: The number of website users is preset to be a, the watermark information capacity is preset to be b, where b=2^c and b≥a, a d-bit CRC check code is calculated, and the concatenation of c and d is equal to N, that is, N=c+d; Among them, parameters a, b, c, d, and N are all real numbers greater than 0; Parsing the glyph storage table of the subset font file, sequentially reading the glyph data of each character in the glyph storage table of the subset font file, and embedding the watermark in the following manner, including: No watermark embedding is performed on single-contour glyphs; Embed 1-bit watermark information into the glyphs of multiple contours, sort them according to the coordinates of the contour starting points, store them in the sorted order when the embedded watermark information bit is "0", and store them in the reverse order when the embedded watermark information bit is "1", and cyclically embed the unique digital number watermark identification information assigned to the logged-in user until the watermark embedding is completed, and obtain the watermark font file; Web page output response module D36: Encode the watermark font file into a base64 string, write CSS to define a custom font in a preset writing method, and modify the font-family attribute of the font style used in the HTML format web page content protection area to the custom font name, wherein the preset writing method is: / *Define custom font* / @font-face{ font-family:'MyCustomFont'; src:url('data:font / ttf; charset=utf-8; base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype'); font-weight:normal; font-style:normal; } Traversing the text characters in the content protection area of the HTML-formatted webpage, converting the unicode codes of the text characters according to the character code mapping table and replacing them; The HTML-formatted web page after executing the above process is output as a response to the logged-in user.
[0014] In a fourth aspect, the present invention provides a system for tracing and blocking pirated websites, which adopts the method for tracing and blocking pirated websites as described in the second aspect, and comprises: Web page structure analysis module D41: a user logs in to a pirated website and browses the HTML-formatted web page of the pirated website; The font file conversion module D42 performs structural analysis on the HTML-formatted webpage, locates the embedded font in the CSS style area, and the embedded font is encoded in base64; and converts the embedded font encoded in base64 into a binary font file; The 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, and after excluding the glyph of one outline, extracts the watermark information bit by bit from the storage order of the glyph outline according to the inverse operation of watermark embedding and splices them into complete watermark information and CRC check code. The watermark information that passes the CRC check is considered to be extracted successfully, otherwise, continue to read the remaining characters for extraction; Retroactive blocking module D44: uses the watermark information to query the user account with the unique digital number corresponding to the system user account of the legitimate website stolen by the pirated website crawler, prohibits the user account from continuing to access the legitimate website, and blocks the user account from pirating.
[0015] In a fifth aspect, the present invention proposes an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for embedding watermarks in compressed data as described above when executing the program.
[0016] In a sixth aspect, the present invention proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for embedding a watermark into compressed data as described above.
[0017] Compared with the prior art, the present invention has the following beneficial effects: The glyph outline sorting watermark proposed by the present invention is highly concealed and not easily detected by pirates. The watermark traceability capability makes up for the problem of original piracy of the entire web page that cannot be solved by simple scrambling coding, and can block piracy in a timely manner.
[0018] In addition, the present invention combines multiple technical means such as multiple random scrambling algorithms, character mapping table cmap table replacement, font subsetting, glyph renaming, etc., making it almost impossible for pirates to reversely analyze and restore scrambled codes through collected data, thereby enhancing security. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present invention, and together with the specification are used to explain the principles of the present invention. Obviously, the accompanying drawings described below are only some embodiments of the present invention, and for those of ordinary skill in the art, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0020] Figure 1 It is an example diagram of a glyph with multiple contours proposed by the present invention.
[0021] Figure 2 It is a schematic diagram of the anti-crawler tracing method based on font file re-arrangement proposed by the present invention.
[0022] Figure 3 It is a structural schematic diagram of the anti-crawler tracing system based on font file re-arrangement proposed by the present invention.
[0023] Explanation of reference numerals: 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 DESCRIPTION
[0024] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two.
[0026] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0027] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0028] It should also be noted that the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, such that a commodity or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or also includes elements inherent to such commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the commodity or device comprising said element.
[0029] For ease of understanding, as Figure 1 shown, the nouns mentioned in the present invention are explained.
[0030] Glyph data: It consists of the corner points and control points of several closed contours, and these corner points and control points define the curves and straight paths of the glyphs, thus constituting the shape of each character in the font. For common fonts such as Chinese and English, the storage order of each contour has no effect on the rendering and display of the characters.
[0031] Glyphs with a single contour: It means that the whole 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 to form a closed or semi-closed shape.
[0032] Glyphs with multiple contours: It means that there is obvious segmentation inside 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.
[0033] The optional embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0034] In a first aspect, as Figure 1 shown, the present invention proposes an anti-crawler traceability method based on font file rearrangement, including: S11. The user logs in to the website and browses the HTML-formatted web page to be protected on the website; 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 web page content protection area of the HTML format; 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 web page content protection area of the HTML format to make A font file corresponding to the used font style is parsed in the character mapping table cmap in the font file, and the Unicode code corresponding to the glyph name glyph is replaced by the character code mapping table to obtain a scrambled font file; S15. The scrambled font file is deeply compressed using a font subsetting program to obtain glyph information of characters used in the protected area of the web page content in the HTML format, and the glyph names in the glyph information are renamed in the order in which the characters appear to obtain a glyph storage table of a subset font file of the scrambled font file; S16. Assign a unique digital number as a watermark identifier to the logged-in user of the website. The watermark identifier is composed of N bits of binary coded watermark information. The specific calculation method is: The number of website users is preset to be a, the watermark information capacity is preset to be b, where b=2^c and b≥a, a d-bit CRC check code is calculated, and the concatenation of c and d is equal to N, that is, N=c+d; Among them, parameters a, b, c, d, and N are all real numbers greater than 0; S17. Parsing the glyph storage table of the subset font file, sequentially reading the glyph data of each character in the glyph storage table of the subset font file, and embedding the watermark in the following manner, including: S171. Do not embed watermark into single outline glyphs; S172. Embed 1-bit watermark information into the glyphs of multiple contours, sort them according to the coordinates of the starting points of the contours, store them in the sorted order when the embedded watermark information bit is "0", and store them in the reverse order when the embedded watermark information bit is "1", and cyclically embed the unique digital number watermark identification information assigned to the logged-in user until the watermark embedding is completed, and obtain the watermark font file; S18. Encode the watermark font file into a base64 string, write a CSS definition custom font in a preset writing method, and modify the font-family attribute of the font style used in the content protection area of the HTML format web page to the custom font name, wherein the preset writing method is: / *Define custom font* / @font-face{ font-family:'MyCustomFont'; src:url('data:font / ttf; charset=utf-8; base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype'); font-weight:normal; font-style:normal; } S19. Traverse the text characters in the protected area of the HTML-formatted web page content, and replace the unicode encoding of the text characters after encoding conversion according to the character encoding mapping table; S20. Output the HTML-formatted web page after executing the S11-S19 process to the logged-in user in response.
[0035] Among them, CSS, the full name of which is Cascading Style Sheets, is a markup language used to describe the appearance and format of a web page. It allows developers to control the style of HTML elements, such as fonts, colors, spacing, etc., by writing CSS code, thereby achieving the separation of content and presentation. CSS not only makes web pages more beautiful, but also improves the loading speed and maintainability of web pages.
[0036] In S13, the Unicode encoding sequence is scrambled using the random scrambling algorithm, and the random scrambling seed described in S13 is used to generate a character encoding mapping table.
[0037] CRC (Cyclic Redundancy Checksum) is an error correction technology, which stands for cyclic redundancy checksum. It is the most commonly used error correction code in the field of data communication. The length of its information field and check field can be specified arbitrarily, but the CRC standard defined by both parties in communication must be consistent. It is mainly used to detect or verify errors that may occur after data transmission or storage.
[0038] Font subsetting is a process that significantly reduces the size of font files by removing unnecessary characters from the font file and retaining only a specific set of characters. This is critical for increasing web page loading speed and optimizing user experience, especially on mobile devices and in poor network conditions.
[0039] The purpose of renaming the glyph names according to the order in which the characters appear in S15 is to prevent an attacker from reversely restoring the original font file from the subset font file.
[0040] Furthermore, the random scrambling algorithm in S13 may be any one of the Xorshift algorithm, the LCG algorithm, and the Mersenne twister algorithm.
[0041] Furthermore, the font file in S14 is any one of ttf, ttc, and otf.
[0042] Furthermore, the font subsetting program in S15 may be any one of FontSmaller, hb-subset, and AssFontSubset.
[0043] Furthermore, the sorting according to the coordinates of the starting points of the contours in S172 may be sorting by the horizontal coordinate first and then by the vertical coordinate with smaller coordinate values being placed first, or sorting by the vertical coordinate first and then by the horizontal coordinate with smaller coordinate values being placed first.
[0044] For ease of understanding, the calculation method of using the unique digital number of the logged-in user as the watermark identifier in S16 is explained.
[0045] Assuming the number of users of the website is a=100 million, then The watermark information capacity b needs to reach 2^27, which is 27 bits in length. Calculate d = 5 bit CRC check code, The concatenation forms a watermark information binary code of N=27bit+5bit=32bit.
[0046] After the user logs in to the website, when browsing the page content that needs to be protected, the anti-crawler tracing method based on font file re-arrangement described in the first aspect will be executed to convert the original web page content into garbled content after font re-encoding. Only by loading the embedded fonts in the web page can it be read normally.
[0047] In a second aspect, the present invention proposes a method for tracing and blocking pirated websites, using an anti-crawler tracing method based on font file re-arrangement as described in the first aspect, comprising: S21. The user logs in to the pirated website and browses the HTML page of the pirated website; S22. The HTML-formatted web page is structurally parsed to locate the embedded font in the CSS style area, where the embedded font is encoded using base64; S23. Convert the embedded font encoded in base64 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 inverse 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 extracted successfully, otherwise continue to read the remaining characters for extraction; S25. Use the watermark information to query the user account with the unique digital number corresponding to the system user account of the legitimate website stolen by the pirated website crawler, ban the user account from continuing to access the legitimate website, and block the user account from pirating.
[0048] When it is discovered that the web page content of the website has been crawled as is by a pirated website, this process can be executed to trace the login user account of the collected content through the watermark information, and the relevant account can be banned in time to prevent the piracy behavior.
[0049] Thirdly, Figure 3 As shown, the present invention proposes an anti-crawler source tracing system based on font file re-arrangement, which adopts the anti-crawler source tracing method based on font file re-arrangement as described in the first aspect, including: Font style acquisition module D31: a user logs in to a website and browses a web page in HTML format that needs to be protected; the HTML web page is structurally parsed to locate the CSS style area and the HTML tag area that needs content protection, and further analyzes to obtain the font style used in the content protection area of the HTML web page; 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, scrambles the Unicode encoding sequence using the random scrambling algorithm, and generates a character encoding mapping table; The scrambled font file acquisition module D33: parses the font file corresponding to the font style used in the protected area of the webpage content in HTML format, parses the character mapping table cmap in the font file, replaces the Unicode code corresponding to the glyph name glyph with the character code mapping table, and obtains the scrambled font file; The glyph storage table acquisition module D34: deeply compresses the scrambled font file using a font subset program to obtain the glyph information of the characters used in the protected area of the web page content in the HTML format, renames the glyph names in the glyph information according to the order in which the characters appear, and obtains the glyph storage table of the subset font file of the scrambled font file; the watermark font file generation module D35: assigns a unique digital number as a watermark identifier to the logged-in user of the website, and the watermark identifier is composed of N-bit binary coded watermark information, and the specific calculation method is: The number of website users is preset to be a, the watermark information capacity is preset to be b, where b=2^c and b≥a, a d-bit CRC check code is calculated, and the concatenation of c and d is equal to N, that is, N=c+d; Among them, parameters a, b, c, d, and N are all real numbers greater than 0; Parsing the glyph storage table of the subset font file, sequentially reading the glyph data of each character in the glyph storage table of the subset font file, and embedding the watermark in the following manner, including: No watermark embedding is performed on single-contour glyphs; Embed 1-bit watermark information into the glyphs of multiple contours, sort them according to the coordinates of the contour starting points, store them in the sorted order when the embedded watermark information bit is "0", and store them in the reverse order when the embedded watermark information bit is "1", and cyclically embed the unique digital number watermark identification information assigned to the logged-in user until the watermark embedding is completed, and obtain the watermark font file; Web page output response module D36: Encode the watermark font file into a base64 string, write CSS to define a custom font in a preset writing method, and modify the font-family attribute of the font style used in the HTML format web page content protection area to the custom font name, wherein the preset writing method is: / *Define custom font* / @font-face{ font-family:'MyCustomFont'; src:url('data:font / ttf; charset=utf-8; base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype'); font-weight:normal; font-style:normal; } Traversing the text characters in the content protection area of the HTML-formatted webpage, converting the unicode codes of the text characters according to the character code mapping table and replacing them; The HTML-formatted web page after executing the above process is output as a response to the logged-in user.
[0050] In a fourth aspect, the present invention provides a system for tracing and blocking pirated websites, which adopts the method for tracing and blocking pirated websites as described in the second aspect, and comprises: Web page structure analysis module D41: a user logs in to a pirated website and browses the HTML-formatted web page of the pirated website; The font file conversion module D42 performs structural analysis on the HTML-formatted webpage, locates the embedded font in the CSS style area, and the embedded font is encoded in base64; and converts the embedded font encoded in base64 into a binary font file; The 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, and after excluding the glyph of one outline, extracts the watermark information bit by bit from the storage order of the glyph outline according to the inverse operation of watermark embedding and splices them into complete watermark information and CRC check code. The watermark information that passes the CRC check is considered to be extracted successfully, otherwise, continue to read the remaining characters for extraction; Retroactive blocking module D44: uses the watermark information to query the user account with the unique digital number corresponding to the system user account of the legitimate website stolen by the pirated website crawler, prohibits the user account from continuing to access the legitimate website, and blocks the user account from pirating.
[0051] In a fifth aspect, the present invention proposes an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for embedding watermarks in compressed data as described above when executing the program.
[0052] In a sixth aspect, the present invention proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for embedding a watermark into compressed data as described above.
[0053] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can be enabled to read and execute the program code stored in the storage medium.
[0054] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0055] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer via a communication network.
[0056] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0057] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0058] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements 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. An anti-crawler tracing method based on font file re-arrangement, characterized in that: include: S11. The user logs in to the website and browses the HTML page of the website to be protected; S12. The HTML-formatted web page is structurally parsed to locate the CSS style area and the HTML tag area that needs content protection, and further analyze the font style used in the HTML-formatted web page content protection area; S13. Select a random scrambling algorithm to generate a random scrambling seed, generate a Unicode code sequence according to the character Unicode code range, scramble the Unicode code sequence using the random scrambling algorithm, and generate a character encoding mapping table; S14. Parsing the font file corresponding to the font style used in the protected area of the HTML web page content, parsing the character map cmap table in the font file, replacing the Unicode code corresponding to the glyph name glyph with the character code mapping table to obtain a scrambled font file; S15. The scrambled font file is deeply compressed using a font subsetting program to obtain glyph information of characters used in the protected area of the web page content in the HTML format, and the glyph names in the glyph information are renamed in the order in which the characters appear to obtain a glyph storage table of a subset font file of the scrambled font file; S16. Assign a unique digital number as a watermark identifier to the logged-in user of the website. The watermark identifier is composed of N bits of binary coded watermark information. The specific calculation method is: The number of website users is preset to be a, the watermark information capacity is preset to be b, where b=2^c and b≥a, a d-bit CRC check code is calculated, and the concatenation of c and d is equal to N, that is, N=c+d; Among them, parameters a, b, c, d, and N are all real numbers greater than 0; S17. Parsing the glyph storage table of the subset font file, sequentially reading the glyph data of each character in the glyph storage table of the subset font file, and embedding the watermark in the following manner, including: S171. Do not embed watermark into single outline glyphs; S172. Embed 1-bit watermark information into multiple outline glyphs, sort them according to the coordinates of the outline starting points, and store them in sorted order when the embedded watermark information bit is "0". When the embedded watermark information bit is "1", store them in reverse order. Embed the unique digital watermark identification information assigned to the logged-in user in a loop until the watermark embedding is completed to obtain a watermark font file. S18. Encode the watermark font file into a base64 string, write a CSS definition custom font in a preset writing method, and modify the font-family attribute of the font style used in the HTML format web page content protection area to the custom font name, wherein the preset writing method is: / *Define custom font* / @font-face { font-family: 'MyCustomFont'; src: url('data:font / ttf;charset=utf- 8;base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype'); font-weight:normal; font-style:normal; } S19. Traverse the text characters in the protected area of the HTML-formatted web page content, and replace the unicode encoding of the text characters after encoding conversion according to the character encoding mapping table; S20. Output the HTML-formatted web page after executing the S11-S19 process to the logged-in user in response.
2. The anti-crawler tracing method based on font file re-arrangement according to claim 1 is characterized in that: include: The random scrambling algorithm in S13 can be selected from any one of the Xorshift algorithm, the LCG algorithm, and the Mersenne rotation algorithm.
3. The anti-crawler tracing method based on font file re-arrangement according to claim 1 is characterized in that: include: The font file in S14 is any one of ttf, ttc, and otf.
4. The anti-crawler tracing method based on font file re-arrangement according to claim 1, characterized in that: include: The font subsetting program in S15 can be any one of FontSmaller, hb-subset, and AssFontSubset.
5. 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 points of the contours in S172 may be sorting by the horizontal coordinate first and then by the vertical coordinate with smaller coordinate values being placed first, or sorting by the vertical coordinate first and then by the horizontal coordinate with smaller coordinate values being placed first.
6. A method for tracing and blocking pirated websites, using the anti-crawler tracing method based on font file re-arrangement as described in any one of claims 1 to 5, characterized in that: include: S21. The user logs in to the pirated website and browses the HTML page of the pirated website; S22. The HTML-formatted web page is structurally parsed to locate the embedded font in the CSS style area, where the embedded font is encoded using base64; S23. Convert the embedded font encoded in base64 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 inverse 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 extracted successfully, otherwise continue to read the remaining characters for extraction; S25. Use the watermark information to query the user account with the unique digital number corresponding to the system user account of the legitimate website stolen by the pirated website crawler, ban the user account from continuing to access the legitimate website, and block the user account from pirating.
7. An anti-crawler source tracing system based on font file re-arrangement, using the anti-crawler source tracing method based on font file re-arrangement according to any one of claims 1 to 5, comprising: Font style acquisition module D31: a user logs in to a website and browses a web page in HTML format that needs to be protected; Performing structural analysis on the HTML-formatted webpage, locating the CSS style area and the HTML tag area that needs content protection, and further analyzing to obtain the font style used in the content protection area of the HTML-formatted webpage; 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, scrambles the Unicode encoding sequence using the random scrambling algorithm, and generates a character encoding mapping table; The scrambled font file acquisition module D33: parses the font file corresponding to the font style used in the protected area of the webpage content in HTML format, parses the character mapping table cmap in the font file, replaces the Unicode code corresponding to the glyph name glyph with the character code mapping table, and obtains the scrambled font file; A font storage table acquisition module D34: deeply compresses the scrambled font file using a font subset program to obtain font information of characters used in the webpage content protection area in the HTML format, renames the font names in the font information according to the order in which the characters appear, and obtains a font storage table of a subset font file of the scrambled font file; Watermark font file generation module D35: assigns a unique digital number as a watermark identifier to the website login user. The watermark identifier is composed of N bits of binary coded watermark information. The specific calculation method is: The number of website users is preset to be a, the watermark information capacity is preset to be b, where b=2^c and b≥a, a d-bit CRC check code is calculated, and the concatenation of c and d is equal to N, that is, N=c+d; Among them, parameters a, b, c, d, and N are all real numbers greater than 0; Parsing the glyph storage table of the subset font file, sequentially reading the glyph data of each character in the glyph storage table of the subset font file, and embedding the watermark in the following manner, including: No watermark embedding is performed on single-contour glyphs; Embed 1-bit watermark information into the glyphs of multiple contours, sort them according to the coordinates of the contour starting points, store them in sorted order when the embedded watermark information bit is "0", and store them in reverse order when the embedded watermark information bit is "1", and cyclically embed the unique digital number watermark identification information assigned to the logged-in user until the watermark embedding is completed, and obtain the watermark font file; Web page output response module D36: Encode the watermark font file into a base64 string, write CSS to define a custom font in a preset writing method, and modify the font-family attribute of the font style used in the HTML format web page content protection area to the custom font name, wherein the preset writing method is: / *Define custom font* / @font-face { font-family: 'MyCustomFont'; src: url('data:font / ttf;charset=utf- 8;base64,YOUR_Base64_ENCODED_FONT_STRING') format('truetype'); font-weight:normal; font-style:normal; } Traversing the text characters in the content protection area of the HTML-formatted webpage, converting the unicode codes of the text characters according to the character code mapping table and replacing them; The HTML-formatted web page after executing the above process is output as a response to the logged-in user.
8. A system for tracing and blocking pirated websites, using the method for tracing and blocking pirated websites as claimed in claim 6, comprising: Web page structure analysis module D41: a user logs in to a pirated website and browses the HTML-formatted web page of the pirated website; The font file conversion module D42 performs structural analysis on the HTML-formatted webpage, locates the embedded font in the CSS style area, and the embedded font is encoded in base64; and converts the embedded font encoded in base64 into a binary font file; The 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, and after excluding the glyph of one outline, extracts the watermark information bit by bit from the storage order of the glyph outline according to the inverse operation of watermark embedding and splices them into complete watermark information and CRC check code. The watermark information that passes the CRC check is considered to be extracted successfully, otherwise, continue to read the remaining characters for extraction; Retroactive blocking module D44: uses the watermark information to query the user account with the unique digital number corresponding to the system user account of the legitimate website stolen by the pirated website crawler, prohibits the user account from continuing to access the legitimate website, and blocks the user account from pirating.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, an anti-crawler tracing method based on font file re-arrangement as claimed in any one of claims 1 to 5 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, an anti-crawler tracing method based on font file re-arrangement as claimed in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Anti-crawler data processing method, device, system and storage medium
CN110990799A
Webpage text encryption and decryption method based on random fonts
CN111859853A
Webpage information anti-leakage method and device
CN114756794A
System and method for preventing web crawler access
US20100023751A1
Character updating method and apparatus
US20160299877A1