WebShell interception method, system, medium and computer equipment
By generating a unique identification code for uploaded files and performing path matching, combined with regular matching detection, the problem that WebShell interception method cannot be effectively intercepted in the existing technology is solved, and accurate detection and interception of WebShell is achieved.
Patent Information
- Application Number
- CN202111258844.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-10-28
AI Technical Summary
The existing WebShell interception method cannot effectively intercept the flexible and variable characteristics of WebShell, resulting in being bypassed.
By generating a unique identification code for uploading files and storing it with the file contents in the database, modifying the file path name to include the identification code, matching the network request path to confirm the consistency of the file content, and if it is inconsistent, a regular matching check is performed to detect whether it is a WebShell.
A comprehensive and accurate detection of WebShell is achieved, avoiding the problems of high false alarm rates and missed alarm rates, and improving the accuracy of interception.
Smart Images

Figure CN113992409B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of WebShell interception, and in particular to a WebShell interception method, system, medium and computer equipment. Background Art
[0002] Web Application Firewall (WAF) is a product that provides protection for Web applications by executing a series of security policies for HTTP / HTTPS.
[0003] WebShell is a code execution environment in the form of web page files such as asp, php, jsp or cgi, which is mainly used for website management, server management, permission management and other operations. It is easy to use. You only need to upload a code file and access it through the URL to perform many daily operations, which greatly facilitates the user's management of websites and servers. Because of this, a small number of people modify the code and use it as a backdoor program to achieve the purpose of controlling the website server.
[0004] As the name implies, "web" means that the server needs to open web services, and "shell" means obtaining certain operating commands on the server. WebShell is mainly used for website and server management. Due to its convenience and powerful functions, specially modified WebShell is also used by some people as a website backdoor tool.
[0005] WAF generally uses regular matching to check WebShell, but because the methods and features of WebShell are very flexible and changeable, it is often easy to be bypassed using ordinary feature value matching. Summary of the invention
[0006] In view of the above-mentioned defects of the prior art, the technical problem to be solved by the present invention is that the existing interception method cannot effectively intercept WebShell.
[0007] To achieve the above-mentioned purpose, the present invention provides a WebShell interception method, comprising: determining whether a request interface is a file upload interface; if it is a file upload interface, generating a corresponding unique identification code for the uploaded file, and saving the unique identification code and the uploaded file content to form an identification code set and an uploaded file content set; modifying the path name of the uploaded file so that the path name at least contains the unique identification code; receiving a current network request, and matching the network path of the current network request with the identification code set to confirm whether the network path contains the unique identification code in the identification code set; if the match is successful, confirming whether the file content requested by the current network request is consistent with the uploaded file content corresponding to the matched unique identification code; if they are consistent, passing the current network request; otherwise, detecting whether the uploaded file content is a WebShell based on regular matching, and performing corresponding interception or passing operations according to the detection result.
[0008] In a preferred embodiment of the present invention, the determination of whether the request interface is a file upload interface includes: determining whether the HTTP header of the request interface matches the HTTP header of the standard interface; if so, determining that the request interface is a file upload interface; otherwise, determining that the request interface is not a file upload interface.
[0009] In another preferred embodiment of the present invention, the unique identification code includes a UUID identification code.
[0010] In another preferred embodiment of the present invention, the encoding rules of the UUID identification code include: 1 to 8 bits use the system time; 9 to 16 bits use the underlying IP address; 17 to 24 bits use the HashCode value of the current object; 25 to 32 bits use a random number of the calling method.
[0011] In another preferred embodiment of the present invention, the method of generating a corresponding unique identification code for the uploaded file and saving the unique identification code and the uploaded file content to form an identification code set and a file content set includes: generating a UUID identification code for the uploaded file; storing the file content in a database using the UUID identification code as a key value; wherein each record in the database represents an uploaded file, and the file content in the database is retrieved using the UUID as a key value.
[0012] In another preferred embodiment of the present invention, it also includes: when modifying the path name of the uploaded file, the path name also includes the file type; replacing the original file name with the unique identification code of the uploaded file and retaining the file type.
[0013] In another preferred embodiment of the present invention, the detecting whether the file content is a WebShell based on regular expression matching includes: detecting whether the file content is a WebShell according to the response content of the operating system command.
[0014] To achieve the above-mentioned purpose, the present invention provides a WebShell interception system, comprising: an interface module, used to determine whether a request interface is a file upload interface; a unique identification code module, used to generate a corresponding unique identification code for the uploaded file after determining that the request interface is an upload interface, and save the unique identification code and the uploaded file content to form an identification code set and a file content set; a path modification module, used to modify the path name of the uploaded file so that the path name at least contains the file type and the unique identification code; a path matching module, used to receive a current network request, and match the network path of the network request with the identification code set to confirm whether the network path contains the unique identification code in the identification code set; an interception judgment module, used to confirm whether the file content requested by the current network request is consistent with the file content corresponding to the matched unique identification code if the match is successful; if they are consistent, the current network request is passed; otherwise, based on regular matching, whether the file content is WebShell is detected, and corresponding interception or passing operations are performed according to the detection result.
[0015] To achieve the above-mentioned purpose and other related purposes, the third aspect of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the WebShell interception method is implemented.
[0016] To achieve the above-mentioned purpose and other related purposes, the fourth aspect of the present application provides a computer device, including: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the device executes the WebShell interception method.
[0017] The WebShell interception method, system, medium and computer equipment provided by the present invention have the following technical effects: the present invention configures a unique identification code for the uploaded file, and stores both the unique identification code and the file content in a database; modifies the file path name according to the unique identification code; when there is a new network request, determines whether the network path contains the stored unique identification code, and if so, further determines whether the file content is consistent; if consistent, it means that it is a normal operation and needs to be released; if inconsistent, it means that it is not a normal operation, and strict regular matching is required to detect whether it is a WebShell. In addition, the present invention uses operating system instructions to detect WebShell, so it can achieve comprehensive and accurate detection.
[0018] The concept, specific structure and technical effects of the present invention will be further described below in conjunction with the accompanying drawings to fully understand the purpose, characteristics and effects of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flowchart of a WebShell interception method in one embodiment of the present invention.
[0020] Figure 2 It is a structural diagram of a WebShell interception system in one embodiment of the present invention.
[0021] Figure 3 It is a schematic diagram of the structure of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0022] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0023] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present invention in a schematic manner, and thus the illustrations only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0024] While some exemplary embodiments of the present invention have been described for the purpose of illustration, it should be understood that the present invention may be implemented in other ways not specifically shown in the drawings.
[0025] like Figure 1 As shown, a flow chart of a WebShell interception method in an embodiment of the present invention is shown. The WebShell interception method of this embodiment is applied to a web application protection system (WAF) to prevent the web from being invaded and tampered with and maintain the security of the website. The web application protection system can be a hardware device, a software product or a cloud-based WAF.
[0026] Specifically, the hardware WAF exists in the form of an independent hardware device, and supports deployment in the network in a variety of ways (such as transparent bridge mode, bypass mode, reverse proxy, etc.) to provide security protection for back-end Web applications. The software product WAF is implemented in a pure software manner, such as ModSecurity, Naxsi, Website Security Dog, etc., and exists in the form of a software product, with the advantages of simple installation, easy use, and low cost. The cloud-based WAF establishes a virtual host for the protected Web server, provides corresponding security policies for each virtual host to protect it, and configures the Web application firewall as a reverse proxy server to proxy the Web server's connection requests to the external network; when the Web application firewall can proxy the host on the external network to access the internal Web server, the Web application firewall appears to the outside as a Web server; it is responsible for forwarding requests on the external network to the internal application server, and then returning the internal response data to the external network; the Web application firewall does not save any real data of the internal server, and all static web pages or CGI programs are saved on the internal Web server; therefore, attacks on the Web application firewall will not cause the web page information to be destroyed, thereby enhancing the security of the Web server.
[0027] The WebShell interception method provided in this embodiment mainly includes steps S11 to S16. The execution process and principle of each step will be further explained below.
[0028] Step S11: Determine whether the request interface is a file upload interface.
[0029] It should be understood that since the WebShell of external attacks is mainly uploaded to the server through the file upload function, and then the WebShell is caused by server parsing problems, it is necessary to control the entrance of the uploaded file.
[0030] In some examples, the process of determining whether a request interface is a file upload interface includes: determining whether the request interface is a file upload interface, and the process includes: determining whether the HTTP header of the request interface matches the HTTP header of the standard interface; if they match, determining that the request interface is a file upload interface; otherwise, determining that the request interface is not a file upload interface.
[0031] For example, the HTTP header Content-Type of a standard interface with file upload function is multipart / form-data. Therefore, if the HTTP header of the request interface matches the above HTTP header, the specification is a file upload interface.
[0032] Step S12: If it is a file upload interface, a corresponding unique identification code is generated for the uploaded file, and the unique identification code and the uploaded file content are saved to form an identification code set and an uploaded file content set.
[0033] In some examples, the unique identification code is UUID, that is, after the request interface is judged to be a file upload interface, a unique identification code UUID is generated for each uploaded file to uniquely identify its identity, such as c8237826-3426-41f9-b5df-2567411c0446, and then the UUID and the corresponding uploaded file content are saved.
[0034] It should be noted that UUID is the abbreviation of Universally Unique Identifier, which is a software construction standard. Its purpose is to allow all elements in a distributed system to uniquely identify new information without the need for a central control terminal to specify identification information. In this way, each user can create a UUID that does not conflict with others. In this case, there is no need to consider the problem of name duplication when creating a database. In addition, UUID is a 128-bit value that can be calculated using a certain algorithm. In order to improve efficiency, commonly used UUIDs can be shortened to 16 bits. UUID is calculated based on data such as the current time, counter, and hardware identification (usually the MAC address of a wireless network card). UUIDs have no centralized management agency, and they are unique identifiers that will not be copied.
[0035] Furthermore, UUID is defined as a string primary key, composed of 32 digits, encoded in hexadecimal, and defines system information that is completely unique in time and space; the encoding rules of UUID are as follows: ① 1 to 8 digits use system time, which is accurate to milliseconds in system time to ensure uniqueness in time; ② 9 to 16 digits use the underlying IP address to ensure uniqueness in the server cluster; ③ 17 to 24 digits use the HashCode value of the current object to ensure uniqueness on an internal object; ④ 25 to 32 digits use a random number of the calling method to ensure millisecond-level uniqueness within an object. The above four strategies can ensure uniqueness, and the UUID algorithm can be considered wherever random numbers are needed in the system.
[0036] In this embodiment, the unique identification code and uploaded file content are saved to form an identification code set and a file content set, including the following process: using UUID as the key value, the file content is stored in the database; a record in the database represents an uploaded file, and in subsequent retrieval, the file content of the record can be retrieved according to UUID as the key.
[0037] Step S13: modifying the path name of the uploaded file so that the path name at least includes the file type and the unique identification code.
[0038] In some examples, the path name of the uploaded file can be modified in the form of "unique identification code. file type". For example: the uploaded file is a.php file, and its corresponding unique identification code UUID is c8237826-3426-41f9-b5df-2567411c0446, so the path name of the uploaded file needs to be modified to c8237826-3426-41f9-b5df-2567411c0446.php.
[0039] It should be noted that the above examples are provided for illustrative purposes and should not be construed as restrictive. The modification method of the path name of the uploaded file is not limited to the "unique identification code + file type" method. In actual applications, for example, other content (such as upload date or file creator information, etc.) other than the unique identification code and file type may also be added, which is not limited in this embodiment.
[0040] Step S14: receiving a current network request, and matching a network path of the current network request with the identification code set to confirm whether the network path contains a unique identification code in the identification code set.
[0041] Specifically, when a new network request is received (such as a download request or an access request, etc.), the network path of the network request needs to be detected, for example, a string match is performed one by one between the network path of the network request and each unique identification code in the unique identification code. A successful match indicates that the network path contains a unique identification code in the identification code set.
[0042] Step S15: If the match is successful, confirm whether the file content requested by the current network request is consistent with the uploaded file content corresponding to the matched unique identification code.
[0043] In some examples, the corresponding file content is retrieved from the database using the matched unique identification code as a key, and the file content is matched with the file content requested by the current network request (such as the file content currently being accessed or downloaded).
[0044] Step S16: If they are consistent, the current network request is allowed. That is, if the file content when the file is uploaded is consistent with the file content when it is accessed, it means that it is a normal file upload and download request, which should be allowed and not blocked.
[0045] Step S17: If not, detect whether the uploaded file content is a WebShell based on regular matching, and perform corresponding interception or release operations according to the detection result. It should be understood that if the file content is inconsistent, it means that it is not a normal file upload and download request, and further detection is required to determine whether it is a WebShell.
[0046] WebShell detection methods usually include static detection methods: using a series of predefined regular expressions to match the signature code, signature value, dangerous function, etc. in the script file to find WebShell; although it has the advantages of simple implementation and convenient deployment, it can only find known WebShells, and the false positive rate and missed rate are relatively high. In addition, the maintenance of the regular expression library needs to ensure the detection rate under the condition of low false positive rate, and the performance of regular matching is very dependent on the writing of regular expressions. There are many ways to write regular expressions for the same detection purpose, and the performance of different writing methods is very different, so it is particularly challenging and dependent on the regular expression writing ability of the regular expression library maintainer.
[0047] At the same time, since WebShell is very flexible and changeable, it may not be very meaningful to detect the request content, but for the response, the main return is the operating system command line. In view of this, the present invention proposes a solution, which changes the regular matching rule from the request detection of WebShell to the response content detection of the operating system command. The content of WebShell is mainly in the form of <% eval request ("sb") %>, <% execute request ("sb") %><% '<% loop <%: %> and other forms containing language codes, and the operating system commands are mainly common operating system commands such as ls, cd, ifconfig, cat / etc / passwd. Therefore, if the operating system instruction matches successfully, it is considered that there is a problem, the request is intercepted, and the content of the uploaded file can also be reported to be manually identified as a webshell; otherwise, the request is let go. Therefore, WebShell detection based on language content is not easy to match completely due to its flexibility, while operating system commands are relatively more fixed, easy to detect and have a higher accuracy rate.
[0048] It is worth noting that the WebShell interception method provided in this embodiment configures a unique identification code for the uploaded file, and stores both the unique identification code and the file content in a database; modifies the file path name according to the unique identification code; when there is a new network request, determines whether the network path contains the stored unique identification code, and if so, further determines whether the file content is consistent; if consistent, it means that it is a normal operation and needs to be released; if inconsistent, it means that it is not a normal operation, and strict regular matching is required to detect whether it is a WebShell. In addition, the present invention uses operating system instructions to detect WebShell, so it can achieve comprehensive and accurate detection.
[0049] like Figure 2 The WebShell interception system 200 of this embodiment includes: an interface module 21, a unique identification code module 22, a path modification module 23, a path matching module 24, and an interception judgment module 25.
[0050] The interface module is used to determine whether the request interface is a file upload interface.
[0051] It should be understood that since the WebShell of external attacks is mainly uploaded to the server through the file upload function, and then the WebShell is caused by server parsing problems, it is necessary to control the entrance of the uploaded file.
[0052] In some examples, the process of determining whether a request interface is a file upload interface includes: determining whether the request interface is a file upload interface, and the process includes: determining whether the HTTP header of the request interface matches the HTTP header of the standard interface; if they match, determining that the request interface is a file upload interface; otherwise, determining that the request interface is not a file upload interface.
[0053] The unique identification code module 22 is used to generate a corresponding unique identification code for the uploaded file after determining that the request interface is an upload interface, and save the unique identification code and the uploaded file content to form an identification code set and a file content set.
[0054] In some examples, the unique identification code is UUID, that is, after the request interface is judged to be a file upload interface, a unique identification code UUID is generated for each uploaded file to uniquely identify its identity, such as c8237826-3426-41f9-b5df-2567411c0446, and then the UUID and the corresponding uploaded file content are saved.
[0055] In this embodiment, the unique identification code and uploaded file content are saved to form an identification code set and a file content set, including the following process: using UUID as the key value, the file content is stored in the database; a record in the database represents an uploaded file, and in subsequent retrieval, the file content of the record can be retrieved according to UUID as the key.
[0056] The path modification module 23 is used to modify the path name of the uploaded file so that the path name at least includes the file type and the unique identification code.
[0057] In some examples, the path name of the uploaded file can be modified in the form of "unique identification code. file type". For example: the uploaded file is a.php file, and its corresponding unique identification code UUID is c8237826-3426-41f9-b5df-2567411c0446, so the path name of the uploaded file needs to be modified to c8237826-3426-41f9-b5df-2567411c0446.php.
[0058] It should be noted that the above examples are provided for illustrative purposes and should not be construed as restrictive. The modification method of the path name of the uploaded file is not limited to the "unique identification code + file type" method. In actual applications, for example, other content (such as upload date or file creator information, etc.) other than the unique identification code and file type may also be added, which is not limited in this embodiment.
[0059] The path matching module 24 is used to receive a current network request and match the network path of the network request with the identification code set to confirm whether the network path contains a unique identification code in the identification code set.
[0060] Specifically, when a new network request is received (such as a download request or an access request, etc.), the network path of the network request needs to be detected, for example, a string match is performed one by one between the network path of the network request and each unique identification code in the unique identification code. A successful match indicates that the network path contains a unique identification code in the identification code set.
[0061] The interception judgment module 25 is used to confirm whether the file content requested by the current network request is consistent with the file content corresponding to the matched unique identification code if the match is successful; if they are consistent, the current network request is passed; otherwise, based on regular matching, whether the file content is a WebShell is detected, and corresponding interception or passing operations are performed according to the detection result.
[0062] In some examples, the corresponding file content is retrieved from the database using the matched unique identification code as a key, and the file content is matched with the file content requested by the current network request (such as the file content currently being accessed or downloaded).
[0063] If they are consistent, the current network request will not be intercepted. That is, if the file content when the file is uploaded is consistent with the file content when it is accessed, it means that it is a normal file upload and download request, which should be released and not intercepted.
[0064] If they are inconsistent, the file content is detected based on regular matching to see if it is a WebShell, and the corresponding interception or release operation is performed according to the detection result. It should be understood that if the file content is inconsistent, it means that it is not a normal file upload and download request, and further detection is required to see if it is a WebShell.
[0065] WebShell detection methods usually include static detection methods: using a series of predefined regular expressions to match the signature code, signature value, dangerous function, etc. in the script file to find WebShell; although it has the advantages of simple implementation and convenient deployment, it can only find known WebShells, and the false positive rate and missed rate are relatively high. In addition, the maintenance of the regular expression library needs to ensure the detection rate under the condition of low false positive rate, and the performance of regular matching is very dependent on the writing of regular expressions. There are many ways to write regular expressions for the same detection purpose, and the performance of different writing methods is very different, so it is particularly challenging and dependent on the regular expression writing ability of the regular expression library maintainer.
[0066] At the same time, since WebShell is very flexible and changeable, it may not be very meaningful to detect the content of the request report, but for the response, the main return is the operating system command line output. In view of this, the present invention proposes a solution, which changes the regular matching rule from the request detection of WebShell to the response content detection of the operating system command. The content of WebShell is mainly in the form of <% eval request ("sb") %>, <% execute request ("sb") %><% '<% loop <%: %> and other forms containing language codes, and the operating system commands are mainly common operating system commands such as ls, cd, ifconfig, cat / etc / passwd. Therefore, if the operating system instruction matches successfully, it is considered that there is a problem, the request is intercepted, and the content of the uploaded file can also be reported to be manually identified as a webshell; otherwise, the request is let go. Therefore, WebShell detection based on language content is not easy to match completely due to its flexibility, while operating system commands are relatively more fixed, easy to detect and have a higher accuracy rate.
[0067] It should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the interface module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0068] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0069] like Figure 3 As shown, a schematic diagram of the structure of a computer device in an embodiment of the present invention is shown. The computer device provided in this example includes: a processor 31, a memory 32, and a communicator 33; the memory 32 is connected to the processor 31 and the communicator 33 through a system bus and completes the communication between them, the memory 32 is used to store computer programs, the communicator 33 is used to communicate with other devices, and the processor 71 is used to run the computer program, so that the electronic terminal executes each step of the above WebShell interception method.
[0070] The system bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize the communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM), and may also include non-volatile memory, such as at least one disk storage.
[0071] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0072] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the WebShell interception method is implemented.
[0073] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[0074] In the embodiments provided in the present application, the computer readable and writable storage medium may include a read-only memory, a random access memory, an EEPROM, a CD-ROM or other optical disk storage device, a disk storage device or other magnetic storage device, a flash memory, a USB flash drive, a mobile hard disk, or any other medium that can be used to store a desired program code in the form of an instruction or data structure and can be accessed by a computer. In addition, any connection can be appropriately referred to as a computer-readable medium. For example, if the instruction is sent from a website, a server or other remote source using a coaxial cable, an optical fiber cable, a twisted pair, a digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwaves, the coaxial cable, optical fiber cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwaves are included in the definition of the medium. However, it should be understood that computer readable and writable storage media and data storage media do not include connections, carriers, signals, or other temporary media, but are intended to be non-temporary, tangible storage media. Disk and disc, as used in this application, includes compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers.
[0075] In summary, the present invention provides a WebShell interception method, system, medium and computer equipment, which configures a unique identification code for the uploaded file, and stores the unique identification code and the file content in a database; modifies the file path name according to the unique identification code; when there is a new network request, determines whether the network path contains the stored unique identification code, and if so, further determines whether the file content is consistent; if consistent, it means that it is a normal operation and needs to be released; if inconsistent, it means that it is not a normal operation, and strict regular matching is required to detect whether it is a WebShell. In addition, the present invention uses operating system instructions to detect WebShell, so it can achieve comprehensive and accurate detection.
[0076] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A WebShell interception method, characterized in that: include: Determine whether the request interface is a file upload interface; If it is a file upload interface, a corresponding unique identification code is generated for the uploaded file, and the unique identification code and the uploaded file content are saved to form an identification code set and an uploaded file content set; Modifying the path name of the uploaded file so that the path name at least includes the unique identification code; Receiving a current network request, and matching a network path of the current network request with the identification code set to confirm whether the network path contains a unique identification code in the identification code set; If the match is successful, confirm whether the file content requested by the current network request is consistent with the uploaded file content corresponding to the matched unique identification code; If they are consistent, the current network request is ignored; Otherwise, detect whether the uploaded file content is a WebShell based on regular matching, and perform corresponding interception or release operations according to the detection result; The unique identification code includes a UUID identification code.
2. The WebShell interception method according to claim 1, characterized in that: The determining whether the request interface is a file upload interface includes: determining whether the HTTP header of the request interface matches the HTTP header of the standard interface; if so, determining that the request interface is a file upload interface; otherwise, determining that the request interface is not a file upload interface.
3. The WebShell interception method according to claim 1, characterized in that: The encoding rules of the UUID identification code include: 1 to 8 bits use the system time; 9 to 16 bits use the underlying IP address; 17 to 24 bits use the HashCode value of the current object; 25 to 32 bits use a random number of the calling method.
4. The WebShell interception method according to claim 2, characterized in that: The generating of a corresponding unique identification code for the uploaded file and saving the unique identification code and the uploaded file content to form an identification code set and an uploaded file content set includes: Generate a UUID identification code for the uploaded file; use the UUID identification code as a key value to store the uploaded file content in a database; wherein each record in the database represents an uploaded file, and the uploaded file content in the database is retrieved according to the UUID as a key value.
5. The WebShell interception method according to claim 1, characterized in that: Also includes: When modifying the path name of the uploaded file, the path name also includes the file type; the original file name is replaced with the unique identification code of the uploaded file and the file type is retained.
6. The method according to claim 1, wherein: The detecting whether the uploaded file content is a WebShell based on regular matching includes: detecting whether the uploaded file content is a WebShell according to the response content of the operating system command.
7. A WebShell interception system, characterized in that: include: An interface module is used to determine whether the request interface is a file upload interface; A unique identification code module, used to generate a corresponding unique identification code for the uploaded file after determining that the request interface is an upload interface, and save the unique identification code and the uploaded file content to form an identification code set and an uploaded file content set; A path modification module, used for modifying the path name of the uploaded file so that the path name at least includes the file type and the unique identification code; A path matching module, used for receiving a current network request, and matching a network path of the current network request with the identification code set to confirm whether the network path contains a unique identification code in the identification code set; The interception judgment module is used to confirm whether the content of the file requested by the current network request is consistent with the content of the uploaded file corresponding to the matched unique identification code if the match is successful; if they are consistent, the current network request is passed; Otherwise, detect whether the uploaded file content is a WebShell based on regular matching, and perform corresponding interception or release operations according to the detection result; The unique identification code includes a UUID identification code.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the WebShell interception method described in any one of claims 1 to 6 is implemented.
9. A computer device, characterized in that: include: Processor and memory; The memory is used to store computer programs; The processor is used to execute the computer program stored in the memory, so that the computer device executes the WebShell interception method according to any one of claims 1 to 6.
