Unauthorized interface scanning method and device
Through configuration file-driven interface extraction and filtering requests, unauthorized interfaces are automatically identified, which solves the problems of low detection efficiency and inflexible configuration in the existing technology, and realizes unauthorized interface scanning with high efficiency and low false alarms.
Patent Information
- Application Number
- CN202410855947.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-29
AI Technical Summary
The existing technology cannot automatically detect and configure flexibly, resulting in low efficiency of unauthorized interface scanning and high false positive rate, and cannot effectively identify potential security vulnerabilities of the website.
Based on the homepage interface of the website to be scanned, the relevant interface list is extracted according to the preset configuration file, and the rules in the configuration file are used to filter requests and respond to judge, to achieve automated unauthorized interface scanning, including interface extraction rules and HTTP status codes. Filtering and dangerous function avoidance.
It realizes the automatic extraction of website related links and identifies potential unauthorized access problems. It has flexible configuration, simple use, low false alarm rate, and improves the efficiency of security detection.
Smart Images

Figure CN118869262A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to an unauthorized interface scanning method and device. Background Art
[0002] With the rapid development and popularization of Internet technology, enterprises and individuals are increasingly relying on websites to conduct business activities and daily interactions. As an important platform for information release, the security of websites is highly valued. Unauthorized access to website interfaces is an important issue in the field of network security. Unauthorized access usually refers to access to website resources without permission, which may lead to sensitive information leakage, data tampering or deletion, and even more serious network attacks.
[0003] There are many technologies involved in the field of unauthorized interface detection, which are used to monitor and prevent unauthorized access. However, most of them are based on passive monitoring methods and generally focus on traffic detection equipment. They cannot automatically extract the website interface and actively initiate scanning and detection. In addition, many scanners for detecting unauthorized access interfaces are not flexible enough and cannot customize judgment rules that are closer to the real environment according to user needs.
[0004] In summary, the existing technology has the problems that the configuration cannot be automatically detected and the configuration is inflexible. Summary of the invention
[0005] The present invention provides an unauthorized interface scanning method and device, which are used to solve the defects of the prior art that automatic detection cannot be performed and the configuration is inflexible, and realize unauthorized interface scanning with simple use, flexible configuration and low false alarm rate.
[0006] The present invention provides an unauthorized interface scanning method, comprising the following steps: Based on the homepage interface of the website to be scanned, relevant interfaces are extracted according to a preset configuration file to obtain an interface list; Performing a screening request on the relevant interfaces in the interface list according to the configuration file; In response to obtaining a response to the screening request, the response is judged according to the configuration file to obtain a scanning result; wherein the configuration file includes a predefined interface extraction rule, an HTTP status code set of unauthorized interface responses, an interface response content exclusion set, and an interface set that needs to be excluded.
[0007] According to an unauthorized interface scanning method provided by the present invention, the interface set to be excluded includes a dangerous interface set and a request interface set for static files; Accordingly, performing a screening request on the relevant interfaces in the interface list according to the configuration file specifically includes: Traversing the related interfaces in the interface list in parallel, and continuing to test when the related interfaces do not belong to the dangerous set and do not belong to the request interface set for the static file; When the test is continued, a GET request is sent to the relevant interface using a pre-built request library; when the response to the GET request is that the request method is not allowed, a POST request is sent to the relevant interface.
[0008] According to an unauthorized interface scanning method provided by the present invention, a screening request is made to the relevant interfaces in the interface list according to the configuration file, and further includes: When the relevant interface belongs to the dangerous interface set, outputting a prompt of not testing; And / or, when the relevant interface belongs to the request interface set for static files, a request exception prompt is output; and / or, when the response to the GET request is not allowed by the request method, a request exception prompt is output.
[0009] According to an unauthorized interface scanning method provided by the present invention, in response to obtaining a response to the screening request, judging the response according to the configuration file to obtain a scanning result specifically includes: When the response to the POST request belongs to the HTTP status code set of unauthorized interface responses and the text content of the response is not empty, if the text content of the response does not contain any elements of the interface response content exclusion set, the current related interface is returned and the related interface is added to the unauthorized list to obtain the scanning result.
[0010] According to an unauthorized interface scanning method provided by the present invention, a screening request is made to the relevant interfaces in the interface list according to the configuration file, and further includes: Deduplication of the interface list; And / or, unnecessary interfaces in the interface list are deleted according to a preset character string.
[0011] According to an unauthorized interface scanning method provided by the present invention, based on the homepage interface of the website to be scanned, relevant interfaces are extracted according to a preset configuration file to obtain an interface list, which specifically includes: Relevant interfaces of the website to be scanned are extracted according to the interface extraction rules in the configuration file to obtain an interface list; wherein the interface extraction rules include regular expressions for matching different types of interfaces.
[0012] The present invention also provides an unauthorized interface scanning device, comprising the following modules: The extraction unit is used to extract relevant interfaces based on the homepage interface of the website to be scanned according to a preset configuration file to obtain an interface list; A request unit, configured to perform a screening request on the relevant interfaces in the interface list according to the configuration file; a judgment unit, configured to, in response to obtaining a response to the screening request, judge the response according to the configuration file to obtain a scanning result; The configuration file includes predefined interface extraction rules, a set of HTTP status codes of unauthorized interface responses, a set of interface response content exclusions, and a set of interfaces that need to be excluded.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned unauthorized interface scanning methods is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the unauthorized interface scanning method described in any one of the above is implemented.
[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the unauthorized interface scanning method described above is implemented.
[0016] The unauthorized interface scanning method and device provided by the present invention extracts relevant interfaces according to a preset configuration file based on the homepage interface of the website to be scanned, and obtains an interface list; performs a screening request on the relevant interfaces in the interface list according to the configuration file; in response to obtaining a response to the screening request, the response is judged according to the configuration file to obtain a scanning result; wherein the configuration file includes a predefined interface extraction rule, an HTTP status code set of an unauthorized interface response, an interface response content exclusion set, and an interface set to be excluded. The present invention can automatically extract all interfaces of website associated links based on the provided website entry interface to be scanned, and effectively identify and judge which interfaces may have unauthorized access problems by analyzing the response content. The present invention is implemented based on a configuration file, and the configuration file can be flexibly defined, thereby realizing flexible definitions of unauthorized judgment rules, interface extraction rules, HTTP response code filtering, avoidance of dangerous functions, and filtering of meaningless responses. It is simple to use, flexible to configure, and has a low false alarm rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 This is one of the flow charts of the unauthorized interface scanning method provided by the present invention.
[0019] Figure 2 This is the second flow chart of the unauthorized interface scanning method provided by the present invention.
[0020] Figure 3 It is a structural schematic diagram of the unauthorized interface scanning device provided by the present invention.
[0021] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] Combine the following Figure 1-Figure 2 Describe the unauthorized interface scanning method of the present invention, Figure 1 It is one of the flow charts of the unauthorized interface scanning method provided by the present invention, such as Figure 1 As shown, the method comprises the following steps: Step 110: Based on the homepage interface of the website to be scanned, relevant interfaces are extracted according to a preset configuration file to obtain an interface list.
[0024] It should be noted that before the present invention is implemented, the configuration file needs to be set first, such as Figure 2 As shown. The configuration file includes predefined interface extraction rules, an HTTP status code set of unauthorized interface responses, an interface response content exclusion set, and an interface set to be excluded. Among them, the interface extraction rules, the HTTP status code set of unauthorized interface responses, the interface response content exclusion set, and the interface set to be excluded can all be flexibly defined according to requirements.
[0025] Specifically, the interface extraction rule is used to automatically extract all relevant jump interfaces according to the regular expression based on the input website homepage interface. The HTTP status code set of the unauthorized interface response includes the HTTP status code defined as the unauthorized interface response, which can be added or deleted according to the actual situation, such as 200, 405, 202, etc. The interface response content exclusion set includes some response text contents that clearly indicate unauthorized access, such as deny, access error, login exception, unauthorized access, forbidden, whitelabel error page, WAF, interception, contact administrator, contact website administrator, 401, authentication failure, etc. The interface sets that need to be excluded include some unauthorized access interface sets, dangerous interface sets, and static file request interface sets. Excluding unauthorized access interfaces can directly bypass the inspection of the corresponding field interface and improve efficiency. Static files are generally accessible to all personnel, such as js, css, png, jpg files, etc., and excluding them can also improve efficiency. Dangerous interfaces include system components or APIs (application programming interfaces) that may be abused and may cause security vulnerabilities, such as interfaces including fields such as delete, remove, add, and update.
[0026] In a specific embodiment, based on the homepage interface of the website to be scanned, relevant interfaces are extracted according to a preset configuration file to obtain an interface list, which specifically includes: Relevant interfaces of the website to be scanned are extracted according to the interface extraction rules in the configuration file to obtain an interface list; wherein the interface extraction rules include regular expressions for matching different types of interfaces.
[0027] In order to explain the configuration file in more detail, the code of the configuration file in a specific embodiment is given as follows: #Define the rules for overstepping authority (i.e. interface extraction rules)
[0028] class config: #Support regular search for URLs in js files
[0029] pattern_raw=r"""
[0030] (?:"|')#start newline delimiter (
[0032] ((?:[a-zA-Z]{1,10}; / / | / / )#Match a scheme[a-Zl*1-10or / /
[0033] [^"' / ]{1,}\.#Match a domainname(any character+dot)
[0034] [a-zA-Z]{2,}[^"']{0,}#The domainextension and / or path
[0035] |
[0036] ((?: / |\.\. / |\. / )#Start with / ,.. / ,. /
[0037] [^"'><,;|*()(%%$^ / \\\[\]#Next character can't be…
[0038] [^"'><,;|()]{1,})#Rest of the characters can't be
[0039] |
[0040] ([a-zA-z0-9\- / {1,} / #Relative endpoint with /
[0041] [a-zA-z0-9\- / {1,}#Resource name
[0042] \.(?:[a-zA-Z]{1,4}action)#Rest+extension(length 1--4or action)
[0043] (?:[\?| / ][^"|']'){0,}|#?mark with parameters
[0044] |
[0045] ([a-zA-z0-9\-]{1,}#filename
[0046] \.(?:pho|asp|aspx|isp|ison|
[0047] action|html|js|txt|xml)#+extension
[0048] (?:\?[^"|']{0,}1))#?mark with parameters )
[0050] (?:"|')#End newline delimiter.
[0051] ""
[0052] #What status code should the unauthorized interface respond to? (i.e. the set of HTTP status codes that the unauthorized interface responds to)
[0053] Result_status-_code=[200,405,202]
[0054] #Interface response content exclusion, which can be continuously filled based on experience (interface response content exclusion set): result_str_not_in = ["deny","access error","login exception","no permission to access","forbidden","Forbidden","Whitelabel Error Page","WAF","intercept","contact administrator","contact website administrator","401","authentication failed"]
[0055] #Filter static file request interface (interface set to be excluded)
[0056] static_file_type=[".js",".css",".png",".jpg",".gif",".vue",".jpeg",".svg",".min","ico"]
[0057] #Filter the request method of dangerous interfaces (the set of interfaces that need to be excluded)
[0058] forbidden_words=['delete','remove',"add","update"]
[0059] Since the content of the configuration file can be flexibly defined, the program's functions can be expanded based on the configuration file, with low maintenance costs. In addition, the configuration file is easy to write, and the functions can be customized without learning Python.
[0060] On this basis, in step 110, in the actual operation process, the homepage interface of the website to be scanned needs to be obtained through input. In a specific embodiment, the homepage list file of the website to be detected is input, such as . / source / donghang.txt. In addition, it should be explained that the interface refers to the uniform resource locator, and the website has a variety of resources that need to be accessed through the interface request.
[0061] Furthermore, after step 110, it is also necessary to set a save path for the scan result, for example, =. / file / result_donghang.txt.
[0062] Afterwards, based on the homepage interface of the website to be scanned, relevant interfaces are extracted. Specifically, the relevant jump interfaces of the homepage interfaces of all the websites to be scanned are automatically extracted according to the regular expression according to the pre-set configuration file.
[0063] In step 110, the interface of the website is recursively searched through the configuration file, thereby independently parsing the URL structure of the website and extracting all resources, so that almost all internal interfaces of the website can be obtained. Existing technology may not be able to fully cover all potential risk points of a website. The automated unauthorized interface scanning method of the present invention is intended to provide comprehensive interface detection to discover all potential security vulnerabilities of the website as much as possible.
[0064] Step 120: Perform a screening request on the relevant interfaces in the interface list according to the configuration file.
[0065] Specifically, the configuration file settings are used to automatically detect unauthorized incoming interfaces, including filtering requests and screening judgments for related interfaces in the interface list, such as Figure 2 shown.
[0066] It should be noted that the algorithms in step 120 and step 130 use multi-threading and are extremely fast.
[0067] In the process of screening requests, the embodiment of the present invention first uses the set of interfaces to be excluded in the configuration file to check the relevant interfaces in the interface list, and then sends requests to the interfaces that do not need to be excluded. The present invention can automatically initiate requests to detect each interface, and is easy to use.
[0068] Step 130: in response to obtaining a response to the screening request, judging the response according to the configuration file to obtain a scanning result; Based on the request sent in step 120, a response is obtained, and the HTTP status code set of the unauthorized interface response and the interface response content exclusion set in the configuration file are used to screen and judge according to the obtained response to obtain a scanning result.
[0069] Existing unauthorized interface detection methods often rely on manual operations or cumbersome setup steps, while the unauthorized interface scanning method provided by the present invention can cooperate with the concept of security left shift, and can realize unauthorized security detection like vulnerability scanning in the testing phase. In the use phase, only the website entry interface needs to be provided to automatically extract all website related links. In addition, the configuration file can flexibly define the judgment rules of unauthorized access, the rules of extracting interfaces, the filtering of HTTP response codes, the avoidance of dangerous functions, the filtering of meaningless responses and other functions, which truly achieves simple use, flexible configuration and low false alarm rate.
[0070] In addition, among them, security left shift is to perform security checks or security-related tasks early in the software development life cycle (SDLC), usually applied to testing. The purpose of left shift is to improve the efficiency of these tasks according to their execution time and ensure that these necessary tasks are not left to the end of the development cycle.
[0071] The following further describes step 120. In some embodiments, the interface set to be excluded includes a dangerous interface set and a request interface set for static files; Accordingly, performing a screening request on the relevant interfaces in the interface list according to the configuration file specifically includes: Traversing the related interfaces in the interface list in parallel, and continuing to test when the related interfaces do not belong to the dangerous set and do not belong to the request interface set for the static file; When the test is continued, a GET request is sent to the relevant interface using a pre-built request library; when the response to the GET request is that the request method is not allowed, a POST request is sent to the relevant interface.
[0072] Specifically, in the actual operation process, multiple interfaces are tested in parallel. First, the dangerous interface set in the interface set to be excluded in the configuration file is used to determine whether the current interface can be tested. If the current interface is not a dangerous interface, the test continues.
[0073] Afterwards, the request interface set for static files in the interface set that needs to be excluded is used to determine whether the current interface belongs to the request interface for static files. If the current interface does not belong to the request interface set for static files, the test continues and a start check prompt can be output.
[0074] Further, a GET request is sent to the current interface using a pre-built request library. It should be explained that a GET request is used to get data from a server. After that, a response to the GET request is obtained. If the response to the GET request is that the request method is not allowed, such as 405, a POST request is continued to be sent to the current interface using the request library. It should be explained that a POST request is used to send data to a server.
[0075] It should be noted that the request library can use a python external library.
[0076] Based on the above embodiment, in order to improve the efficiency of receiving responses, the response can be restricted while sending a GET request or a POST request. For example, it is not necessary to verify the server's SSL certificate during this process, the request timeout period is limited, and it is set not to follow redirects.
[0077] Based on the above embodiment, performing a screening request on the relevant interfaces in the interface list according to the configuration file further includes: When the relevant interface belongs to the dangerous interface set, outputting a prompt of not testing; And / or, when the relevant interface belongs to the request interface set for static files, a request exception prompt is output; and / or, when the response to the GET request is not allowed by the request method, a request exception prompt is output.
[0078] Specifically, when judging whether the current interface can be tested by using the dangerous interface set in the interface set to be excluded, if the current interface belongs to the dangerous interface set, no test is performed and a no test prompt can be output. In some embodiments, the corresponding no test prompt includes "the interface may be dangerous, so do not test this interface".
[0079] In addition, when determining whether the current interface belongs to the request interface for static files by using the request interface set for static files in the interface set to be excluded, if the current interface belongs to the request interface set for static files, a request exception prompt is output. In some embodiments, the corresponding request exception prompt includes "request+current interface+error".
[0080] Further, if the response to the GET request is not that the request method is not allowed, a request abnormality prompt is output. In some embodiments, the abnormality prompt includes "request+current interface+error".
[0081] The following further describes step 130. In some embodiments, in response to obtaining a response to the screening request, judging the response according to the configuration file to obtain a scanning result specifically includes: When the response to the POST request belongs to the HTTP status code set of unauthorized interface responses and the text content of the response is not empty, if the text content of the response does not contain any elements of the interface response content exclusion set, the current related interface is returned and the related interface is added to the unauthorized list to obtain the scanning result.
[0082] Specifically, the response to the POST request is first judged using the HTTP status code set of the unauthorized interface response in the configuration file. If the response to the POST request belongs to the set and the text content of the response is not empty, the next step of checking is performed.
[0083] After that, traverse each element in the interface response content exclusion set. If the text content of the response does not include any element in the interface response content exclusion set, the current interface is determined to be an unauthorized interface, and the current related interface is returned and added to the unauthorized list to obtain the scanning result. Otherwise, nothing is returned.
[0084] Since different websites may have different security requirements and risk thresholds, the present invention makes judgments based on the HTTP status code set of the unauthorized interface response and the response content exclusion set in the configuration file. The configuration file supports customized judgment logic, so that the scanning method can be adjusted and optimized according to specific business needs and security policies.
[0085] In order to provide a more detailed description of the screening request in step 120 and the screening judgment in step 130, the specific codes for performing the screening request and the screening judgment in a specific embodiment are given as follows: #Add unauthorized identification
[0086] def requestsAndcheck(url): url=url.strip("\\").strip("").strip("\n")
[0087] for forbidden_word in config.forbidden_words: if forbidden_word in url: print("The interface may be dangerous. Do not test this interface")
[0088] return None
[0089] #Exclude static files (js\css\png, etc.)
[0090] if url[-3:]not in config.static_file_type and url[-4:]not inconfig.static_file_type:print("Start checking:"+url)
[0091] try: Rg=requests.get(url,verify=False,timeout=5,allow_redirects=False)
[0092] if Rg.status_code == 405: try: Rg=requests.post(url,verify=False,timeout=5,allow_redirects=False)
[0093] except: print("request"+url+"error")
[0094] if Rg.status_code in config.result_status_code and Rg.text! ="": for str_flag in config.result_str_not_in: if str_flag not in Rg.text: return url
[0095] excellent: print("request"+url+"error")
[0096] return None
[0097] Furthermore, based on the above embodiment, the code may also include restrictions on the thread pool, implementation of multi-thread support, and writing of an unauthorized list, as follows: def check_url_access(urls,result_name="temp.txt"): MAX_WORKERS = 50 # Control the thread pool to less than 50
[0098] print("Start unauthorized check")
[0099] if urls==[]or yrls==None: print("urls is empty")
[0100] return None
[0101] print(urls)
[0102] hole_url=[]
[0103] #Multithreading support
[0104] with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:results=executor.map(requestsAndcheck,urls)
[0105] for result_url in list(results): if result_url not in hole_url and result url'=None.
[0106] hole_url.append(result_url)
[0107] print("-------------URL with unauthorized access vulnerability------------")
[0108] print(hole_url)
[0109] #Write to file
[0110] with open(result_name,"a")as f: for url in hole_url: f.write(url+"\n")
[0111] In some embodiments, performing a screening request on the relevant interfaces in the interface list according to the configuration file further includes: Deduplication of the interface list; And / or, unnecessary interfaces in the interface list are deleted according to a preset character string.
[0112] Specifically, the collected interfaces can be deduplicated and some unnecessary interfaces can be deleted. This operation can also be customized in the configuration file. In a specific embodiment, the code for deduplication and deletion of unnecessary interfaces is as follows:
[0113] def remove_duplicates(input_file,output file): unique_lines = set()
[0114] # Read the entire file directly into memory and store each line of string as a list
[0115] with open(input_file,'r')as file_in: lines = file_in.readlines()
[0116] # Remove duplicates from the list
[0117] lines = set(lines)
[0118] #Write the results to the output file
[0119] with open(output_file,'w')as file_out: file_out.writelines(lines)
[0120] print("Deduplication completed!")
[0121] def remove_unhealth_urls(input_file,output_file): urls=[]
[0122] with open(input_file "r")as f: for line_url in f.readlines(): if".action"not in line_url and"sa?"not in line_url: urls.append(line url)
[0123] with open(output_file,'w')as file out: file out.writelines(urls)
[0124] In addition, in the actual operation process, the code entry of an embodiment of the present invention is as follows: import urllib3
[0125] from utils import find by_file,find by_url,check_url_access
[0126] if__name__=="__main__": urllib3.disable_warnings()
[0127] #Perform unauthorized scanning through the URL in the file content
[0128] #file name=""
[0129] for urls in find_by_file(". / source / donghang.txt",js=False,model="undeep"):check_url_access(urls,". / file / result_donghang.txt")
[0130] #Perform unauthorized scanning by entering the URL
[0131] #urls=find_by_url(https: / / iob.ziroom.com / campus / enter)
[0132] In addition, it should be noted that the present invention also includes other implementation methods of extracting interfaces through the settings of configuration files, or requesting and performing unauthorized judgments based on customized rules of interfaces and configuration files. The embodiments of the present invention for scanning configuration files and unauthorized interfaces based on configuration files do not represent the only implementation methods of the present invention, and other implementation methods are not described in detail in the present invention.
[0133] The unauthorized interface scanning method provided by the present invention extracts relevant interfaces according to a preset configuration file based on the homepage interface of the website to be scanned, and obtains an interface list; performs a screening request on the relevant interfaces in the interface list according to the configuration file; in response to obtaining a response to the screening request, the response is judged according to the configuration file to obtain a scanning result; wherein the configuration file includes a predefined interface extraction rule, an HTTP status code set of an unauthorized interface response, an interface response content exclusion set, and an interface set to be excluded. The present invention can automatically extract all interfaces of website associated links based on the provided website entry interface to be scanned, and effectively identify and judge which interfaces may have unauthorized access problems by analyzing the response content. The present invention is implemented based on a configuration file, and the configuration file can be flexibly defined, thereby realizing flexible definitions of unauthorized judgment rules, interface extraction rules, HTTP response code filtering, avoidance of dangerous functions, and filtering of meaningless responses. It is simple to use, flexible to configure, and has a low false alarm rate.
[0134] The unauthorized interface scanning device provided by the present invention is described below. The unauthorized interface scanning device described below and the unauthorized interface scanning method described above can be referred to each other. Figure 3 As shown, the device includes the following modules: an extraction unit 310, which is used to extract relevant interfaces based on the homepage interface of the website to be scanned according to a preset configuration file to obtain an interface list; A request unit 320, configured to perform a screening request on the relevant interfaces in the interface list according to the configuration file; A judgment unit 330, configured to, in response to obtaining a response to the screening request, judge the response according to the configuration file to obtain a scanning result; The configuration file includes predefined interface extraction rules, a set of HTTP status codes of unauthorized interface responses, a set of interface response content exclusions, and a set of interfaces that need to be excluded.
[0135] According to an unauthorized interface scanning device provided by the present invention, the interface set to be excluded includes a dangerous interface set and a request interface set for static files; Accordingly, performing a screening request on the relevant interfaces in the interface list according to the configuration file specifically includes: Traversing the related interfaces in the interface list in parallel, and continuing to test when the related interfaces do not belong to the dangerous set and do not belong to the request interface set for the static file; When the test is continued, a GET request is sent to the relevant interface using a pre-built request library; when the response to the GET request is that the request method is not allowed, a POST request is sent to the relevant interface.
[0136] According to an unauthorized interface scanning device provided by the present invention, a screening request is made to the relevant interfaces in the interface list according to the configuration file, and further includes: When the relevant interface belongs to the dangerous interface set, outputting a prompt of not testing; And / or, when the relevant interface belongs to the request interface set for static files, a request exception prompt is output; and / or, when the response to the GET request is not allowed by the request method, a request exception prompt is output.
[0137] According to an unauthorized interface scanning device provided by the present invention, in response to obtaining a response to the screening request, judging the response according to the configuration file to obtain a scanning result specifically includes: When the response to the POST request belongs to the HTTP status code set of unauthorized interface responses and the text content of the response is not empty, if the text content of the response does not contain any elements of the interface response content exclusion set, the current related interface is returned and the related interface is added to the unauthorized list to obtain the scanning result.
[0138] According to an unauthorized interface scanning device provided by the present invention, a screening request is made to the relevant interfaces in the interface list according to the configuration file, and further includes: Deduplication of the interface list; And / or, unnecessary interfaces in the interface list are deleted according to a preset character string.
[0139] According to an unauthorized interface scanning device provided by the present invention, based on the homepage interface of the website to be scanned, relevant interfaces are extracted according to a preset configuration file to obtain an interface list, which specifically includes: Relevant interfaces of the website to be scanned are extracted according to the interface extraction rules in the configuration file to obtain an interface list; wherein the interface extraction rules include regular expressions for matching different types of interfaces.
[0140] The unauthorized interface scanning device provided by the present invention extracts relevant interfaces according to a preset configuration file based on the homepage interface of the website to be scanned, and obtains an interface list; performs a screening request on the relevant interfaces in the interface list according to the configuration file; in response to obtaining a response to the screening request, the response is judged according to the configuration file to obtain a scanning result; wherein the configuration file includes a predefined interface extraction rule, an HTTP status code set of an unauthorized interface response, an interface response content exclusion set, and an interface set to be excluded. The present invention can automatically extract all interfaces of website associated links based on the provided website entry interface to be scanned, and effectively identify and judge which interfaces may have unauthorized access problems by analyzing the response content. The present invention is implemented based on a configuration file, and the configuration file can be flexibly defined, thereby realizing flexible definitions of unauthorized judgment rules, interface extraction rules, HTTP response code filtering, avoidance of dangerous functions, and filtering of meaningless responses. It is simple to use, flexible to configure, and has a low false alarm rate.
[0141] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the unauthorized interface scanning method, which includes: extracting relevant interfaces according to a preset configuration file based on the homepage interface of the website to be scanned to obtain an interface list; performing a screening request on the relevant interfaces in the interface list according to the configuration file; in response to obtaining a response to the screening request, judging the response according to the configuration file to obtain a scanning result; wherein the configuration file includes a predefined interface extraction rule, an HTTP status code set of an unauthorized interface response, an interface response content exclusion set and an interface set to be excluded.
[0142] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0143] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the unauthorized interface scanning method provided by the above methods, the method including: based on the homepage interface of the website to be scanned, extracting relevant interfaces according to a preset configuration file to obtain an interface list; performing a filtering request on the relevant interfaces in the interface list according to the configuration file; in response to obtaining a response to the filtering request, judging the response according to the configuration file to obtain a scanning result; wherein the configuration file includes pre-defined interface extraction rules, a set of HTTP status codes of unauthorized interface responses, a set of interface response content exclusions, and a set of interfaces that need to be excluded.
[0144] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the unauthorized interface scanning method provided by the above-mentioned methods, the method comprising: based on the homepage interface of the website to be scanned, extracting relevant interfaces according to a preset configuration file to obtain an interface list; performing a screening request on the relevant interfaces in the interface list according to the configuration file; in response to obtaining a response to the screening request, judging the response according to the configuration file to obtain a scanning result; wherein the configuration file includes predefined interface extraction rules, a set of HTTP status codes of unauthorized interface responses, a set of interface response content exclusions, and a set of interfaces that need to be excluded.
[0145] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0146] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0147] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An unauthorized interface scanning method, characterized in that: include: Based on the homepage interface of the website to be scanned, relevant interfaces are extracted according to a preset configuration file to obtain an interface list; Performing a screening request on the relevant interfaces in the interface list according to the configuration file; In response to obtaining a response to the screening request, the response is judged according to the configuration file to obtain a scanning result; wherein the configuration file includes a predefined interface extraction rule, an HTTP status code set of unauthorized interface responses, an interface response content exclusion set, and an interface set that needs to be excluded.
2. The unauthorized interface scanning method according to claim 1, characterized in that: The interface set to be excluded includes a dangerous interface set and a request interface set for static files; Accordingly, performing a screening request on the relevant interfaces in the interface list according to the configuration file specifically includes: Traversing the related interfaces in the interface list in parallel, and continuing to test when the related interfaces do not belong to the dangerous set and do not belong to the request interface set for the static file; While continuing the test, use the pre-built request library to send a GET request to the relevant interface; When the response to the GET request is that the request method is not allowed, a POST request is sent to the relevant interface.
3. The configurable automated unauthorized interface scanning method according to claim 2, characterized in that: Performing a screening request on the relevant interfaces in the interface list according to the configuration file also includes: When the relevant interface belongs to the dangerous interface set, outputting a prompt of not testing; And / or, when the relevant interface belongs to the request interface set for static files, a request exception prompt is output; and / or, when the response to the GET request is not allowed by the request method, a request exception prompt is output.
4. The configurable automated unauthorized interface scanning method according to claim 2, characterized in that: In response to obtaining a response to the screening request, the response is judged according to the configuration file to obtain a scanning result, specifically including: when the response to the POST request belongs to the HTTP status code set of unauthorized interface responses, and the text content of the response is not empty, if the text content of the response does not contain any element of the interface response content exclusion set, then the current related interface is returned and the related interface is added to the unauthorized list to obtain a scanning result.
5. The configurable automated unauthorized interface scanning method according to claim 2, characterized in that: Performing a screening request on the relevant interfaces in the interface list according to the configuration file also includes: Deduplication of the interface list; And / or, unnecessary interfaces in the interface list are deleted according to a preset character string.
6. The configurable automated unauthorized interface scanning method according to claim 1, characterized in that: Based on the homepage interface of the website to be scanned, extracting relevant interfaces according to a preset configuration file to obtain an interface list, specifically comprising: extracting relevant interfaces of the website to be scanned according to the interface extraction rules in the configuration file to obtain an interface list; The interface extraction rules include regular expressions for matching different types of interfaces.
7. An unauthorized interface scanning device, characterized in that: include: The extraction unit is used to extract relevant interfaces based on the homepage interface of the website to be scanned according to a preset configuration file to obtain an interface list; A request unit, configured to perform a screening request on the relevant interfaces in the interface list according to the configuration file; a judgment unit, configured to, in response to obtaining a response to the screening request, judge the response according to the configuration file to obtain a scanning result; The configuration file includes predefined interface extraction rules, a set of HTTP status codes of unauthorized interface responses, a set of interface response content exclusions, and a set of interfaces that need to be excluded.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the unauthorized interface scanning method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the unauthorized interface scanning method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the unauthorized interface scanning method according to any one of claims 1 to 6 is implemented.
