WO2020019514A1 - 一种注入漏洞检测方法及装置 - Google Patents

一种注入漏洞检测方法及装置 Download PDF

Info

Publication number
WO2020019514A1
WO2020019514A1 PCT/CN2018/108717 CN2018108717W WO2020019514A1 WO 2020019514 A1 WO2020019514 A1 WO 2020019514A1 CN 2018108717 W CN2018108717 W CN 2018108717W WO 2020019514 A1 WO2020019514 A1 WO 2020019514A1
Authority
WO
WIPO (PCT)
Prior art keywords
page
request
field
parameter set
node
Prior art date
Application number
PCT/CN2018/108717
Other languages
English (en)
French (fr)
Inventor
熊庆昌
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020019514A1 publication Critical patent/WO2020019514A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1433Vulnerability analysis

Definitions

  • the present application relates to the field of Internet technologies, and in particular, to a method and a device for detecting an injection vulnerability.
  • the injection vulnerability is generated when the code is written without judging the legality of the user input data. Similarity detection is a common method in injection vulnerability detection.
  • the existing similarity detection mainly uses similar algorithms (such as local sensitive hashing algorithm simhash, minimum hashing algorithm minhash, etc.) to calculate page content returned by true logic (sql true logic) requests and false logic (sql false logic) requests.
  • the similarity value of the returned page content When the similarity value is greater than the preset threshold, the two pages are considered to be similar and there is no injection vulnerability. When the similarity value is less than the preset threshold, the two pages are considered to be not similar and there is an injection vulnerability.
  • the embodiments of the present application provide a method and a device for detecting an injection vulnerability, which can reduce the number of false positives and improve the accuracy of detecting an injection vulnerability.
  • an embodiment of the present application provides an injection vulnerability detection method, which includes:
  • a first parameter set is obtained, where the first parameter set includes different page parameters between the first page and the second page, the first page is a page returned by the server for a first request of a first logical type, and the second page A page returned by the server for a second request of a second logical type;
  • a second parameter set is obtained, and the second parameter set includes different page parameters between the N third pages and every two pages in the first page, and each of the M fourth pages and each of the second pages Different page parameters between two pages;
  • an injection vulnerability detection device where the device includes:
  • a first obtaining module configured to obtain a first parameter set, where the first parameter set includes different page parameters between the first page and the second page, and the first page is returned by the server for a first request of a first logical type
  • the second page which is the page returned by the server for the second request of the second logical type
  • the transceiver module is configured to send N third requests and M fourth requests to the server, and receive N third pages respectively returned by the server for the N third requests and return respectively for the M fourth requests M fourth pages, where the third request is a request obtained by inserting any field of the first logical type in the target request for injection vulnerability detection, and the fourth request is inserting the second logic in the target request Requests for any field of type;
  • a second obtaining module configured to obtain a second parameter set, where the second parameter set includes different page parameters between the N third pages and every two pages in the first page, and the M fourth pages And different page parameters between every two pages in the second page;
  • a determining module configured to determine that an injection vulnerability exists in the server when at least one page parameter exists in the first parameter set and is not in the second parameter set.
  • an embodiment of the present application provides a terminal, including a processor, an input device, an output device, and a memory.
  • the processor, the input device, the output device, and the memory are connected to each other.
  • the memory is used to store and support the execution of the terminal.
  • the computer program of the above method, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the injection vulnerability detection method of the first aspect.
  • an embodiment of the present application provides a computer-readable storage medium.
  • the computer storage medium stores a computer program, where the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the foregoing first On the one hand injection detection methods.
  • whether the page parameters in the first parameter set are all in the second parameter set is used to determine whether an injection vulnerability exists in the server, which can reduce the number of false positives and improve the accuracy of detecting the injection vulnerability.
  • FIG. 1 is a schematic diagram of a data structure of an HTTP request
  • FIG. 2 is a schematic flowchart of an injection vulnerability detection method according to an embodiment of the present application.
  • Figure 3a is a schematic diagram of an HTML DOM tree
  • 3b is a schematic diagram of a third node set and a first node set
  • 3c is a schematic diagram of a fourth node set and a second node set
  • FIG. 4 is another schematic flowchart of an injection vulnerability detection method according to an embodiment of the present application.
  • 5a is a schematic diagram of a DOM tree structure of a first page
  • FIG. 5b is a schematic diagram of a first DOM node
  • 5c is a schematic diagram of a DOM tree structure of a second page
  • 5d is a schematic diagram of a second DOM node
  • FIG. 6 is a schematic block diagram of an injection vulnerability detection device according to an embodiment of the present application.
  • FIG. 7 is a schematic block diagram of a terminal according to an embodiment of the present application.
  • the target request, the first request, the second request, the third request, and the fourth request in the embodiments of the present application may be different Hypertext Transfer Protocol (HTTP) requests, respectively.
  • HTTP Hypertext Transfer Protocol
  • An HTTP request can refer to a request message from the client to the server.
  • FIG. 1 is a schematic diagram of a data structure of an HTTP request. Among them, the HTTP request consists of three parts: request line, request header, and request body (request data).
  • the HTTP request line contains the request method (such as GET or POST), the Uniform Resource Locator (URL) corresponding to the request, and the protocol name / version number used; the HTTP request header contains many header field names and values , Such as the Host field, Referer field, Cookie field, etc .; the HTTP request body contains the query string information submitted by the customer.
  • the Host field is used to indicate the domain name (IP address) and port number of the server requesting access; the Referer field is used to tell the server which page the request came from; the Cookie field is used to maintain the server session state, usually written by the server In, in subsequent requests, it is read by the server.
  • the HTTP request will be taken as an example for description below.
  • the injection vulnerability detection method provided in the embodiments of the present application can be applied to terminals such as smart phones, tablet computers, and desktop computers.
  • the injection vulnerability detection method provided by the embodiment of the present application may be executed by any terminal of any of the types described above, or may be executed by a functional module (such as a browser, etc.) of any terminal of any of the types described above.
  • a functional module such as a browser, etc.
  • the injection vulnerability detection method may include steps:
  • the terminal obtains a first parameter set.
  • the terminal may send a first request of true logic and a second request of false logic, and receive a first page returned by the first request and a second page returned by the second request.
  • the terminal uses a page similarity algorithm (such as a locally sensitive hash algorithm simhash, a minimum hash algorithm minhash, etc.) to calculate the similarity value between the first page and the second page, and can determine whether the similarity value is less than a preset Similarity threshold (such as 95%). If yes, that is, the similarity value is less than a preset similarity threshold, indicating that an injection loophole may exist in the server, and the terminal may obtain the first parameter set.
  • a page similarity algorithm such as a locally sensitive hash algorithm simhash, a minimum hash algorithm minhash, etc.
  • the similarity value at this time is less than the preset similarity threshold value may be because the page itself is dynamically changed, or the page returned by some pages when multiple requests are dynamically changed, so by calculating the similarity of the two pages The degree value does not determine whether an injection vulnerability exists in the server.
  • the terminal may obtain the first parameter set from a local storage or a server.
  • the first parameter set may exist in the form of a set, a list, or the like.
  • the first parameter set may include different page parameters between the first page and the second page.
  • the first page may be a page returned by a first HTTP request of a first logical type
  • the second page may be a page targeted at a first Two logical types of pages returned by a second HTTP request.
  • the first logic type may be true logic
  • the second logic type may be false logic.
  • the first HTTP request of the first logical type may be determined by inserting a first field of the first logical type in a target HTTP request for injection vulnerability detection, and the second HTTP request of the second logical type may be determined by the target
  • the second field of the second logical type inserted in the HTTP request is determined.
  • the terminal may use a hierarchical parsing tool (such as DOM4J) to parse the first page returned by the server for the first HTTP request of the first logical type according to the document object model (DOM).
  • DOM document object model
  • a first node set including at least one first DOM node is obtained, and the second page returned by the server for the second HTTP request of the second logical type can be parsed according to the DOM to obtain a second node including at least one second DOM node set. Then compare whether the first node set and the corresponding DOM node of the second node set are the same, and record different DOM nodes between the first node set and the corresponding DOM node of the second node set to the first parameter. set.
  • the DOM can logically build a tree model for an HTML document by parsing a Hypertext Markup Language (HTML) document.
  • HTML DOM Hypertext Markup Document Object Model
  • everything in an HTML document is a node, the entire document is a document node, each HTML element is an element node, and the text within the HTML element Are text nodes, each HTML attribute is an attribute node, and a comment is a comment node.
  • Figure 3a it is a schematic diagram of the HTML DOM tree. Among them, the root element is the root node, and the element is the child node.
  • Each HTML document can be parsed into a root element and one or more elements according to the DOM.
  • the terminal sends N third requests and M fourth requests to the server, and receives N third pages returned by the server for the N third requests and M fourth pages returned for the M fourth requests, respectively. .
  • the terminal may insert N fields of the first logical type into a target HTTP request for injection vulnerability detection, obtain N third HTTP requests of the first logical type, and may M fields of the second logical type are inserted into the target HTTP request to obtain M fourth HTTP requests of the second logical type.
  • the terminal may send the N third HTTP requests and the M fourth HTTP requests to the server.
  • the server After receiving the N third HTTP requests and the M fourth HTTP requests, the server returns the server for each HTTP request. For a page corresponding to an HTTP request, the terminal may receive the N third pages returned by the server for the N third requests and the M fourth pages returned for the M fourth requests.
  • an HTTP request can be obtained for each field inserted in the target HTTP request.
  • the N and the M may be integers greater than or equal to 1, and the sizes of the N and the M may be equal or unequal, which is not limited in the embodiment of the present application.
  • the field of the first logical type may be a structured query language (SQL) statement of true logic
  • the field of the second logical type may be a SQL statement of false logic.
  • the question mark "?” Character is used to separate file names and parameters in the URL.
  • the terminal can extract the URL carried by the target HTTP request from the target HTTP request used for injection vulnerability detection, and then insert true logical N SQL statements into the parameter field of the URL to obtain N logical third third HTTP requests. , And you can insert M logical SQL statements of false logic in the parameter field of the URL to get M fourth HTTP requests of false logic.
  • the terminal may send the N third HTTP requests and the M fourth HTTP requests to the server. After receiving the N third HTTP requests and the M fourth HTTP requests, the server returns the server for each HTTP request. For a page corresponding to an HTTP request, the terminal may receive the N third pages returned by the server for the N third requests and the M fourth pages returned for the M fourth requests.
  • the terminal obtains an HTTP request for each SQL statement inserted in the parameter field of the URL.
  • the N true logic SQL statements may be different, or part of them may be different; the M false logic SQL statements may be different, or part of them may be different, which is not limited in the embodiment of the present application.
  • the terminal can preset multiple true logical SQL statements and multiple false logical SQL statements.
  • the terminal can select from multiple preset true logical SQL statements.
  • the SQL statement is optionally inserted with a truly logical SQL statement.
  • the terminal when the terminal inserts a false logical SQL statement into the parameter field of the URL, it can also select one false logical SQL statement from a plurality of preset false logical SQL statements for insertion.
  • the URL in the third HTTP request For http://xxx.pingna.com/sql.php?
  • the terminal may insert true logical N SQL statements into the target field of the target HTTP request used for injection vulnerability detection to obtain true logical N third HTTP requests, and may M false SQL statements are inserted into the target field of the request to obtain M fourth HTTP requests of false logic.
  • the terminal may send the N third HTTP requests and the M fourth HTTP requests to the server.
  • the server After receiving the N third HTTP requests and the M fourth HTTP requests, the server returns the server for each HTTP request. For a page corresponding to an HTTP request, the terminal may receive the N third pages returned by the server for the N third requests and the M fourth pages returned for the M fourth requests.
  • the target field may include one or more of a Host field, a Referer field, and a Cookie field.
  • the third HTTP request and the fourth HTTP request are respectively determined by inserting SQL statements of different logical types into the same field of the target HTTP request.
  • the Host field of the target HTTP request is "ulog.jd.com”
  • the Referer field is http://xx.xx.xx.com/xx.html
  • the logical SQL statement "or 1 ⁇ 2" obtains another truly logical third HTTP request.
  • the Host field of the third HTTP request is "ulog.jd.comor 1 ⁇ 2".
  • the Host field of the fourth HTTP request is "ulog.jd.com and 2> 112".
  • the terminal when the terminal sends N third HTTP requests and M fourth HTTP requests to the server, the terminal may cross-send, such as sending a third HTTP request, then sending a fourth HTTP request, and then sending Send another third HTTP request, and then send another fourth HTTP request until all HTTP requests have been sent.
  • the terminal may also send N third HTTP requests and M fourth HTTP requests in sequence, for example, send the fourth HTTP request after N third HTTP requests have been sent.
  • This embodiment of the present application does not limit this.
  • multiple HTTP requests can be sent periodically at a preset time interval, or they can be sent as fast as possible.
  • the embodiment of this application does not limit the time interval between sending multiple HTTP requests.
  • the terminal obtains a second parameter set.
  • the terminal may use a hierarchical parsing tool. (Such as dom 4j) parse each third page of the N third pages according to the DOM to obtain N DOM trees, and then extract N third node sets from the N DOM trees, each third The node set includes at least one DOM node.
  • the terminal can use dom 4j to parse each fourth page of the M fourth pages according to the DOM to obtain M DOM trees, and then extract M fourth node sets from the M DOM trees.
  • Each fourth node set includes at least one fourth DOM node.
  • a DOM tree corresponds to a collection of nodes.
  • the terminal may compare whether the DOM nodes between the N third node sets and each two node sets in the first node set are the same, and the N third node set and each two node sets in the first node set.
  • the different DOM nodes are recorded in the second parameter set.
  • the different DOM nodes between the node sets are also recorded in the second parameter set.
  • FIG. 3b it is a schematic diagram of a third node set and a first node set.
  • N 2
  • the DOM nodes included in the third node set 1 are: "root element ⁇ bookstore>: Sisyphus Bookstore, element ⁇ book>: books, element ⁇ title>: Harry Potter, element ⁇ author>: J K.Rowling, element ⁇ year>: 2005, element ⁇ price>: 29.99 ".
  • the DOM nodes included in the third node set 2 are: "Root element ⁇ bookstore>: Sisyphus bookstore, element ⁇ book>: book, element ⁇ title>: Harry Potter, element ⁇ author>: JK.Rowling, element ⁇ year>: 2005, element ⁇ price>: 28.9 ".
  • the DOM nodes included in the first node set are: "root element ⁇ bookstore>: Sisyphus Bookstore, element ⁇ book>: book, element ⁇ title>: Harry Potter, element ⁇ author>: J.Kowling, element ⁇ year >: 2005, element ⁇ price>: 29.99 ".
  • the terminal compares whether there are different DOM nodes between the second node set and the fourth node set 1, and compares whether there are different DOM nodes between the second node set and the fourth node set 2. Whether there are different DOM nodes between the four-node set 1 and the fourth node set 2, as can be seen from FIG. 3c, different DOM nodes "element ⁇ year>" are recorded into the second parameter set. At this time, the second parameter set includes two DOM nodes of "element ⁇ year> and element ⁇ price>".
  • the terminal determines that an injection vulnerability exists in the server.
  • the terminal may compare each DOM node in the first parameter set obtained above with each DOM node in the second parameter set obtained above, so as to determine the If each DOM node is in the second parameter set, if not, it means that at least one DOM node in the first parameter set is not in the second parameter set, and the terminal can determine that an injection vulnerability exists in the server.
  • the embodiment of the present application compares whether all DOM nodes in the first parameter set (including different DOM nodes between pages returned by true logic requests and false logic requests) are in the second parameter set (including those returned by multiple true logic requests).
  • the first parameter set includes "element ⁇ title>, element ⁇ author>, and element ⁇ price>”
  • the second parameter set includes "element ⁇ year> and element ⁇ price>”.
  • the terminal searches whether the "element ⁇ title>” in the first parameter set is in the second parameter set, and finds whether the "element ⁇ author>” in the first parameter set is in the second parameter set, and then searches the first parameter set Is the "element ⁇ price>" in the second parameter set, obviously, the "element ⁇ title>, element ⁇ author>” in the first parameter set is not in the second parameter set, and the "element” in the first parameter set " ⁇ price>” is in the second parameter set, because there are 2 DOM nodes ("element ⁇ title>, element ⁇ author>”) in the first parameter set, the terminal can determine that it exists in the server Inject holes.
  • the terminal does not search for the DOM node that is not found in the first set, thereby improving processing efficiency. For example, the terminal finds whether the "element ⁇ title>" in the first parameter set is in the second parameter set. If not, the terminal directly determines that an injection vulnerability exists in the server, and no longer looks for the "element ⁇ author" in the first parameter set > And the element ⁇ price> "is in the second parameter set.
  • the first parameter set includes different page parameters between the first page and the second page, sends N third requests and M fourth requests to the server, and receives the The server obtains the N third pages returned for the N third requests and the M fourth pages returned for the M fourth requests, and then obtains a second parameter set, where the second parameter set includes the N third pages And different page parameters between every two pages in the first page, and different page parameters between each of the M fourth pages and every two pages in the second page, when at least When a page parameter is not in the second parameter set, it is determined that an injection vulnerability exists in the server, which can reduce the number of false positives and improve the accuracy of detecting an injection vulnerability.
  • the injection vulnerability detection method may include steps:
  • the terminal determines a target request for injection vulnerability detection.
  • the terminal may obtain one or more target HTTP requests preset by the user for detecting whether the server has an injection vulnerability.
  • the URL carried in the target HTTP request may be a URL existing in the server, that is, the terminal can normally access the server through the URL.
  • the terminal determines the first request and the second request according to the target request.
  • the terminal may insert a field of a first logical type in the target HTTP request determined above, obtain a first HTTP request of the first logical type, and may insert a second in the target HTTP request.
  • the first logic type may represent true logic
  • the second logic type may represent false logic.
  • the field of the first logical type may be an SQL statement of true logic
  • the field of the second logical type may be an SQL statement of false logic.
  • the terminal may insert a true logical SQL statement in a target field of the target HTTP request, obtain a first logical request of true logic, and may insert false logic in the target field of the target HTTP request.
  • the target field may include one or more of a Host field, a Referer field, and a Cookie field.
  • the first HTTP request and the second HTTP request are respectively determined by inserting SQL statements of different logical types into the same field of the target HTTP request.
  • the terminal may extract the URL carried by the target HTTP request from the target HTTP request, and then insert a true logical SQL statement in a parameter field of the URL to obtain a true logical first HTTP request. And a pseudo-logic SQL statement can be inserted into the parameter field of the URL to obtain a second HTTP request for the pseudo-logic.
  • the terminal can preset multiple true logical SQL statements and multiple false logical SQL statements. When the terminal inserts true logical SQL statements in the parameter field of the URL, the terminal can preset multiple true logical SQL statements. Select any true logical SQL statement to insert. Similarly, when the terminal inserts a false logical SQL statement into the parameter field of the URL, it can also select one false logical SQL statement from a plurality of preset false logical SQL statements for insertion.
  • the terminal sends a first request and a second request to the server, and receives a first page returned by the server for the first request and a second page returned for the second request.
  • the terminal may send the first HTTP request and the second HTTP request to the server, and the server receives the first HTTP request and the second HTTP request sent by the terminal, and targets the first HTTP The request returns a first page corresponding to the first HTTP request, and returns a second page corresponding to the second HTTP request for the second HTTP request.
  • the terminal may receive the first page and the second page.
  • the terminal records different DOM nodes between the first page and the second page to the first parameter set.
  • the terminal may use a hierarchical parsing tool (such as dom 4j) to parse the received first page according to the DOM to obtain the DOM tree structure of the first page, and then may obtain At least one first DOM node is extracted from the DOM tree structure.
  • the terminal may parse the received second page according to the DOM to obtain the DOM tree structure of the second page, and then extract at least one second DOM node from the DOM tree structure of the second page.
  • the terminal may match each first DOM node in the at least one first DOM node with each corresponding second DOM node in the at least one second DOM node, and determine that the at least one first DOM node and the at least one second DOM Different DOM nodes between nodes, and the different DOM nodes can be recorded into the first parameter set.
  • the different DOM nodes in the first parameter set may be caused by the dynamic change of the page itself or the dynamic return of the page during multiple requests, or it may be an injection vulnerability in the server.
  • the true logical SQL inserted in step S402 The statements and the pseudo-logical SQL statements are executed by the server as SQL query statements, resulting in different DOM nodes between the first page and the second page.
  • the terminal parses the first page content1 according to the DOM to obtain the DOM tree structure of content1, as shown in FIG. 5a, which is a schematic diagram of the DOM tree structure of the first page. Each element and text in the DOM tree structure can be called For a node.
  • the terminal may extract at least one first DOM node from the DOM tree structure of content1. As shown in FIG. 5b, it is a schematic diagram of a first DOM node.
  • the terminal parses the second page content2 according to the DOM to obtain the DOM tree structure of content2, as shown in FIG. 5c, which is a schematic diagram of the DOM tree structure of the second page.
  • the terminal may extract at least one second DOM node from the DOM tree structure of content2.
  • FIG. 5d it is a schematic diagram of a second DOM node.
  • the terminal may compare the content of the text node in the at least one first DOM node and the content of the text node in the at least one second DOM node, and the tag names and tag types of the element nodes ( ⁇ title>, ⁇ author>, ⁇ year>, and ⁇ price>). , Whether the content node ( ⁇ book>) has the same tag name, tag type, tag attribute, number of child nodes, type of child node, etc. If the content of a text node is different, the terminal may determine that the text node is a different DOM node between the at least one first DOM node and the at least one second DOM node.
  • the terminal may determine that the certain element node is a different DOM node between the at least one first DOM node and the at least one second DOM node. If any one of the content node has a different tag name, tag type, tag attribute, number of child nodes, and type of child nodes, the terminal may determine that the content node is the at least one first DOM node and the at least one second DOM nodes that are not the same between DOM nodes.
  • the terminal sends N third requests and M fourth requests to the server, and receives N third pages returned by the server for the N third requests and M fourth pages returned for the M fourth requests, respectively. .
  • the terminal obtains a second parameter set.
  • the terminal matches different DOM nodes in the first parameter set with different DOM nodes in the second parameter set, and determines whether each DOM node in the first parameter set is in the second parameter set. in.
  • the terminal determines that an injection vulnerability exists in the server.
  • the terminal may compare each DOM node in the first parameter set obtained above with each node in the second parameter set obtained above, so as to determine Whether each DOM node in the first parameter set is in the second parameter set; if not, it means that at least one DOM node in the first parameter set is not in the second parameter set, and the terminal can determine the server An injection vulnerability exists. If yes, it indicates that each DOM node in the first parameter set is in the second parameter set, and the terminal can determine that there is no injection vulnerability in the server.
  • the embodiment of the present application compares whether all DOM nodes in the first parameter set (including different DOM nodes between pages returned by true logic requests and false logic requests) are in the second parameter set (including those returned by multiple true logic requests). (Different DOM nodes between pages and different DOM nodes between pages returned by multiple false logic requests) can eliminate false positives of injection vulnerabilities caused by dynamic changes in the page itself or multiple requests for dynamic return, reducing injection The number of false positives of vulnerabilities improves the accuracy of detecting injected vulnerabilities.
  • the terminal may output security prompt information after determining that the server does not have an injection vulnerability, and the security prompt information is used to prompt that the server does not have an injection vulnerability, and the detection result may be conveniently viewed.
  • the terminal may output alarm prompt information, which may include a parameter field of the URL of the target HTTP request, and the alarm prompt information may be used to prompt a programmer about the parameters of the URL in the server.
  • the processing of injection vulnerabilities in the field can prevent the information of customers using the above-mentioned server from being leaked, resulting in loss of customer's property. At the same time, it is possible to find out where there are injection holes in the server faster, so that programmers can process the places where there are injection holes in the server faster.
  • the embodiment of the present application determines a target request for injection vulnerability detection, determines a first request and a second request according to the target request, and sends the first request and the second request to the server, and receives the first request returned by the server for the first request.
  • One page and the second page returned for the second request then record the different DOM nodes between the first page and the second page to the first parameter set, and then send N third requests and M fourth requests to the server And receive the N third pages returned by the server for N third requests and the M fourth pages returned for M fourth requests, and then obtain a second parameter set; then, each different DOM in the first parameter set
  • the nodes are matched with different DOM nodes in the second parameter set to determine whether each DOM node in the first parameter set is in the second parameter set.
  • the terminal determines that there is an injection vulnerability in the server.
  • the terminal Injection vulnerability does not exist to determine the server. Not only can you reduce the number of false positives and improve the accuracy of detecting injection vulnerabilities, but you can also find out where there are injection vulnerabilities in the server faster and improve the detection efficiency.
  • the injection vulnerability detection device of this embodiment includes:
  • the first obtaining module 10 is configured to obtain a first parameter set.
  • the first parameter set includes different page parameters between the first page and the second page.
  • the first page is a page returned by the server for the first request of the first logical type
  • the second page is the server directed at the first page.
  • the transceiver module 30 is configured to send N third requests and M fourth requests to the server, and receive N third pages respectively returned by the server for the N third requests and return respectively for the M fourth requests M fourth pages.
  • the third request is a request obtained by inserting any field of the first logical type in the target request for injection vulnerability detection
  • the fourth request is obtained by inserting any field of the second logical type in the target request. request.
  • the second obtaining module 30 is configured to obtain a second parameter set.
  • the second parameter set includes different page parameters between the N third pages and every two pages of the first page, and each of the M fourth pages and every two pages of the second page. Different page parameters.
  • a determining module 40 is configured to determine that an injection vulnerability exists in the server when at least one page parameter exists in the first parameter set and is not in the second parameter set.
  • the device further includes a first insertion module 50.
  • the first inserting module 50 is configured to insert a field into a parameter field of a uniform resource locator URL of the target request for any of the N fields of the first logical type to form a third request;
  • An insertion module 50 is further configured to insert any one of the M fields of the second logical type into the parameter field of the URL of the target request to form a fourth request.
  • the device further includes a second insertion module 60.
  • the second inserting module 60 is configured to insert a field into a target field of the target request to form a third request for any one of the N fields of the first logical type.
  • the second inserting module 60 also For any one of the M fields of the second logical type, insert the field into a target field of the target request to form a fourth request.
  • the target field includes one or more of a Host field, a Referer field, and a Cookie field.
  • the above-mentioned page parameters include a document object model DOM node.
  • the second obtaining module 30 is specifically configured to:
  • a page corresponds to a node set, and a node set includes at least one DOM node.
  • the device further includes a matching module 70.
  • the matching module 70 is configured to match each page parameter in the first parameter set with each page parameter in the second parameter set, and determine whether each page parameter in the first parameter set is in the In the second parameter set.
  • the matching module 70 is specifically configured to match each DOM node in the first parameter set with each DOM node in the second parameter set, and determine that in the first parameter set Whether each DOM node of is in the second parameter set.
  • the foregoing determining module 40 is further configured to determine that, when each page parameter in the first parameter set is in the second parameter set, the injection vulnerability does not exist in the server.
  • the device further includes an output module 80.
  • the output module 80 is configured to output alarm prompt information after determining that an injection vulnerability exists in the server, and the alarm prompt information is used to prompt the server that the injection vulnerability exists.
  • the output module 80 is further configured to output security prompt information when it is determined that the injection vulnerability does not exist in the server, and the security prompt information may be used to prompt that the server has been detected and does not exist. Inject holes.
  • the above-mentioned injection vulnerability detection device may implement the implementation manner provided by each step in the implementation manner provided in FIG. 2 or FIG. 4 through the foregoing modules to implement the functions implemented in the foregoing embodiments.
  • the above-mentioned injection vulnerability detection device may implement the implementation manner provided by each step in the implementation manner provided in FIG. 2 or FIG. 4 through the foregoing modules to implement the functions implemented in the foregoing embodiments.
  • the foregoing The corresponding description provided by each step in the method embodiment shown in FIG. 2 or FIG. 4 is not repeated here.
  • the injection vulnerability detection device may obtain a first parameter set, where the first parameter set includes different page parameters between the first page and the second page, and sends N third requests and M numbers to the server.
  • a fourth request and receiving the N third pages returned by the server for the N third requests and the M fourth pages returned for the M fourth requests, and then obtaining a second parameter set, the second parameter set Including different page parameters between the N third pages and every two pages in the first page, and different page parameters between the M fourth pages and every two pages in the second page, when the When at least one page parameter in the first parameter set is not in the second parameter set, it is determined that an injection vulnerability exists in the server, which can reduce the number of false positives and improve the accuracy of detecting the injection vulnerability.
  • the terminal in the embodiment of the present application may include: one or more processors 701; one or more input devices 702, one or more output devices 703, and a memory 704.
  • the processor 701, the input device 702, the output device 703, and the memory 704 are connected through a bus 705.
  • the memory 702 is configured to store a computer program, the computer program includes program instructions, and the processor 701 is configured to execute the program instructions stored in the memory 702.
  • the processor 701 is configured to call the program instruction for execution:
  • the first parameter set includes different page parameters between the first page and the second page.
  • the first page is a page returned by the server for the first request of the first logical type
  • the second page is the server directed at the first page.
  • the output device 703 is configured to send N third requests and M fourth requests to the server.
  • the above input device 702 is configured to receive N third pages respectively returned by the server for the N third requests and M fourth pages respectively returned for the M fourth requests.
  • the third request is a request obtained by inserting any field of the first logical type in the target request for injection vulnerability detection, and the fourth request is obtained by inserting any field of the second logical type in the target request. Request.
  • the processor 701 is further configured to call the program instruction for execution: obtaining a second parameter set, where the second parameter set includes different page parameters between the N third pages and every two pages in the first page , And different page parameters between the M fourth pages and every two pages of the second page;
  • the processor 701 may be a central processing unit (CPU), and the processor may also be another general-purpose processor or a digital signal processor (DSP). , Application specific integrated circuit (ASIC), ready-made programmable gate array (field-programmable gate array), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the input device 702 may include a receiver, a receiving program interface, and the like, and the output device 703 may include a transmitter, a sending program interface, and the like.
  • the memory 704 may include a read-only memory and a random access memory, and provide instructions and data to the processor 701. A portion of the memory 704 may also include non-volatile random access memory. For example, the memory 704 may also store device type information.
  • the processor 701, the input device 702, and the output device 703 described in the embodiments of the present application may execute the implementation manner described in the injection vulnerability detection method provided in the embodiments of the present application, and may also execute The implementation manner of the described injection vulnerability detection device is not repeated here.
  • An embodiment of the present application further provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program includes program instructions. When the program instructions are executed by a processor, the injection shown in FIG. 2 or FIG.
  • the program instructions are executed by a processor, the injection shown in FIG. 2 or FIG.
  • FIG. 2 or FIG. 4 For details of the vulnerability detection method, please refer to the description of the embodiment shown in FIG. 2 or FIG. 4, and details are not described herein again.
  • the computer-readable storage medium may be an injection vulnerability detection device or an internal storage unit of a terminal according to any of the foregoing embodiments, such as a hard disk or a memory of the terminal.
  • the computer-readable storage medium may also be an external storage device of the terminal, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, and a flash memory card provided on the terminal. (flash card) and so on.
  • the computer-readable storage medium may include both an internal storage unit of the terminal and an external storage device.
  • the computer-readable storage medium is used to store the computer program and other programs and data required by the terminal.
  • the computer-readable storage medium can also be used to temporarily store data that has been or will be output.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请实施例公开了一种注入漏洞检测方法及装置,其中方法包括:获取第一参数集合,该第一参数集合中包括第一页面和第二页面之间不同的页面参数,向服务器发送N个第三请求和M个第四请求,并接收该服务器针对该N个第三请求返回的N个第三页面和针对该M个第四请求返回的M个第四页面,再获取第二参数集合,该第二参数集合包括该N个第三页面和该第一页面中每两个页面之间不同的页面参数,以及该M个第四页面和该第二页面中每两个页面之间不同的页面参数,当该第一参数集合中存在至少一个页面参数不在该第二参数集合中时,则确定该服务器中存在注入漏洞。采用本申请实施例,可以减少误报的次数,提高检测注入漏洞的准确性。

Description

一种注入漏洞检测方法及装置
本申请要求于2018年7月25日提交中国专利局、申请号为201810825470X、申请名称为“一种注入漏洞检测方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及互联网技术领域,尤其涉及一种注入漏洞检测方法及装置。
背景技术
注入漏洞是编写代码的时候,没有对用户输入数据的合法性进行判断产生的。目前在注入漏洞检测中相似度检测是一种常见的方法。
现有的相似度检测,主要是利用相似算法(如局部敏感哈希算法simhash、最小哈希算法minhash等)计算真逻辑(sql真逻辑)请求返回的页面内容与假逻辑(sql假逻辑)请求返回的页面内容的相似度值。当相似度值大于预设阈值时,则认为这两个页面相似,不存在注入漏洞,当相似度值小于预设阈值时,则认为这两个页面不相似,存在注入漏洞。
然而,由于很多页面本身就是动态变化的,还有些页面在多次请求时返回的页面内容是动态变化的,因此,通过计算两个页面的相似度值来判断是否存在注入漏洞,存在大量的误报。
发明内容
本申请实施例提供一种注入漏洞检测方法及装置,可以减少误报的次数,提高检测注入漏洞的准确性。
第一方面,本申请实施例提供了一种注入漏洞检测方法,该方法包括:
获取第一参数集合,该第一参数集合中包括第一页面和第二页面之间不同的页面参数,该第一页面为服务器针对第一逻辑类型的第一请求返回的页面,该第二页面为所述服务器针对第二逻辑类型的第二请求返回的页面;
向所述服务器发送N个第三请求和M个第四请求,并接收该服务器针对该N个第三请求分别返回的N个第三页面和针对该M个第四请求分别返回的M个第四页面,其中第三请求为在用于注入漏洞检测的目标请求中插入该第一逻辑类型的任一字段得到的请求,第四请求为在该目标请求中插入该第二逻辑类型的任一字段得到的请求;
获取第二参数集合,该第二参数集合中包括该N个第三页面和该第一页面中每两个页面之间不同的页面参数,以及该M个第四页面和该第二页面中每两个页面之间不同的页面参数;
若该第一参数集合中存在至少一个页面参数不在该第二参数集合中,则确定该服务器中存在注入漏洞。
第二方面,本申请实施例提供了一种注入漏洞检测装置,该装置包括:
第一获取模块,用于获取第一参数集合,该第一参数集合中包括第一页面和第二页面之间不同的页面参数,该第一页面为服务器针对第一逻辑类型的第一请求返回的页面,该第二页面为该服务器针对第二逻辑类型的第二请求返回的页面;
收发模块,用于向该服务器发送N个第三请求和M个第四请求,并接收该服务器针对该N个第三请求分别返回的N个第三页面和针对该M个第四请求分别返回的M个第四页面,其中第三请求为在用 于注入漏洞检测的目标请求中插入该第一逻辑类型的任一字段得到的请求,第四请求为在该目标请求中插入该第二逻辑类型的任一字段得到的请求;
第二获取模块,用于获取第二参数集合,该第二参数集合中包括该N个第三页面和该第一页面中每两个页面之间不同的页面参数,以及该M个第四页面和该第二页面中每两个页面之间不同的页面参数;
确定模块,用于当该第一参数集合中存在至少一个页面参数不在该第二参数集合中时,确定该服务器中存在注入漏洞。
第三方面,本申请实施例提供了一种终端,包括处理器、输入设备、输出设备和存储器,该处理器、输入设备、输出设备和存储器相互连接,其中,该存储器用于存储支持终端执行上述方法的计算机程序,该计算机程序包括程序指令,该处理器被配置用于调用该程序指令,执行上述第一方面的注入漏洞检测方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,该计算机存储介质存储有计算机程序,该计算机程序包括程序指令,该程序指令当被处理器执行时使该处理器执行上述第一方面的注入漏洞检测方法。
本申请实施例通过比较第一参数集合中的页面参数是否全部在第二参数集合中,来判断服务器中是否存在注入漏洞,可以减少误报的次数,提高检测注入漏洞的准确性。
附图说明
图1是HTTP请求的数据结构的示意图;
图2是本申请实施例提供的一种注入漏洞检测方法的一示意流程图;
图3a是HTML DOM树的示意图;
图3b是第三节点集合和第一节点集合的示意图;
图3c是第四节点集合和第二节点集合的示意图;
图4是本申请实施例提供的一种注入漏洞检测方法的另一示意流程图;
图5a是第一页面的DOM树结构的示意图;
图5b是第一DOM节点的示意图;
图5c是第二页面的DOM树结构的示意图;
图5d是第二DOM节点的示意图;
图6是本申请实施例提供的一种注入漏洞检测装置的一示意性框图;
图7是本申请实施例提供的一种终端的一示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请实施例中的目标请求、第一请求、第二请求、第三请求、第四请求可以分别为不同的超文本传输协议(hypertext transfer protocol,HTTP)请求。HTTP请求可以指从客户端到服务器端的请求消息。如图1所示,图1为HTTP请求的数据结构的示意图。其中,HTTP请求由三个部分组成:请求行、请求头部、请求体(请求数据)。HTTP请求行中包含请求方法(如GET或POST等)、请求对应的统一资源定位符(uniform resource locator,URL)以及使用的协议名称/版本号;HTTP请求头部中包含很多头 部字段名和值,如Host字段、Referer字段、Cookie字段等;HTTP请求体中包含客户提交的查询字符串信息。Host字段用于表示请求访问的服务器的域名(IP地址)和端口号;Referer字段用于告诉服务器请求是从哪个页面链接过来的;Cookie字段用于维持服务端会话状态的,通常由服务端写入,在后续请求中,供服务端读取。为方便描述,下面将以HTTP请求为例进行说明。
本申请实施例提供的注入漏洞检测方法可适用于智能手机、平板电脑、台式电脑等终端。可选的,本申请实施例提供的注入漏洞检测方法可由上述任一类型的任一终端执行,也可为上述任一类型的任一终端中的功能模块(比如浏览器等)执行,在此不做限制。为方便描述,下面将以终端为例进行说明。
下面将结合图2至图7,对本申请实施例提供的注入漏洞检测方法及装置进行说明。
参见图2,是本申请实施例提供一种注入漏洞检测方法的一示意流程图。如图2所示,该注入漏洞检测方法可包括步骤:
S201,终端获取第一参数集合。
在一些可行的实施方式中,终端可以发送真逻辑的第一请求和假逻辑的第二请求,并接收该第一请求返回的第一页面和该第二请求返回的第二页面。终端利用页面相似度算法(如局部敏感哈希算法simhash、最小哈希算法minhash等)计算该第一页面与该第二页面之间的相似度值,并可以判断该相似度值是否小于预设的相似度阈值(如95%)。若是,即该相似度值小于预设的相似度阈值,说明服务器中可能存在注入漏洞,终端可以获取第一参数集合。但此时的相似度值小于预设的相似度阈值可能是因为页面本身是动态变化的,或某些页面在多次请求时返回的页面是动态变化的,因此,通过计算两个页面的相似度值不能确定服务器中是否存在注入漏洞。
在一些可行的实施方式中,终端可以从本地存储或服务器中获取第一参数集合。其中,该第一参数集合可以以集合、列表等形式存在。该第一参数集合中可以包括第一页面和第二页面之间不同的页面参数,该第一页面可以为针对第一逻辑类型的第一HTTP请求返回的页面,该第二页面可以为针对第二逻辑类型的第二HTTP请求返回的页面。该第一逻辑类型可以为真逻辑,该第二逻辑类型可以为假逻辑。该第一逻辑类型的第一HTTP请求可以由在用于注入漏洞检测的目标HTTP请求中插入该第一逻辑类型的第一字段确定,该第二逻辑类型的第二HTTP请求可以由在该目标HTTP请求中插入该第二逻辑类型的第二字段确定。例如,第一逻辑类型的字段为“or 1=1”、“or 1<2”或“or 2=2”等恒真的结构化查询语言(structured query language,SQL)语句,第二逻辑类型的字段为“and 1=2”、“and 1>2”或“and 21=12”等恒假的SQL语句。
在一些可行的实施方式中,终端可以利用层级解析工具(如dom 4j)将服务器针对第一逻辑类型的第一HTTP请求返回的第一页面按照文档对象模型(document object model,DOM)进行解析,得到包括至少一个第一DOM节点的第一节点集合,并可以将服务器针对第二逻辑类型的第二HTTP请求返回的第二页面按照DOM进行解析,得到包括至少一个第二DOM节点的第二节点集合。再比较该第一节点集合和该第二节点集合的对应DOM节点之间是否相同,将该第一节点集合和该第二节点集合的对应DOM节点之间不相同的DOM节点记录至第一参数集合。
需要说明的是,DOM可通过解析超文本标记语言(hypertext markup language,HTML)文档,为HTML文档在逻辑上建立一个树模型。根据万维网联盟(W3C)的HTML DOM(超文本标记语言文档对象模型)标准,HTML文档中的所有内容都是节点,整个文档是一个文档节点,每个HTML元素是元素节点,HTML元素内的文本是文本节点,每个HTML属性是属性节点,注释是注释节点。如图3a所示,是HTML DOM树的示意图。其中,根元素即根节点,元素即子节点。每个HTML文档都可以按 照DOM被解析为一个根元素和一个或多个元素。
S202,终端向服务器发送N个第三请求和M个第四请求,并接收服务器针对N个第三请求分别返回的N个第三页面和针对M个第四请求分别返回的M个第四页面。
在一些可行的实施方式中,终端可以在用于注入漏洞检测的目标HTTP请求中插入该第一逻辑类型的N个字段,得到该第一逻辑类型的N个第三HTTP请求,并可以在该目标HTTP请求中插入该第二逻辑类型的M个字段,得到该第二逻辑类型的M个第四HTTP请求。终端可以向服务器发送该N个第三HTTP请求和该M个第四HTTP请求,服务器在接收到该N个第三HTTP请求和该M个第四HTTP请求后,针对每个HTTP请求服务器返回该HTTP请求对应的页面,终端可以接收该服务器针对该N个第三请求返回的N个第三页面和针对该M个第四请求返回的M个第四页面。其中,在该目标HTTP请求中每插入一个字段可得到一个HTTP请求。该N和该M均可以为大于或等于1的整数,该N和该M的大小可以相等,也可以不相等,本申请实施例不做限定。该第一逻辑类型的字段可以为真逻辑的结构化查询语言(structured query language,SQL)语句,该第二逻辑类型的字段可以为假逻辑的SQL语句。例如,第一逻辑类型的字段为“or 1=1”、“or 1<2”或“or 2=2”等恒真的SQL语句,第二逻辑类型的字段为“and 1=2”、“and 1>2”或“and 21=12”等恒假的SQL语句。
在一些可行的实施方式中,URL的结构通常为“协议://服务器名称(IP地址)/路径/文件名?参数”,例如,一个URL为:http://xxx.pingna.com/sql.php?id=1,其中,id=1表示这个URL的参数字段,URL的参数字段由参数名和参数值组成,id表示参数名,1表示参数值,参数值可为数字、字母(包括大小写)、特殊字符(指除数字、字母之外的字符)和/或它们的组合。问号“?”字符用于分隔URL中的文件名和参数。终端可以从用于注入漏洞检测的目标HTTP请求中提取该目标HTTP请求携带的URL,再可以在该URL的参数字段中插入真逻辑的N个SQL语句,得到真逻辑的N个第三HTTP请求,并可以在该URL的参数字段中插入假逻辑的M个SQL语句,得到假逻辑的M个第四HTTP请求。终端可以向服务器发送该N个第三HTTP请求和该M个第四HTTP请求,服务器在接收到该N个第三HTTP请求和该M个第四HTTP请求后,针对每个HTTP请求服务器返回该HTTP请求对应的页面,终端可以接收该服务器针对该N个第三请求返回的N个第三页面和针对该M个第四请求返回的M个第四页面。其中,终端在该URL的参数字段中每插入一个SQL语句就得到一个HTTP请求。该N个真逻辑的SQL语句可以各不相同,也可以一部分不相同;该M个假逻辑的SQL语句可以各不相同,也可以一部分不相同,本申请实施例不做限定。可选的,终端可以预设多个真逻辑的SQL语句和多个假逻辑的SQL语句,终端在该URL的参数字段中插入真逻辑的SQL语句时,可以从预设的多个真逻辑的SQL语句任选一个真逻辑的SQL语句进行插入。同理终端在该URL的参数字段中插入假逻辑的SQL语句时,也可以从预设的多个假逻辑的SQL语句任选一个假逻辑的SQL语句进行插入。
例如,目标HTTP请求携带的URL为http://xxx.pingna.com/sql.php?id=1,假设N=2,M=2。终端在该URL的参数字段“id=1”后插入一个预设的真逻辑的SQL语句“or 1=1”,得到一个真逻辑的第三HTTP请求,此时该第三HTTP请求中的URL为http://xxx.pingna.com/sql.php?id=1or 1=1;终端再在该URL的参数字段“id=1”后插入另一预设的真逻辑的SQL语句“or 1<2”,得到另一个真逻辑的第三HTTP请求,此时该第三HTTP请求中的URL为http://xxx.pingna.com/sql.php?id=1or 1<2。同理,终端在该URL的参数字段“id=1”后插入一个预设的假逻辑的SQL语句“and 1>2”,得到假逻辑的第四HTTP请求,此时该第四HTTP请求的URL为http://xxx.pingna.com/sql.php?id=1and 1>2;终端再在该URL的参数字段“id=1”后插入另一个预设的假逻辑的SQL语句“and 12=21”,得到另一个假逻辑的第四HTTP 请求,此时该第四HTTP请求的URL为http://xxx.pingna.com/sql.php?id=1and 12=21。
在一些可行的实施方式中,终端可以在用于注入漏洞检测的目标HTTP请求的目标字段中插入真逻辑的N个SQL语句,得到真逻辑的N个第三HTTP请求,并可以在该目标HTTP请求的该目标字段中插入假逻辑的M个SQL语句,得到假逻辑的M个第四HTTP请求。终端可以向服务器发送该N个第三HTTP请求和该M个第四HTTP请求,服务器在接收到该N个第三HTTP请求和该M个第四HTTP请求后,针对每个HTTP请求服务器返回该HTTP请求对应的页面,终端可以接收该服务器针对该N个第三请求返回的N个第三页面和针对该M个第四请求返回的M个第四页面。该目标字段可以包括Host字段、Referer字段、Cookie字段中的一种或多种。其中,第三HTTP请求和第四HTTP请求分别由在目标HTTP请求的同一字段中插入不同逻辑类型的SQL语句确定。
假设目标HTTP请求的Host字段为“ulog.jd.com”,Referer字段为http://xx.xx.xx.com/xx.html,Cookie字段为“_jda=1387505529”。以Host字段为例,假设N=3,M=2。终端在该目标HTTP请求的Host字段“ulog.jd.com”后插入一个预设的真逻辑SQL语句“or 1=1”,得到一个真逻辑的第三HTTP请求,此时该第三HTTP请求的Host字段为“ulog.jd.com or 1=1”;再在该Host字段“ulog.jd.com”后插入另一个预设的真逻辑SQL语句“or 2=2”,得到另一个真逻辑的第三HTTP请求,此时该第三HTTP请求的Host字段为“ulog.jd.com or 2=2”;再在该Host字段“ulog.jd.com”后插入又一个预设的真逻辑SQL语句“or 1<2”,得到又一个真逻辑的第三HTTP请求,此时该第三HTTP请求的Host字段为“ulog.jd.comor 1<2”。同理,终端在该目标HTTP请求的Host字段“ulog.jd.com”后插入一个预设的假逻辑SQL语句“and 12=21”,得到一个假逻辑的第四HTTP请求,此时该第四HTTP请求的Host字段为“ulog.jd.comand 12=21”;再在该Host字段“ulog.jd.com”后插入另一个预设的假逻辑SQL语句“and 2>112”,得到另一个假逻辑的第四HTTP请求,此时该第四HTTP请求的Host字段为“ulog.jd.com and 2>112”。
在一些可行的实施方式中,终端在向服务器发送N个第三HTTP请求和M个第四HTTP请求时,可以交叉发送,如发送一个第三HTTP请求,再发送一个第四HTTP请求,接着发送另一个第三HTTP请求,再发送另一个第四HTTP请求,直至所有的HTTP请求发送完毕。终端还可以顺序发送N个第三HTTP请求和M个第四HTTP请求,例如当N个第三HTTP请求发送完毕之后再发送第四HTTP请求。本申请实施例对此不做限定。其中,多个HTTP请求之间可以以预设的时间间隔定时发送,也可以尽可能快的发送,本申请实施例对发送多个HTTP请求之间的时间间隔也不做限定。
S203,终端获取第二参数集合。
在一些可行的实施方式中,终端在接收到上述服务器针对上述N个第三请求返回的N个第三页面和针对上述M个第四请求返回的M个第四页面之后,可以利用层级解析工具(如dom 4j)对该N个第三页面中的每个第三页面按照DOM进行解析,得到N个DOM树,再从该N个DOM树中提取N个第三节点集合,每个第三节点集合中包括至少一个DOM节点。同理,终端可以利用dom 4j对该M个第四页面中的每个第四页面按照DOM进行解析,得到M个DOM树,再从该M个DOM树中提取M个第四节点集合,每个第四节点集合中包括至少一个第四DOM节点。一个DOM树对应一个节点集合。终端可以比较该N个第三节点集合和上述第一节点集合中每两个节点集合之间的DOM节点是否相同,将该N个第三节点集合和该第一节点集合中每两个节点集合之间不同的DOM节点记录到第二参数集合中。同理,可以比较该M个第四节点集合和上述第二节点集合中每两个节点集合之间的DOM节点是否相同,将该M个第四节点集合和该第二节点集合中每两个节点集合之间不同的DOM节点也记录到第二参数集合中。
例如,如图3b所示,是第三节点集合和第一节点集合的示意图。其中,N=2,第三节点集合1中包括的DOM节点为:“根元素<bookstore>:西西弗书店、元素<book>:书籍、元素<title>:Harry Potter、元素<author>:J K.Rowling、元素<year>:2005、元素<price>:29.99”。第三节点集合2中包括的DOM节点为:“根元素<bookstore>:西西弗书店、元素<book>:书籍、元素<title>:Harry Potter、元素<author>:J K.Rowling、元素<year>:2005、元素<price>:28.9”。第一节点集合中包括的DOM节点为:“根元素<bookstore>:西西弗书店、元素<book>:书籍、元素<title>:Harry Potter、元素<author>:J K.Rowling、元素<year>:2005、元素<price>:29.99”。终端比较第一节点集合和第三节点集合1之间是否存在不相同的DOM节点,并比较第一节点集合和第三节点集合2之间是否存在不相同的DOM节点,还比较第三节点集合1和第三节点集合2之间是否存在不相同的DOM节点,由图3b可知,将不同的DOM节点“元素<price>”记录至第二参数集合中。如图3c所示,是第四节点集合和第二节点集合的示意图。其中,M=2。同理,终端比较第二节点集合和第四节点集合1之间是否存在不相同的DOM节点,并比较第二节点集合和第四节点集合2之间是否存在不相同的DOM节点,还比较第四节点集合1和第四节点集合2之间是否存在不相同的DOM节点,由图3c可知,将不同的DOM节点“元素<year>”记录至第二参数集合中。此时,第二参数集合中包括“元素<year>和元素<price>”这两个DOM节点。
S204,若第一参数集合中存在至少一个页面参数不在第二参数集合中,则终端确定服务器中存在注入漏洞。
在一些可行的实施方式中,终端可以将上述获取到的第一参数集合中的各个DOM节点与上述获取到的第二参数集合中的各个DOM节点进行比较,从而确定该第一参数集合中的每个DOM节点是否都在该第二参数集合中,若否,说明该第一参数集合中存在至少一个DOM节点不在该第二参数集合中,终端就可以确定上述服务器中存在注入漏洞。本申请实施例通过比较第一参数集合(包括真逻辑请求和假逻辑请求返回的页面之间不同的DOM节点)中的所有DOM节点是否都在第二参数集合(包括多个真逻辑请求返回的页面之间不同的DOM节点和多个假逻辑请求返回的页面之间不同的DOM节点)中,可以排除因为页面本身动态变化或多次请求动态返回引起的注入漏洞误报的情况,减少了注入漏洞的误报次数,提高了检测注入漏洞的准确度。
例如,第一参数集合中包括“元素<title>、元素<author>以及元素<price>”,第二参数集合中包括“元素<year>和元素<price>”。终端查找第一参数集合中的“元素<title>”是否在第二参数集合中,并查找第一参数集合中的“元素<author>”是否在第二参数集合中,再查找第一参数集合中的“元素<price>”是否在第二参数集合中,显然,第一参数集合中的“元素<title>、元素<author>”不在第二参数集合中,第一参数集合中的“元素<price>”在第二参数集合中,那么因为第一参数集合中存在2个DOM节点(“元素<title>、元素<author>”)不在第二参数集合中,终端就可以确定服务器中存在注入漏洞。可选的,终端可以在第一参数集合中查找到任一个DOM节点不在第二参数集合中后,对第一集合中未查找的DOM节点,不再进行查找,从而提高处理效率。如终端查找第一参数集合中的“元素<title>”是否在第二参数集合中,若否,则终端直接确定服务器中存在注入漏洞,而不再查找第一参数集合中的“元素<author>以及元素<price>”是否在第二参数集合中。
本申请实施例通过获取第一参数集合,该第一参数集合中包括第一页面和第二页面之间不同的页面参数,向服务器发送N个第三请求和M个第四请求,并接收该服务器针对该N个第三请求返回的N个第三页面和针对该M个第四请求返回的M个第四页面,再获取第二参数集合,该第二参数集合包括该N个第三页面和该第一页面中每两个页面之间不同的页面参数,以及该M个第四页面和该第二页面中 每两个页面之间不同的页面参数,当该第一参数集合中存在至少一个页面参数不在该第二参数集合中时,则确定该服务器中存在注入漏洞,可以减少误报的次数,提高检测注入漏洞的准确性。
参见图4,是本申请实施例提供的一种注入漏洞检测方法的另一示意流程图。如图4所示,该注入漏洞检测方法可包括步骤:
S401,终端确定用于注入漏洞检测的目标请求。
在一些可行的实施方式中,终端可以获取用户预设的一个或多个用于检测服务器是否存在注入漏洞的目标HTTP请求。该目标HTTP请求中携带的URL可以为该服务器中存在的URL,即终端通过该URL可以正常访问该服务器。
S402,终端根据目标请求确定出第一请求和第二请求。
在一些可行的实施方式中,终端可以在上述确定出的目标HTTP请求中插入第一逻辑类型的字段,得到该第一逻辑类型的第一HTTP请求,并可以在该目标HTTP请求中插入第二逻辑类型的字段,得到该第二逻辑类型的第二HTTP请求。其中,该第一逻辑类型可以表示真逻辑,第二逻辑类型可以表示假逻辑。该第一逻辑类型的字段可以为真逻辑的SQL语句,该第二逻辑类型的字段可以为假逻辑的SQL语句。例如,第一逻辑类型的字段为“or 1=1”、“or 1<2”或“or 2=2”等恒真的SQL语句,第二逻辑类型的字段为“and 1=2”、“and 1>2”或“and 21=12”等恒假的SQL语句。
在一些可行的实施方式中,终端可以在该目标HTTP请求的目标字段中插入真逻辑的SQL语句,得到真逻辑的第一HTTP请求,并可以在该目标HTTP请求的该目标字段中插入假逻辑的SQL语句,得到假逻辑的第二HTTP请求。该目标字段可以包括Host字段、Referer字段、Cookie字段中的一种或多种。其中,该第一HTTP请求和该第二HTTP请求分别由在该目标HTTP请求的同一字段中插入不同逻辑类型的SQL语句确定。
在一些可行的实施方式中,终端可以从该目标HTTP请求中提取该目标HTTP请求携带的URL,再可以在该URL的参数字段中插入真逻辑的SQL语句,得到真逻辑的第一HTTP请求,并可以在该URL的参数字段中插入假逻辑的SQL语句,得到假逻辑的第二HTTP请求。其中,终端可以预设多个真逻辑的SQL语句和多个假逻辑的SQL语句,终端在该URL的参数字段中插入真逻辑的SQL语句时,可以从预设的多个真逻辑的SQL语句任选一个真逻辑的SQL语句进行插入。同理终端在该URL的参数字段中插入假逻辑的SQL语句时,也可以从预设的多个假逻辑的SQL语句任选一个假逻辑的SQL语句进行插入。
S403,终端向服务器发送第一请求和第二请求,接收服务器针对第一请求返回的第一页面和针对第二请求返回的第二页面。
在一些可行的实施方式中,终端可以向上述服务器发送上述第一HTTP请求和上述第二HTTP请求,该服务器接收终端发送的该第一HTTP请求和该第二HTTP请求,并针对该第一HTTP请求返回该第一HTTP请求对应的第一页面,且针对该第二HTTP请求返回该第二HTTP请求对应的第二页面。终端可以接收该第一页面和该第二页面。
S404,终端将第一页面和第二页面之间不同的DOM节点记录至第一参数集合。
在一些可行的实施方式中,终端可以利用层级解析工具(如dom 4j)将上述接收到的第一页面按照DOM进行解析,得到该第一页面的DOM树结构,再可以从该第一页面的DOM树结构中提取至少一个第一DOM节点。同理,终端可以将上述接收到的第二页面按照DOM进行解析,得到该第二页面的DOM树结构,再可以从该第二页面的DOM树结构中提取至少一个第二DOM节点。终端可以将该至少一个 第一DOM节点中各个第一DOM节点与该至少一个第二DOM节点中对应的各个第二DOM节点进行匹配,确定该至少一个第一DOM节点与该至少一个第二DOM节点之间不相同的DOM节点,并可以将该不相同的DOM节点记录至第一参数集合中。此时,第一参数集合中不同的DOM节点可能是由于页面本身动态变化或页面在多次请求时的动态返回导致的,也可能是服务器中存在注入漏洞,步骤S402中插入的真逻辑的SQL语句和假逻辑的SQL语句被服务器当作SQL查询语句执行,从而导致第一页面和第二页面之间存在不同的DOM节点。
例如,终端对第一页面content1按照DOM进行解析,得到content1的DOM树结构,如图5a所示,是第一页面的DOM树结构的示意图,DOM树结构中的每个元素、文本都可称为一个节点。终端可以从content1的DOM树结构中提取至少一个第一DOM节点。如图5b所示,为第一DOM节点的示意图。同理,终端对第二页面content2按照DOM进行解析,得到content2的DOM树结构,如图5c所示,是第二页面的DOM树结构的示意图。终端可以从content2的DOM树结构中提取至少一个第二DOM节点。如图5d所示,为第二DOM节点的示意图。终端可以分别比较该至少一个第一DOM节点和该至少一个第二DOM节点中文本节点的内容,元素节点(<title>、<author>、<year>以及<price>)的标签名称、标签类型,内容节点(<book>)的标签名称、标签类型、标签属性、子节点数量、子节点类型等是否相同。若某个文本节点的内容不相同,终端就可以确定该某个文本节点为该至少一个第一DOM节点与该至少一个第二DOM节点之间不相同的DOM节点。若某个元素节点的标签名称和标签类型中任意一个不相同,终端就可以确定该某个元素节点为该至少一个第一DOM节点与该至少一个第二DOM节点之间不相同的DOM节点。若某个内容节点的标签名称、标签类型、标签属性、子节点数量和子节点类型中任意一个不相同,终端就可以确定该某个内容节点为该至少一个第一DOM节点与该至少一个第二DOM节点之间不相同的DOM节点。
S405,终端向服务器发送N个第三请求和M个第四请求,并接收服务器针对N个第三请求分别返回的N个第三页面和针对M个第四请求分别返回的M个第四页面。
S406,终端获取第二参数集合。
本申请实施例中上述步骤S405-步骤S406的实现方式可参考图2所示实施例的步骤S202-步骤S203所提供的实现方式,在此不再赘述。
S407,终端将第一参数集合中各个不同的DOM节点与第二参数集合中各个不同的DOM节点之间进行匹配,确定第一参数集合中的每个DOM节点是否都在所述第二参数集合中。
S408,若第一参数集合中存在至少一个DOM节点不在第二参数集合中,则终端确定服务器中存在注入漏洞。
S409,若第一参数集合中每个DOM节点都在第二参数集合中,则终端确定服务器中不存在注入漏洞。
在一些可行的实施方式中,在一些可行的实施方式中,终端可以将上述获取到的第一参数集合中的各个DOM节点与上述获取到的第二参数集合中的各个节点进行比较,从而确定该第一参数集合中的每个DOM节点是否都在该第二参数集合中,若否,说明该第一参数集合中存在至少一个DOM节点不在该第二参数集合中,终端就可以确定上述服务器中存在注入漏洞。若是,说明该第一参数集合中的每个DOM节点都在该第二参数集合中,终端可以确定上述服务器中不存在注入漏洞。本申请实施例通过比较第一参数集合(包括真逻辑请求和假逻辑请求返回的页面之间不同的DOM节点)中的所有DOM节点是否都在第二参数集合(包括多个真逻辑请求返回的页面之间不同的DOM节点和多个假逻辑请求返 回的页面之间不同的DOM节点)中,可以排除因为页面本身动态变化或多次请求动态返回引起的注入漏洞误报的情况,减少了注入漏洞的误报次数,提高了检测注入漏洞的准确度。
在一些可行的实施方式中,终端在确定上述服务器不存在注入漏洞之后,可以输出安全提示信息,该安全提示信息用于提示上述服务器中不存在注入漏洞,可以方便地查看到检测结果。终端在确定上述服务器中存在注入漏洞之后,可以输出报警提示信息,该报警提示信息可以包括上述目标HTTP请求的URL的参数字段,该报警提示信息可以用于提示编程人员对上述服务器中URL的参数字段存在的注入漏洞进行处理,可以防止使用上述服务器的客户的信息被泄露,从而导致客户的财产损失。同时可以更快地发现服务器中存在注入漏洞的地方,进而使得编程人员可以更快地对服务器中存在注入漏洞的地方进行处理。
本申请实施例通过确定用于注入漏洞检测的目标请求,再根据目标请求确定出第一请求和第二请求,并向服务器发送第一请求和第二请求,接收服务器针对第一请求返回的第一页面和针对第二请求返回的第二页面;再将第一页面和第二页面之间不同的DOM节点记录至第一参数集合,然后向服务器发送N个第三请求和M个第四请求,并接收服务器针对N个第三请求返回的N个第三页面和针对M个第四请求返回的M个第四页面,再获取第二参数集合;接着将第一参数集合中各个不同的DOM节点与第二参数集合中各个不同的DOM节点之间进行匹配,确定第一参数集合中的每个DOM节点是否都在所述第二参数集合中,当第一参数集合中存在至少一个DOM节点不在第二参数集合中时,则终端确定服务器中存在注入漏洞,当第一参数集合中每个DOM节点都在第二参数集合中时,则终端确定服务器中不存在注入漏洞。不仅可以减少误报的次数,提高检测注入漏洞的准确性,还可以更快地发现服务器中存在注入漏洞的地方,提高检测的效率。
参见图6,是本申请实施例提供的一种注入漏洞检测装置的一示意框图。本实施例的注入漏洞检测装置包括:
第一获取模块10,用于获取第一参数集合。其中,该第一参数集合中包括第一页面和第二页面之间不同的页面参数,该第一页面为服务器针对第一逻辑类型的第一请求返回的页面,该第二页面为服务器针对第二逻辑类型的第二请求返回的页面。
收发模块30,用于向服务器发送N个第三请求和M个第四请求,并接收该服务器针对该N个第三请求分别返回的N个第三页面和针对该M个第四请求分别返回的M个第四页面。其中第三请求为在用于注入漏洞检测的目标请求中插入该第一逻辑类型的任一字段得到的请求,第四请求为在该目标请求中插入该第二逻辑类型的任一字段得到的请求。
第二获取模块30,用于获取第二参数集合。其中,该第二参数集合中包括该N个第三页面和该第一页面中每两个页面之间不同的页面参数,以及该M个第四页面和该第二页面中每两个页面之间不同的页面参数。
确定模块40,用于当该第一参数集合中存在至少一个页面参数不在该第二参数集合中时,确定该服务器中存在注入漏洞。
在一些可行的实施方式中,该装置还包括第一插入模块50。该第一插入模块50,用于针对该第一逻辑类型的N个字段中的任一字段,将该字段插入该目标请求的统一资源定位符URL的参数字段中形成一个第三请求;该第一插入模块50,还用于针对该第二逻辑类型的M个字段中的任一字段,将该字段插入该目标请求的URL的参数字段中形成一个第四请求。
在一些可行的实施方式中,该装置还包括第二插入模块60。该第二插入模块60,用于针对该第一 逻辑类型的N个字段中的任一字段,将该字段插入该目标请求的目标字段中形成一个第三请求;该第二插入模块60,还用于针对该第二逻辑类型的M个字段中的任一字段,将该字段插入该目标请求的目标字段中形成一个第四请求。其中,该目标字段包括Host字段、Referer字段、Cookie字段中的一种或多种。
在一些可行的实施方式中,上述页面参数包括文档对象模型DOM节点。上述第二获取模块30具体用于:
获取该第一页面按照DOM进行解析后得到的第一节点集合和该第二页面按照该DOM进行解析后的第二节点集合;将该N个第三页面按照该DOM进行解析,得到N个第三节点集合;将该M个第四页面按照该DOM进行解析,得到M个第四节点集合;将该N个第三节点集合和该第一节点集合中每两个节点集合之间不同的DOM节点记录至该第二参数集合中;将该M个第四节点集合和该第二节点集合中每两个节点集合之间不同的DOM节点记录至该第二参数集合中。其中,一个页面对应一个节点集合,一个节点集合包括至少一个DOM节点。
在一些可行的实施方式中,该装置还包括匹配模块70。该匹配模块70,用于将该第一参数集合中的各个页面参数与该第二参数集合中的各个页面参数之间进行匹配,确定该第一参数集合中的每个页面参数是否都在该第二参数集合中。在一种可能的实施方式中,该匹配模块70具体用于将该第一参数集合中的各个DOM节点与该第二参数集合中的各个DOM节点之间进行匹配,确定该第一参数集合中的每个DOM节点是否都在该第二参数集合中。
在一些可行的实施方式中,上述确定模块40还用于当该第一参数集合中每个页面参数都在该第二参数集合中时,确定该服务器中不存在该注入漏洞。
在一些可行的实施方式中,该装置还包括输出模块80。该输出模块80,用于在确定该服务器中存在注入漏洞之后,输出报警提示信息,该报警提示信息用于提示该服务器中存在该注入漏洞。在一种可能的实施方式中,该输出模块80还用于在确定该服务器中不存在该注入漏洞时,输出安全提示信息,该安全提示信息可以用于提示该服务器已被检测且不存在该注入漏洞。
具体实现中,上述注入漏洞检测装置可通过上述各个模块执行上述图2或者图4所提供的实现方式中各个步骤所提供的实现方式,实现上述各实施例中所实现的功能,具体可参见上述图2或图4所示的方法实施例中各个步骤提供的相应描述,在此不再赘述。
在本申请实施例中,注入漏洞检测装置可获取第一参数集合,该第一参数集合中包括第一页面和第二页面之间不同的页面参数,向服务器发送N个第三请求和M个第四请求,并接收该服务器针对该N个第三请求返回的N个第三页面和针对该M个第四请求返回的M个第四页面,再获取第二参数集合,该第二参数集合包括该N个第三页面和该第一页面中每两个页面之间不同的页面参数,以及该M个第四页面和该第二页面中每两个页面之间不同的页面参数,当该第一参数集合中存在至少一个页面参数不在该第二参数集合中时,则确定该服务器中存在注入漏洞,可以减少误报的次数,提高检测注入漏洞的准确性。
参见图7,是本申请实施例提供的一种终端的一示意性框图。如图7所示,本申请实施例中的终端可以包括:一个或多个处理器701;一个或多个输入设备702,一个或多个输出设备703和存储器704。上述处理器701、输入设备702、输出设备703和存储器704通过总线705连接。存储器702用于存储计算机程序,该计算机程序包括程序指令,处理器701用于执行存储器702存储的程序指令。其中,上述处理器701被配置用于调用该程序指令执行:
获取第一参数集合。其中,该第一参数集合中包括第一页面和第二页面之间不同的页面参数,该第一页面为服务器针对第一逻辑类型的第一请求返回的页面,该第二页面为服务器针对第二逻辑类型的第二请求返回的页面。
上述输出设备703用于向服务器发送N个第三请求和M个第四请求。上述输入设备702,用于接收该服务器针对该N个第三请求分别返回的N个第三页面和针对该M个第四请求分别返回的M个第四页面。其中,第三请求为在用于注入漏洞检测的目标请求中插入该第一逻辑类型的任一字段得到的请求,第四请求为在该目标请求中插入该第二逻辑类型的任一字段得到的请求。
上述处理器701还被配置用于调用该程序指令执行:获取第二参数集合,该第二参数集合中包括该N个第三页面和该第一页面中每两个页面之间不同的页面参数,以及该M个第四页面和该第二页面中每两个页面之间不同的页面参数;
若该第一参数集合中存在至少一个页面参数不在该第二参数集合中,则确定该服务器中存在注入漏洞。
应当理解,在本申请实施例中,所称处理器701可以是中央处理单元(central processing unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
输入设备702可以包括接收器、接收程序接口等,输出设备703可以包括发送器、发送程序接口等。
该存储器704可以包括只读存储器和随机存取存储器,并向处理器701提供指令和数据。存储器704的一部分还可以包括非易失性随机存取存储器。例如,存储器704还可以存储设备类型的信息。
具体实现中,本申请实施例中所描述的处理器701、输入设备702、输出设备703可执行本申请实施例提供的注入漏洞检测方法中所描述的实现方式,也可执行本申请实施例所描述的注入漏洞检测装置的实现方式,在此不再赘述。
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序包括程序指令,该程序指令被处理器执行时实现图2或图4所示的注入漏洞检测方法,具体细节请参照图2或图4所示实施例的描述,在此不再赘述。
上述计算机可读存储介质可以是前述任一实施例所述的注入漏洞检测装置或终端的内部存储单元,例如终端的硬盘或内存。该计算机可读存储介质也可以是该终端的外部存储设备,例如该终端上配备的插接式硬盘,智能存储卡(smart media card,SMC),安全数字(secure digital,SD)卡,闪存卡(flash card)等。进一步地,该计算机可读存储介质还可以既包括该终端的内部存储单元也包括外部存储设备。该计算机可读存储介质用于存储该计算机程序以及该终端所需的其他程序和数据。该计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。

Claims (20)

  1. 一种注入漏洞检测方法,其特征在于,包括:
    获取第一参数集合,所述第一参数集合中包括第一页面和第二页面之间不同的页面参数,所述第一页面为服务器针对第一逻辑类型的第一请求返回的页面,所述第二页面为所述服务器针对第二逻辑类型的第二请求返回的页面;
    向所述服务器发送N个第三请求和M个第四请求,并接收所述服务器针对所述N个第三请求分别返回的N个第三页面和针对所述M个第四请求分别返回的M个第四页面,其中第三请求为在用于注入漏洞检测的目标请求中插入所述第一逻辑类型的任一字段得到的请求,第四请求为在所述目标请求中插入所述第二逻辑类型的任一字段得到的请求;
    获取第二参数集合,所述第二参数集合中包括所述N个第三页面和所述第一页面中每两个页面之间不同的页面参数,以及所述M个第四页面和所述第二页面中每两个页面之间不同的页面参数;
    若所述第一参数集合中存在至少一个页面参数不在所述第二参数集合中,则确定所述服务器中存在注入漏洞。
  2. 根据权利要求1所述的方法,其特征在于,所述向服务器发送N个第三请求和M个第四请求之前,所述方法还包括:
    针对所述第一逻辑类型的N个字段中的任一字段,将所述字段插入所述目标请求的统一资源定位符URL的参数字段中形成一个第三请求;
    针对所述第二逻辑类型的M个字段中的任一字段,将所述字段插入所述目标请求的URL的参数字段中形成一个第四请求。
  3. 根据权利要求1所述的方法,其特征在于,所述向服务器发送N个第三请求和M个第四请求之前,所述方法还包括:
    针对所述第一逻辑类型的N个字段中的任一字段,将所述字段插入所述目标请求的目标字段中形成一个第三请求;
    针对所述第二逻辑类型的M个字段中的任一字段,将所述字段插入所述目标请求的目标字段中形成一个第四请求;
    其中,所述目标字段包括Host字段、Referer字段、Cookie字段中的一种或多种。
  4. 根据权利要求1-3任意一项所述的方法,其特征在于,所述页面参数包括文档对象模型DOM节点;
    所述获取第二参数集合,包括:
    获取所述第一页面按照DOM进行解析后得到的第一节点集合和所述第二页面按照所述DOM进行解析后的第二节点集合;
    将所述N个第三页面按照所述DOM进行解析,得到N个第三节点集合;
    将所述M个第四页面按照所述DOM进行解析,得到M个第四节点集合;
    将所述N个第三节点集合和所述第一节点集合中每两个节点集合之间不同的DOM节点记录至所述第二参数集合中;
    将所述M个第四节点集合和所述第二节点集合中每两个节点集合之间不同的DOM节点记录至所述第二参数集合中;
    其中,一个页面对应一个节点集合,一个节点集合包括至少一个DOM节点。
  5. 根据权利要求1-4任意一项所述的方法,其特征在于,所述获取第二参数集合之后,所述方法还包括:
    将所述第一参数集合中的各个页面参数与所述第二参数集合中的各个页面参数之间进行匹配,确定所述第一参数集合中的每个页面参数是否都在所述第二参数集合中。
  6. 根据权利要求1-5任意一项所述的方法,其特征在于,所述方法,还包括:
    若所述第一参数集合中每个页面参数都在所述第二参数集合中,则确定所述服务器中不存在所述注入漏洞。
  7. 根据权利要求1-6任意一项所述的方法,其特征在于,所述确定所述服务器中存在注入漏洞之后,还包括:
    输出报警提示信息,所述报警提示信息用于提示所述服务器中存在所述注入漏洞。
  8. 一种注入漏洞检测装置,其特征在于,包括:
    第一获取模块,用于获取第一参数集合,所述第一参数集合中包括第一页面和第二页面之间不同的页面参数,所述第一页面为服务器针对第一逻辑类型的第一请求返回的页面,所述第二页面为所述服务器针对第二逻辑类型的第二请求返回的页面;
    收发模块,用于向所述服务器发送N个第三请求和M个第四请求,并接收所述服务器针对所述N个第三请求分别返回的N个第三页面和针对所述M个第四请求分别返回的M个第四页面,其中第三请求为在用于注入漏洞检测的目标请求中插入所述第一逻辑类型的任一字段得到的请求,第四请求为在所述目标请求中插入所述第二逻辑类型的任一字段得到的请求;
    第二获取模块,用于获取第二参数集合,所述第二参数集合中包括所述N个第三页面和所述第一页面中每两个页面之间不同的页面参数,以及所述M个第四页面和所述第二页面中每两个页面之间不同的页面参数;
    确定模块,用于当所述第一参数集合中存在至少一个页面参数不在所述第二参数集合中时,则确定所述服务器中存在注入漏洞。
  9. 根据权利要求8所述的装置,其特征在于,所述装置还包括:
    第一插入模块,用于针对所述第一逻辑类型的N个字段中的任一字段,将所述字段插入所述目标请求的统一资源定位符URL的参数字段中形成一个第三请求;
    所述第一插入模块,还用于针对所述第二逻辑类型的M个字段中的任一字段,将所述字段插入所述目标请求的URL的参数字段中形成一个第四请求。
  10. 根据权利要求8所述的装置,其特征在于,所述装置还包括:
    第二插入模块,用于针对所述第一逻辑类型的N个字段中的任一字段,将所述字段插入所述目标请求的目标字段中形成一个第三请求;
    所述第二插入模块,还用于针对所述第二逻辑类型的M个字段中的任一字段,将所述字段插入所述目标请求的目标字段中形成一个第四请求;
    其中,所述目标字段包括Host字段、Referer字段、Cookie字段中的一种或多种,所述在所述目标请求的目标字段中每插入一个字段得到一个请求。
  11. 根据权利要求8-10任意一项所述的装置,其特征在于,所述页面参数包括文档对象模型DOM节点;
    所述第二获取模块具体用于:
    获取所述第一页面按照DOM进行解析后得到的第一节点集合和所述第二页面按照所述DOM进行解析后的第二节点集合;
    将所述N个第三页面按照所述DOM进行解析,得到N个第三节点集合;
    将所述M个第四页面按照所述DOM进行解析,得到M个第四节点集合;
    将所述N个第三节点集合和所述第一节点集合中每两个节点集合之间不同的DOM节点记录至所述第二参数集合中;
    将所述M个第四节点集合和所述第二节点集合中每两个节点集合之间不同的DOM节点记录至所述第二参数集合中;
    其中,一个页面对应一个节点集合,一个节点集合包括至少一个DOM节点。
  12. 根据权利要求8-11任意一项所述的装置,其特征在于,所述装置还包括:
    匹配模块,用于将所述第一参数集合中的各个页面参数与所述第二参数集合中的各个页面参数之间进行匹配,确定所述第一参数集合中的每个页面参数是否都在所述第二参数集合中。
  13. 根据权利要求8-12任意一项所述的装置,其特征在于,所述确定模块还用于:
    当所述第一参数集合中每个页面参数都在所述第二参数集合中时,确定所述服务器中不存在所述注入漏洞。
  14. 根据权利要求8-13任意一项所述的装置,其特征在于,所述装置还包括:
    输出模块,用于在确定所述服务器中存在注入漏洞之后,输出报警提示信息,所述报警提示信息用于提示所述服务器中存在所述注入漏洞。
  15. 一种终端,其特征在于,包括处理器、输入设备、输出设备和存储器,所述处理器、输入设备、输出设备和存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器用于执行所述存储器的所述程序指令,其中:
    所述处理器,用于获取第一参数集合,所述第一参数集合中包括第一页面和第二页面之间不同的页面参数,所述第一页面为服务器针对第一逻辑类型的第一请求返回的页面,所述第二页面为所述服务器针对第二逻辑类型的第二请求返回的页面;
    所述输出设备,用于向所述服务器发送N个第三请求和M个第四请求;
    所述输入设备,用于接收所述服务器针对所述N个第三请求分别返回的N个第三页面和针对所述M个第四请求分别返回的M个第四页面,其中第三请求为在用于注入漏洞检测的目标请求中插入所述第一逻辑类型的任一字段得到的请求,第四请求为在所述目标请求中插入所述第二逻辑类型的任一字段得到的请求;
    所述处理器,还用于获取第二参数集合,所述第二参数集合中包括所述N个第三页面和所述第一页面中每两个页面之间不同的页面参数,以及所述M个第四页面和所述第二页面中每两个页面之间不同的页面参数;当所述第一参数集合中存在至少一个页面参数不在所述第二参数集合中时,确定所述服务器中存在注入漏洞。
  16. 根据权利要求15所述的终端,其特征在于,所述处理器还用于:
    针对所述第一逻辑类型的N个字段中的任一字段,将所述字段插入所述目标请求的统一资源定位符URL的参数字段中形成一个第三请求;
    针对所述第二逻辑类型的M个字段中的任一字段,将所述字段插入所述目标请求的URL的参数字段中形成一个第四请求。
  17. 根据权利要求15所述的终端,其特征在于,所述处理器还用于:
    针对所述第一逻辑类型的N个字段中的任一字段,将所述字段插入所述目标请求的目标字段中形成一个第三请求;
    针对所述第二逻辑类型的M个字段中的任一字段,将所述字段插入所述目标请求的目标字段中形成一个第四请求;
    其中,所述目标字段包括Host字段、Referer字段、Cookie字段中的一种或多种。
  18. 根据权利要求15-17任意一项所述的终端,其特征在于,所述页面参数包括文档对象模型DOM节点;
    所述处理器具体用于:
    获取所述第一页面按照DOM进行解析后得到的第一节点集合和所述第二页面按照所述DOM进行解析后的第二节点集合;
    将所述N个第三页面按照所述DOM进行解析,得到N个第三节点集合;
    将所述M个第四页面按照所述DOM进行解析,得到M个第四节点集合;
    将所述N个第三节点集合和所述第一节点集合中每两个节点集合之间不同的DOM节点记录至所述第二参数集合中;
    将所述M个第四节点集合和所述第二节点集合中每两个节点集合之间不同的DOM节点记录至所述第二参数集合中;
    其中,一个页面对应一个节点集合,一个节点集合包括至少一个DOM节点。
  19. 根据权利要求15-18任意一项所述的终端,其特征在于,所述处理器还用于:
    将所述第一参数集合中的各个页面参数与所述第二参数集合中的各个页面参数之间进行匹配,确定所述第一参数集合中的每个页面参数是否都在所述第二参数集合中。
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的方法。
PCT/CN2018/108717 2018-07-25 2018-09-29 一种注入漏洞检测方法及装置 WO2020019514A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810825470.XA CN109150842B (zh) 2018-07-25 2018-07-25 一种注入漏洞检测方法及装置
CN201810825470.X 2018-07-25

Publications (1)

Publication Number Publication Date
WO2020019514A1 true WO2020019514A1 (zh) 2020-01-30

Family

ID=64797755

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/108717 WO2020019514A1 (zh) 2018-07-25 2018-09-29 一种注入漏洞检测方法及装置

Country Status (2)

Country Link
CN (1) CN109150842B (zh)
WO (1) WO2020019514A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110460606B (zh) * 2019-08-16 2021-10-12 中国银行股份有限公司 一种二阶sql注入漏洞检测方法、装置及设备
CN113285855B (zh) * 2021-07-14 2021-12-07 天聚地合(苏州)数据股份有限公司 服务器监控方法及系统

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080295178A1 (en) * 2007-05-24 2008-11-27 Oracle International Corporation Indicating SQL injection attack vulnerability with a stored value
CN103441985A (zh) * 2013-07-25 2013-12-11 国家电网公司 一种针对cookie方式的sql注入漏洞检测方法
CN106407803A (zh) * 2016-08-30 2017-02-15 北京奇虎科技有限公司 Sql注入漏洞的检测方法及装置
CN107704758A (zh) * 2017-08-25 2018-02-16 郑州云海信息技术有限公司 一种sql注入漏洞检测方法和检测装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8010522B2 (en) * 2007-12-07 2011-08-30 International Business Machines Corporation System, method and program product for detecting SQL queries injected into data fields of requests made to applications
CN102799830B (zh) * 2012-08-06 2015-06-17 厦门市美亚柏科信息股份有限公司 一种改进的sql注入漏洞检测方法
CN102855418A (zh) * 2012-08-08 2013-01-02 周耕辉 发现Web内网代理漏洞的方法
CN104881603B (zh) * 2014-02-27 2018-07-03 腾讯科技(深圳)有限公司 网页重定向漏洞检测方法及装置
CN105046150B (zh) * 2015-08-06 2017-10-17 福建天晴数码有限公司 防止sql注入的方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080295178A1 (en) * 2007-05-24 2008-11-27 Oracle International Corporation Indicating SQL injection attack vulnerability with a stored value
CN103441985A (zh) * 2013-07-25 2013-12-11 国家电网公司 一种针对cookie方式的sql注入漏洞检测方法
CN106407803A (zh) * 2016-08-30 2017-02-15 北京奇虎科技有限公司 Sql注入漏洞的检测方法及装置
CN107704758A (zh) * 2017-08-25 2018-02-16 郑州云海信息技术有限公司 一种sql注入漏洞检测方法和检测装置

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
MA KAI ET AL: "Injection Point Extraction Approach in SQL Injection Vulnerability under Web2. 0 Environment", COMPUTER TECHNOLOGY AND DEVELOPMENT, vol. 23, no. 3, 31 March 2013 (2013-03-31), pages 121 - 125 *
SAXENA, AMITABH: "Detecting SOQL-Injection Vulnerabilities in SalesForce Applications", 2013 INTERNATIONAL CONFERENCE ON ADVANCES IN COMPUTING, COMMUNICATIONS AND INFORMATICS (ICACCI, 31 December 2013 (2013-12-31), pages 489 - 493, XP032510287 *

Also Published As

Publication number Publication date
CN109150842A (zh) 2019-01-04
CN109150842B (zh) 2021-07-09

Similar Documents

Publication Publication Date Title
US10579831B2 (en) Verification of data set components using digitally signed probabilistic data structures
CN109768992B (zh) 网页恶意扫描处理方法及装置、终端设备、可读存储介质
WO2017000439A1 (zh) 一种恶意行为的检测方法、系统、设备及计算机存储介质
US8051484B2 (en) Method and security system for indentifying and blocking web attacks by enforcing read-only parameters
US10078687B2 (en) Deletion of elements from a probabilistic data structure
CN107341395B (zh) 一种拦截爬虫的方法
US9954880B2 (en) Protection via webpage manipulation
CN106878264A (zh) 一种数据管理方法及服务器
US8307276B2 (en) Distributed content verification and indexing
WO2019076014A1 (zh) 网页生成方法、装置、终端设备及介质
WO2012089005A1 (zh) 钓鱼网页检测方法及设备
CN107239701B (zh) 识别恶意网站的方法及装置
US10972507B2 (en) Content policy based notification of application users about malicious browser plugins
WO2013143403A1 (zh) 一种访问网站的方法和系统
CN108900554B (zh) Http协议资产检测方法、系统、设备及计算机介质
CN111008348A (zh) 反爬虫方法、终端、服务器及计算机可读存储介质
US10263784B2 (en) Signature verification for data set components using probabilistic data structures
WO2020019514A1 (zh) 一种注入漏洞检测方法及装置
US20130282699A1 (en) Using Authority Website to Measure Accuracy of Business Information
WO2020019515A1 (zh) 一种注入漏洞检测方法及装置
WO2020073493A1 (zh) Sql注入漏洞检测方法、装置、设备及可读存储介质
CN116304458B (zh) 一种web页面实时通知更新方法、装置、设备及介质
EP3347831B1 (en) Deletion of elements from a bloom filter
CN115664736A (zh) 一种共享数据的方法、装置、设备及介质
CN112769792A (zh) 一种isp攻击检测方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18928141

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 03/05/2021)

122 Ep: pct application non-entry in european phase

Ref document number: 18928141

Country of ref document: EP

Kind code of ref document: A1