Web application protection method, system and computer-readable storage medium

By generating and saving parameter pictures, the problem of incomplete protection of existing web application protection methods is solved, and comprehensive security protection for web applications is achieved.

CN113918862BActive Publication Date: 2025-08-19CHINA UNITED NETWORK COMM GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111232418.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-22
Publication Date
2025-08-19
Estimated Expiration
2041-10-22

AI Technical Summary

Technical Problem

The existing web application protection methods are not comprehensive enough to protect malicious code and cannot effectively defend against cross-site scripting, SQL injection, file upload, brute-force cracking and other attacks.

Method used

The front-end sends data requests to the back-end, and the back-end parses the parameter information to generate the corresponding parameter picture and save it to the database, including determining whether it needs to be rendered and whether it contains sensitive data, adding fixed salt values, etc.

Benefits of technology

It realizes comprehensive protection of web applications, effectively defends against cross-site scripting, sql injection, file upload, brute-force cracking and other attacks, and improves security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113918862B_ABST
    Figure CN113918862B_ABST
Patent Text Reader

Abstract

The present invention provides a web application protection method, system, and computer-readable storage medium. The method comprises: a front-end sending a data request to a back-end, the data request carrying a uniform resource locator (URL) and parameter information; upon receiving the data request, the back-end parsing the parameter information to obtain corresponding parameter values; and the back-end generating corresponding parameter images based on the parameter values, and saving the parameter images to a preset database. By graphically representing parameter values, the present invention can avoid web application risks caused by inserting malicious code into parameters, effectively defend against attacks such as cross-site scripting, SQL injection, file uploads, and brute force attacks, thereby improving the security of web applications and achieving comprehensive protection for web applications. This addresses the problem that existing web application protection methods lack comprehensive protection for web applications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of web application protection, and in particular to a web application protection method, system, and computer-readable storage medium. Background Art

[0002] The internet is rapidly evolving, and web attacks are becoming increasingly frequent, with increasingly subtle attack methods. With the widespread adoption of the internet, web applications are becoming increasingly intertwined with people's lives. The primary exposure of web application backends to users lies in parameters. Attackers often carefully construct parameters and insert malicious code into them to achieve their attacks. Currently, parameter validation methods such as encoding and blacklisting and whitelisting can provide some protection.

[0003] However, encoding can only address malicious code containing special characters, rendering protection incomplete. While comprehensive blacklists and whitelists can theoretically protect against all malicious code, in practice, it's impossible to fully collect signatures for all malicious code, and thus, provide comprehensive protection. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to address the above-mentioned deficiencies in the prior art and provide a web application protection method, system and computer-readable storage medium to solve the problem that the existing web application protection methods are not comprehensive enough in protecting web applications.

[0005] In a first aspect, the present invention provides a web application protection method, applied to a system including a front-end and a back-end, the method comprising:

[0006] The front end sends a data request to the back end, wherein the data request carries a uniform resource locator URL and parameter information;

[0007] After receiving the data request, the backend parses the parameter information to obtain corresponding parameter values;

[0008] The backend generates a corresponding parameter image according to the parameter value and saves the parameter image in a preset database.

[0009] Preferably, the backend generates a corresponding parameter image according to the parameter value, specifically including:

[0010] The backend determines whether the parameter value needs to be rendered;

[0011] If so, the backend obtains the rendering style corresponding to the parameter value, and renders according to the rendering style to generate the parameter image;

[0012] If not, the backend generates the parameter image according to a preset default style.

[0013] Preferably, after the backend generates a corresponding parameter image according to the parameter value, the method further includes:

[0014] The backend determines whether the parameter value contains sensitive data;

[0015] If so, the backend adds a fixed salt value to the parameter image;

[0016] The step of saving the parameter image to a preset database specifically includes:

[0017] The parameter image with the fixed salt value added is saved in the preset database.

[0018] Preferably, after saving the parameter image to a preset database, the method further includes:

[0019] The front end sends a parameter display request to the back end;

[0020] The backend sends the parameter image to the frontend according to the parameter display request;

[0021] The front end receives the parameter image and displays the parameter image at a predetermined position;

[0022] The parameter image is a dynamic image or a static image.

[0023] Preferably, the step of saving the parameter image to a preset database specifically includes:

[0024] The parameter image is saved in the preset database in the form of a matrix.

[0025] In a second aspect, the present invention provides a web application protection system, including a front end and a back end;

[0026] The front end is used to send a data request to the back end, wherein the data request carries a uniform resource locator URL and parameter information;

[0027] The backend is used to parse the parameter information after receiving the data request to obtain the corresponding parameter value;

[0028] The backend is further configured to generate corresponding parameter images according to the parameter values and save the parameter images into a preset database.

[0029] Preferably, the backend is also used to determine whether the parameter value needs to be rendered, and when it is determined that the parameter value needs to be rendered, obtain the rendering style corresponding to the parameter value, and render according to the rendering style to generate the parameter image; and when it is determined that the parameter value does not need to be rendered, generate the parameter image according to a pre-set default style.

[0030] Preferably, the backend is also used to determine whether the parameter value contains sensitive data, and when it is determined that the parameter value contains sensitive data, add a fixed salt value to the parameter image; and save the parameter image with the fixed salt value added to the preset database.

[0031] In a third aspect, the present invention provides a web application protection system, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement the web application protection method described in the first aspect above.

[0032] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the web application protection method described in the first aspect is implemented.

[0033] The web application protection method, system, and computer-readable storage medium provided by the present invention first send a data request from the front end to the back end, the data request carrying a URL and parameter information. The back end then parses the parameter information based on the received data request to obtain corresponding parameter values. Finally, the back end generates a corresponding parameter image based on the parameter values and saves the parameter image to a preset database. By graphically representing parameter values, the present invention can avoid web application risks caused by inserting malicious code into parameters, effectively defending against attacks such as cross-site scripting, SQL injection, file upload, and brute force attacks, thereby improving the security of web applications and achieving comprehensive protection for web applications. This addresses the problem that existing web application protection methods lack comprehensive protection for web applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 : This is a flow chart of a web application protection method according to embodiment 1 of the present invention;

[0035] Figure 2 : This is a structural diagram of a web application protection system according to embodiment 2 of the present invention;

[0036] Figure 3 : This is a structural diagram of a web application protection system according to embodiment 3 of the present invention. DETAILED DESCRIPTION

[0037] In order to enable those skilled in the art to better understand the technical solutions of the present invention, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0038] It should be understood that the specific embodiments and drawings described herein are only used to explain the present invention rather than to limit the present invention.

[0039] It is understood that, in the absence of conflict, the various embodiments of the present invention and the various features in the embodiments may be combined with each other.

[0040] It can be understood that, for the convenience of description, the drawings of the present invention only show parts related to the present invention, while parts unrelated to the present invention are not shown in the drawings.

[0041] It can be understood that each unit and module involved in the embodiments of the present invention may correspond to only one physical structure, or may be composed of multiple physical structures, or multiple units and modules may be integrated into one physical structure.

[0042] It will be understood that, without conflict, the functions and steps marked in the flowcharts and block diagrams of the present invention may occur in an order different from that marked in the drawings.

[0043] It is understood that the flowcharts and block diagrams of the present invention illustrate the possible architectures, functions, and operations of the systems, devices, equipment, and methods according to various embodiments of the present invention. Each box in the flowchart or block diagram may represent a unit, module, program segment, or code, which contains executable instructions for implementing the specified functions. Moreover, each box or combination of boxes in the block diagram and flowchart may be implemented using a hardware-based system that implements the specified functions, or may be implemented using a combination of hardware and computer instructions.

[0044] It can be understood that the units and modules involved in the embodiments of the present invention can be implemented by software or hardware. For example, the units and modules can be located in a processor.

[0045] Example 1:

[0046] This embodiment provides a web application protection method, such as Figure 1 As shown, the method is applied to a system including a front end and a back end, and includes:

[0047] Step S102: the front end sends a data request to the back end, wherein the data request carries a URL (Uniform Resource Locator) and parameter information.

[0048] In this embodiment, the front-end is the portion of a web application that users can see and interact with, including the web page structure, the web's visual appearance, and web-level interaction implementation. The back-end primarily handles the corresponding business logic by interacting with a database, primarily including function implementation, data storage, and access. When a user accesses a web application page, they enter parameter values in the corresponding input boxes and click the corresponding submit button to execute the request. At this point, the front-end sends a data request to the back-end. This request carries the URL and parameter information required for the request, which may include parameter names and values.

[0049] Step S104: After receiving the data request, the backend parses the parameter information to obtain corresponding parameter values.

[0050] In this embodiment, after receiving the data request, the backend parses the parameter information and obtains the corresponding parameter value from the parsing result.

[0051] Step S106: The backend generates a corresponding parameter image according to the parameter value, and saves the parameter image into a preset database.

[0052] In this embodiment, in order to prevent attackers from attacking through carefully constructed parameter values, the back end generates corresponding parameter images according to the parameter values and saves the parameter images to a preset database, thereby being able to play a good protective role for web applications. Taking the scenario of user messages or comments as an example, when surfing the Internet, users often encounter scenarios of user messages or comment areas. The normal process is that after the user comments in the comment area, they submit the comment, and the back end stores the comment content (i.e., the parameter value) in the database. When accessing this page again, the back end extracts the comment content from the database and sends it to the front end, which is then echoed on the page. At this time, if the attacker writes a malicious script in the comment content, the browser will execute the malicious script during the page echo process. Since the comment content is visible to all users, each user will execute this malicious code when accessing the comment, which will then cause a large-scale attack. This is a typical XSS attack scenario. However, when the comment content is converted into an image by the present invention, no matter what comment content is entered in the comment area, the browser will not be able to execute the malicious script, thereby ensuring the security of the web application.

[0053] Optionally, the backend generates a corresponding parameter image according to the parameter value, which may specifically include:

[0054] The backend determines whether the parameter value needs to be rendered;

[0055] If so, the backend obtains the rendering style corresponding to the parameter value, and renders according to the rendering style to generate the parameter image;

[0056] If not, the backend generates the parameter image according to a preset default style.

[0057] In this embodiment, in order to enhance the aesthetics of the page, a corresponding parameter image can be generated according to the style to be displayed on the front end. The parameter image can be a dynamic image or a static image. When the parameter value needs to be echoed on the page, the parameter image obtained after rendering is displayed to the user, thereby improving the user's visual experience. Specifically, the back end first determines whether the parameter value needs to be rendered. Specifically, it can determine whether the parameter value needs to be rendered based on the parameter name or whether it has an associated rendering style. If the back end determines that the parameter value needs to be rendered, the back end can first obtain the rendering style corresponding to the parameter value. The rendering style can be written into a document in advance by the front end designer, and then the back end renders according to the rendering style in the document to generate the corresponding parameter image. The rendering style can be, for example, bold font, red color, etc. If the back end determines that the parameter value does not need to be rendered, the back end generates the parameter image according to a preset default style. For example, the parameter image generated by the default style can be a picture with black text on a white background.

[0058] Optionally, after the backend generates a corresponding parameter image according to the parameter value, the method may further include:

[0059] The backend determines whether the parameter value contains sensitive data;

[0060] If so, the backend adds a fixed salt value to the parameter image;

[0061] Saving the parameter image to a preset database may specifically include:

[0062] The parameter image with the fixed salt value added is saved in the preset database.

[0063] In this embodiment, to ensure data security and facilitate subsequent desalination operations, a fixed salt value can be added to the parameter image corresponding to the parameter value containing sensitive data. Specifically, the backend first determines whether the parameter value contains sensitive data. Specifically, the judgment can be made based on keywords or parameter names. For example, if the parameter value contains keywords such as passwords and ID numbers, it is determined that the parameter value contains sensitive data and needs to be encrypted. In this case, the backend adds a fixed salt value to the parameter image and stores it in the database.

[0064] In this embodiment, when the parameter value needs to be displayed, the front-end sends a parameter display request to the back-end. The back-end sends the parameter image to the front-end in response to the parameter display request. After receiving the parameter image, the front-end displays it at a predetermined location. If the parameter image has been salted, the back-end first removes the salt value to restore the parameter image before sending it to the front-end.

[0065] In this embodiment, the parameter image generated by the default style can be a grayscale image, and the parameter image generated by the rendering style can be a color image. The parameter images generated by each style can be stored in a preset database in the form of a matrix. For example, if the grayscale image has a corresponding parameter value of 1, the corresponding matrix can be as follows:

[0066]

[0067] Among them, the rows of the matrix correspond to the height of the parameter image (in pixels), the columns of the matrix correspond to the width of the parameter image (in pixels), the elements of the matrix correspond to the pixels of the parameter image, and the values of the matrix elements are the grayscale values of the pixels.

[0068] In this embodiment, if the field corresponding to the parameter value in the database is set as the primary key, for example, the parameter value is the user name (admin), the backend will generate a picture of the user name and store it in the database. The parameter picture will be used as the key value picture and stored in the form of a matrix. At this time, if the front end wants to query the user admin, the front end will send admin to the back end, and the back end will convert the parameter value admin into the corresponding parameter picture, which will be converted into a picture matrix by OpenCV or other image processing plug-ins. Then, all the key value pictures in the database will be traversed, and the corresponding matrix values will be compared to query the information corresponding to admin.

[0069] The web application protection method provided by an embodiment of the present invention first sends a data request from the front end to the back end, the data request carrying a URL and parameter information. The back end then parses the parameter information based on the received data request to obtain corresponding parameter values. Finally, the back end generates a corresponding parameter image based on the parameter values and saves the parameter image to a preset database. By graphically representing parameter values, the present invention can avoid web application risks caused by inserting malicious code into parameters, effectively defend against attacks such as cross-site scripting, SQL injection, file upload, and brute force attacks, thereby improving the security of web applications and achieving comprehensive protection for web applications. This addresses the problem that existing web application protection methods lack comprehensive protection for web applications.

[0070] Example 2:

[0071] like Figure 2 As shown, this embodiment provides a web application protection system, including a front end 12 and a back end 14;

[0072] The front end 12 is used to send a data request to the back end 14, wherein the data request carries a uniform resource locator URL and parameter information;

[0073] The backend 14 is used to parse the parameter information after receiving the data request to obtain the corresponding parameter value;

[0074] The backend 14 is further configured to generate corresponding parameter images according to the parameter values, and save the parameter images into a preset database.

[0075] Optionally, the back end 14 is also used to determine whether the parameter value needs to be rendered, and when it is determined that the parameter value needs to be rendered, obtain the rendering style corresponding to the parameter value, and render according to the rendering style to generate the parameter image; and when it is determined that the parameter value does not need to be rendered, generate the parameter image according to a pre-set default style.

[0076] Optionally, the backend 14 is also used to determine whether the parameter value contains sensitive data, and when it is determined that the parameter value contains sensitive data, add a fixed salt value to the parameter image; and save the parameter image with the fixed salt value added to the preset database.

[0077] Optionally, the front end 12 is further configured to send a parameter display request to the back end 14;

[0078] The backend 14 is further configured to send the parameter image to the frontend 12 according to the parameter display request;

[0079] The front end 12 is further configured to receive the parameter image and display the parameter image at a predetermined position;

[0080] The parameter image is a dynamic image or a static image.

[0081] Optionally, the backend 14 is specifically configured to generate a corresponding parameter image according to the parameter value, and save the parameter image in the form of a matrix into the preset database.

[0082] Example 3:

[0083] like Figure 3 As shown, this embodiment provides a web application protection system, including a memory 22 and a processor 24. The memory 22 stores a computer program, and the processor 24 is configured to run the computer program to execute the web application protection method in Example 1.

[0084] The memory 22 is connected to the processor 24 . The memory 22 may be a flash memory, a read-only memory, or other memory. The processor 24 may be a central processing unit or a single-chip microcomputer.

[0085] Example 4:

[0086] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the web application protection method in the above-mentioned embodiment 1 is implemented.

[0087] The computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program modules or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable read only memory), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory), digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer.

[0088] The web application protection systems and computer-readable storage media provided in Examples 2 to 4 first send a data request from the front end to the back end, the data request carrying a URL and parameter information. The back end then parses the parameter information based on the received data request to obtain corresponding parameter values. Finally, the back end generates corresponding parameter images based on the parameter values and saves the parameter images to a preset database. By graphically representing parameter values, the present invention can avoid web application risks caused by inserting malicious code into parameters, effectively defend against attacks such as cross-site scripting, SQL injection, file uploads, and brute force attacks, thereby improving the security of web applications and achieving comprehensive protection for web applications. This addresses the problem that existing web application protection methods lack comprehensive protection for web applications.

[0089] It will be understood that the above embodiments are merely exemplary embodiments for illustrating the principles of the present invention, and the present invention is not limited thereto. Those skilled in the art will appreciate that various modifications and improvements can be made without departing from the spirit and substance of the present invention, and such modifications and improvements are also considered to be within the scope of protection of the present invention.

Claims

1. A web application protection method, characterized in that: Applied to a system including a front-end and a back-end, the method includes: The front end sends a data request to the back end, wherein the data request carries a uniform resource locator URL and parameter information; After receiving the data request, the backend parses the parameter information to obtain corresponding parameter values; The backend generates a corresponding parameter image according to the parameter value and saves the parameter image in a preset database; After the parameter image is saved in a preset database, the method further includes: The front end sends a parameter display request to the back end; The backend sends the parameter image to the frontend according to the parameter display request; The front end receives the parameter image and displays the parameter image at a predetermined position; The parameter image is a dynamic image or a static image.

2. The web application protection method according to claim 1, characterized in that: The backend generates a corresponding parameter image according to the parameter value, specifically including: The backend determines whether the parameter value needs to be rendered; If so, the backend obtains the rendering style corresponding to the parameter value, and renders according to the rendering style to generate the parameter image; If not, the backend generates the parameter image according to a preset default style.

3. The web application protection method according to claim 2, characterized in that: After the backend generates a corresponding parameter image according to the parameter value, the method further includes: The backend determines whether the parameter value contains sensitive data; If so, the backend adds a fixed salt value to the parameter image; The step of saving the parameter image to a preset database specifically includes: The parameter image with the fixed salt value added is saved in the preset database.

4. The web application protection method according to claim 1, characterized in that: The step of saving the parameter image to a preset database specifically includes: The parameter image is saved in the preset database in the form of a matrix.

5. A web application protection system, characterized in that: Including front-end and back-end; The front end is used to send a data request to the back end, wherein the data request carries a uniform resource locator URL and parameter information; The backend is used to parse the parameter information after receiving the data request to obtain the corresponding parameter value; The backend is further configured to generate a corresponding parameter image according to the parameter value and save the parameter image in a preset database; The front end is further configured to send a parameter display request to the back end; The backend is further configured to send the parameter image to the frontend according to the parameter display request; The front end is further configured to receive the parameter image and display the parameter image at a predetermined position; The parameter image is a dynamic image or a static image.

6. The web application protection system according to claim 5, characterized in that: The backend is also used to determine whether the parameter value needs to be rendered, and when it is determined that the parameter value needs to be rendered, obtain the rendering style corresponding to the parameter value, and render according to the rendering style to generate the parameter image; and when it is determined that the parameter value does not need to be rendered, generate the parameter image according to a pre-set default style.

7. The web application protection system according to claim 5, characterized in that: The backend is also used to determine whether the parameter value contains sensitive data, and when it is determined that the parameter value contains sensitive data, add a fixed salt value to the parameter image; and save the parameter image with the fixed salt value added to the preset database.

8. A web application protection system, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement the web application protection method according to any one of claims 1 to 4.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the web application protection method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Information processing method and device, information display method and device, electronic device and server

    CN110098995A

  • Image encryption and decryption method, related device and storage medium

    CN110312054A