Gateway CSRF test method and device, electronic equipment and medium

By obtaining and correlating the root node and menu bar node information of the device to be tested, generating a test operation diagram, automatically obtaining URL and Body content, and conducting CSRF tests, the existing test methods are solved, and the problem of inefficiency and error-prone is achieved is achieved efficiently. Accurate CSRF testing.

CN119071060APending Publication Date: 2024-12-03WUHAN SIPU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411176789.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

Existing CSRF testing methods are inefficient in testing and error-prone, resulting in an increased risk of attack success.

Method used

By obtaining the root node information of the device to be tested and correlating it with the menu bar node information, a test node operation diagram is generated, and the URL content and Body content are automatically obtained by clicking the operation button by the browser, and CSRF test is performed.

Benefits of technology

The test process is simplified, CSRF testing is automated, which improves testing efficiency, reduces manual errors, and ensures the accuracy and consistency of test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119071060A_ABST
    Figure CN119071060A_ABST
Patent Text Reader

Abstract

The invention provides a gateway CSRF test method and device, electronic equipment and a medium, and belongs to the field of network tests.The method comprises the steps that a device to be tested is logged in, and root node information of the device to be tested is obtained; obtaining menu bar node information based on the root node information, and associating the root node information with the menu bar node information to generate a test node operation graph; an operation button corresponding to the test node operation diagram is clicked through a browser, and URL content and Body content of a corresponding test node are obtained; and performing a CSRF test on the gateway based on the URL content and the Body content. According to the method and the device, the URL content and the Body content of the test node can be automatically obtained by clicking the operation button of the test node operation graph through the browser, so that the CSRF test is realized, and the technical problems that the existing CSRF test method is low in test efficiency and easy to make mistakes are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of network testing, and in particular to a CSRF testing method, device, electronic equipment and medium for a gateway. Background Art

[0002] Currently, mainstream Internet behavior management products all provide administrators with WEB (World Wide Web) access control methods. That is, after the administrator connects the Internet behavior management device to the network, he accesses the IP address of the Internet behavior management through a browser and logs in correctly on the login page. Then, he can control the Internet behavior management. When accessing the Internet behavior management, you can use the http / https protocol to access it. https is more secure and reliable than the http protocol.

[0003] However, after the administrator successfully logs in to the Internet behavior management, when operating the Internet behavior management content, currently usually http:get or http:post and other methods are used to send configuration requests, so that the Internet behavior management device can correctly receive the administrator's operation instructions. Therefore, when the administrator operates the Internet behavior management device, if the Internet behavior management does not have a CSRF (cross-site request forgery) protection mechanism, it will cause the attacker to intercept and tamper with the administrator's logged-in identity to operate the Internet behavior management, resulting in irreparable losses, thereby achieving a successful CSRF attack.

[0004] Therefore, during the functional safety test verification and final version release, it is necessary to ensure that all functional modules and all operations have a correct CSRF protection mechanism to ensure that no operation can cause CSRF attacks. Therefore, the existing CSRF testing methods have the problems of low testing efficiency and easy errors. Summary of the invention

[0005] In view of this, it is necessary to provide a gateway CSRF testing method, device, electronic device and medium to solve the technical problems of low testing efficiency and easy errors in existing CSRF testing methods.

[0006] In order to solve the above problems, the present invention provides a CSRF testing method for a gateway, comprising: Log in to the device to be tested and obtain the root node information of the device to be tested; Based on the root node information, menu bar node information is acquired, and the root node information is associated with the menu bar node information to generate a test node operation diagram; Click the operation button corresponding to the test node operation diagram through the browser to obtain the URL content and Body content of the corresponding test node; A CSRF test is performed on the gateway based on the URL content and the Body content.

[0007] In a possible implementation, logging into the device to be tested and obtaining the root node information of the device to be tested includes: Log in to the device to be tested and obtain the tested page returned by the device to be tested; The page to be tested is parsed to obtain the root node information of the device to be tested.

[0008] In a possible implementation, obtaining menu bar node information based on the root node information includes: Based on the root node information, click the corresponding root node positions in sequence through the browser to jump to the root node page; Get the left tree directory corresponding to the root node page; Associating the root node information with the left tree directory to generate a test path; Based on the test path, menu bar node information is obtained.

[0009] In a possible implementation, obtaining menu bar node information based on the test path includes: Based on the test path, enter the function module to be tested in the menu bar to obtain the tested page information; Based on the tested page information, menu bar node information is obtained.

[0010] In a possible implementation, performing a CSRF test on the gateway based on the URL content and the Body content includes: When it is determined that the network request in the URL content is a POST request, modify the network request in the URL content to a GET request, and add the Body content to the URL content to obtain a modified URL content; Perform CSRF testing on the gateway based on modified URL content.

[0011] In a possible implementation, modifying the network request in the URL content to a GET request, and adding the Body content to the URL content to obtain the modified URL content includes: The network request in the URL content is modified to a GET request, and the remaining content after deleting the Token information in the Body content is added to the URL content to obtain the modified URL content.

[0012] In one possible implementation, a CSRF test is performed on the gateway based on the modified URL content, including: Send the modified URL content to the device to be tested, and obtain the response information returned by the device to be tested; When it is determined based on the response information that the modified URL content is sent successfully or the device to be tested returns an operation successfully, it is determined that CSRF exists in the gateway.

[0013] On the other hand, the present invention also provides a CSRF testing device for a gateway, comprising: The first acquisition module is used to log in to the device to be tested and obtain the root node information of the device to be tested; An association module, used to obtain menu bar node information based on the root node information, and associate the root node information with the menu bar node information to generate a test node operation diagram; The second acquisition module is used to click the operation button corresponding to the test node operation diagram through the browser to obtain the URL content and Body content of the corresponding test node; The testing module is used to perform a CSRF test on the gateway based on the URL content and the Body content.

[0014] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps of the CSRF testing method for the gateway as described in any one of the above.

[0015] On the other hand, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the CSRF testing method for a gateway as described in any one of the above items are implemented.

[0016] The beneficial effect of adopting the above implementation mode is: the CSRF test method, device, electronic device and medium of the gateway provided by the present invention obtain the root node information of the device to be tested, and associate the root node information with the menu bar node information to be tested, so as to generate a test node operation diagram. When a test is required, the URL content and Body content of the test node can be automatically obtained by clicking the operation button of the test node operation diagram through the browser, thereby realizing the CSRF test. For the tester, it is only necessary to click the operation button. The process is simple, and the tester does not need to manually analyze the link of each request. The entire test process can be realized automatically, thereby solving the technical problems of low test efficiency and easy errors in the existing CSRF test method. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0018] Figure 1 A flowchart of an embodiment of the CSRF testing method for a gateway provided by the present invention; Figure 2 A schematic diagram of a test node operation diagram provided by the present invention; Figure 3 A flowchart of another embodiment of the CSRF testing method for a gateway provided by the present invention; Figure 4 A functional block diagram of an embodiment of a CSRF testing device for a gateway provided by the present invention; Figure 5 A schematic structural diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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 those skilled in the art without creative work are within the scope of protection of the present invention.

[0020] In the description of the embodiments of the present application, unless otherwise specified, “plurality” means two or more than two.

[0021] The terms "including" and "having" and any variations thereof in the embodiments of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product or equipment comprising a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules not clearly listed or inherent to these processes, methods, products or equipment.

[0022] The naming or numbering of the steps in the embodiments of the present invention does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The execution order of the named or numbered process steps can be changed according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved.

[0023] Reference to an "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0024] The present invention provides a CSRF testing method, device, electronic device and medium for a gateway, which are respectively described below.

[0025] like Figure 1 As shown, the present invention provides a CSRF (cross-site request forgery) testing method for a gateway, comprising: S101, log in to the device to be tested and obtain the root node information of the device to be tested; S102, based on the root node information, obtaining menu bar node information, and associating the root node information with the menu bar node information to generate a test node operation diagram; S103, clicking the operation button corresponding to the test node operation diagram through the browser to obtain the URL (Uniform Resource Locator) content and Body (request body) content of the corresponding test node; S104: Perform a CSRF test on the gateway based on the URL content and the Body content.

[0026] It can be understood that, using the test method provided by the present invention, the tester only needs to provide the test environment address and the admin administrator password. The tool integrating the method provided by the present invention will automatically access the IP (Internet Protocol) address of the device to be tested through HTTPS (Hypertext Transfer Protocol Security), correctly open the login page of the device to be tested, and use the admin administrator (an administrator with full operation permissions) to log in. After correctly logging in to the device to be tested, the tool will automatically analyze the navigation positions of all operation modules, scan and analyze all operation items, and generate a test node operation diagram. The test node operation diagram is shown in FIG. Figure 2 As shown, when the test node operation diagram is generated, the CSRF test can be started, and the historical test data will be stored. When the test is completed, the test report will be automatically generated, which effectively reduces a large number of repetitive functions for testers and avoids low-level problems such as missed tests, effectively improving work efficiency and avoiding waste of resources.

[0027] Take the current mainstream online behavior management function as an example: Process 1: The tool of the present invention uses a proxy method to log in to the device to be tested through a browser; Process 2: After successfully logging into the device to be tested, the tool of the present invention can obtain all root node information of the device to be tested and store the root node information in the Main_content (main directory) list; Process 3: Request to traverse the root node information in sequence, obtain the menu bar node information, associate the menu bar node information with the root node information and store them in the dTreeNode list; Process 4: By analyzing the position of the operable button, the tool of the present invention can automatically obtain the specific URL content of the request after the operation button in the proxy mode. All operations of the Internet behavior management device need to obtain the requested URL content to implement the function configuration. When the tool of the present invention intercepts the request content through the proxy mode, the URL corresponding to the specific operation is stored and managed, which can facilitate the subsequent inspection and modification of the URL operation content, so that the CSRF test can be quickly performed and the CSRF test node operation diagram can be generated; Process 5: After the tool of the present invention obtains the URL content corresponding to the operation, it can test and verify whether the node module operation button has CSRF attack protection. The test method is as follows: 1. Get the navigation position of all node modules on the device to be tested and the type of operation button corresponding to the node position: Navigation path: Policy Management--Control Policy; Operation type: Create a new one; Navigation path: Policy Management--Control Policy; Operation type: Edit; Navigation path: Policy Management--Control Policy; Operation type: Delete; 2. After the tool of the present invention starts the proxy, it can obtain the specific content of the URL of all operations sent to the Internet behavior management, such as the deletion operation; 3. The tool uniquely associates the intercepted URL content with the operation, so that the specific operation URL content of the specific module can be obtained; 4. The tool performs CSRF testing on specific operations of specific modules: Check whether the network request is a POST request: In the specific content of the URL, it can be determined whether the network request is a POST request, so as to perform verification; Change the POST request to a GET request, move all parameters to the URL, delete the token (temporary token) and send it down to check whether the device under test responds normally to the modified URL content; Delete the token in the request body and send the configuration to check whether the device under test responds to the modified request. After adding the Authorization:N request header to the request, delete the token and resend the request to determine whether the CSRF check can be bypassed; Process six: After performing CSRF testing on operations in all navigation nodes, horizontal and vertical test reports can be generated. Because each module operation requires the four test checks in process five, each operation test pass or test failure is clearly marked. Through the test report, you can see which module has which tests that failed, and which modules have failed a single test item. After the automated test case is executed, analyze the test results and send the test report to the development and testing department via email: The development department conducts internal investigations on such issues, strengthens precautions for such issues, and improves the quality of the development department when developing functions. According to the problem distribution type, subsequent tests will prioritize the functional coverage of modules with frequent problems, thereby improving test accuracy.

[0028] By using the tool provided by the present invention and comparing the current test process and test technology, the following problems can be solved: 1. It solves the problem of missed tests due to lack of experience or human error. The tool analyzes the interactive requests to quickly and correctly verify and modify all URL contents that need to be tested, and can be associated with the navigation position and operation of the corresponding module; 2. It solves the current complicated test process, reduces repetitive work, improves the work efficiency of the overall test team, avoids waste of resources, and solves the problem of manual operation errors caused by back-and-forth switching from the root; 3. Effectively reduce the complexity of existing tests, reduce manual intervention, and hand over complex steps, difficult steps, and operations prone to problems to the tool to complete, thereby further reducing manual testing costs and resources and effectively improving test quality; 4. It solves the problem of subsequent maintenance difficulties. When full coverage testing is required later, the URL path and test content of the previous test analysis can be directly reused to ensure the consistency of the test results. It also solves the problems of missed tests and inaccurate tests that are prone to occur in the existing manual testing process, and effectively improves the accuracy of test results. 5. Based on the conclusions of the test report analysis, improve the quality of developed products, improve the accuracy of testing, and ensure the correctness of functions from multiple dimensions.

[0029] In some embodiments, logging into the device to be tested and obtaining the root node information of the device to be tested includes: Log in to the device to be tested and obtain the tested page returned by the device to be tested; The page to be tested is parsed to obtain the root node information of the device to be tested.

[0030] It is understandable that the user can enter the account and password through the terminal device and verify the account and password. After the verification is passed, the user can log in to the device to be tested. The device to be tested will return the tested html page to the terminal device that entered the account and password.

[0031] Parse the returned HTML page to obtain the root node information of the device to be tested.

[0032] In some embodiments, based on the root node information, obtaining menu bar node information includes: Based on the root node information, click the corresponding root node positions in sequence through the browser to jump to the root node page; Get the left tree directory corresponding to the root node page; Associating the root node information with the left tree directory to generate a test path; Based on the test path, menu bar node information is obtained.

[0033] It can be understood that after obtaining all the root node information, the root node positions are clicked in turn through the browser to jump to the root node page information, which includes the left tree content information under the node. The returned html page element content can be analyzed according to the label, id, type, and button type to obtain which left tree nodes are under the current root node, and then the root node information is obtained, and then the left tree directory of the root node is obtained, and the two are combined and associated to generate a test path.

[0034] In some embodiments, based on the test path, obtaining menu bar node information includes: Based on the test path, enter the function module to be tested in the menu bar to obtain the tested page information; Based on the tested page information, menu bar node information is obtained.

[0035] It is understandable that the menu bar node information may include: create, delete, enable, disable, etc.

[0036] In some embodiments, performing a CSRF test on the gateway based on the URL content and the Body content includes: When it is determined that the network request in the URL content is a POST request, modify the network request in the URL content to a GET request, and add the Body content to the URL content to obtain a modified URL content; Perform CSRF testing on the gateway based on modified URL content.

[0037] In some embodiments, modifying the network request in the URL content to a GET request, and adding the Body content to the URL content to obtain the modified URL content includes: The network request in the URL content is modified to a GET request, and the remaining content after deleting the Token information in the Body content is added to the URL content to obtain the modified URL content.

[0038] In some embodiments, the gateway is tested for CSRF based on the modified URL content, including: Send the modified URL content to the device to be tested, and obtain the response information returned by the device to be tested; When it is determined based on the response information that the modified URL content is sent successfully or the device to be tested returns an operation successfully, it is determined that CSRF exists in the gateway.

[0039] In some embodiments, reference Figure 3 The testing method provided by the present invention comprises the following steps: Step 301: Enable the proxy function and connect to the device under test: Open the tool provided by the present invention and correctly fill in the address of the device to be tested and the user name / password; The tool uses webdriver to automatically open the browser according to the device IP address configured by the user, and turns on proxy filtering to access the device under test. Fill in the user-configured username / password to log in, and you can log in to the device under test correctly; Step 302: Get the root node information of the page being tested: After logging into the tested device correctly, enter the tested page. Through the returned HTML page, you can obtain the root node information location of the tested page: After the tool reads the page information of the device under test, it automatically stores the read information in the node list; Step 303: Analyze the left tree information of each root node: After all the root node information is obtained in step 302, the root node positions are clicked in turn through the browser to jump to the root node page information, which includes the left tree content information under the node. Through the returned HTML page element content, according to the label, id, type, and button type, it can be analyzed to obtain which left tree nodes are obtained under the current root node: In step 302, the root node information is obtained, and in step 303, the left tree directory of the root node is obtained. The tool combines the two and generates a test path; Step 304: Obtain the operation information and position of a specific module in the menu bar: According to step 302 and step 303, the navigation path (test path) can be correctly generated, and the specific modules to be tested can be entered in sequence according to the navigation path. Through the returned HTML page information, the operable modules of the tested page can be analyzed and obtained according to the keywords: Then, the specific operation is associated with the left tree node in step 303 to obtain a complete test node operation diagram; Step 305: Get the specific URL and Body content of the operation node: After obtaining the specific operation in step 304, after clicking the specific operation button through the browser, the request content is analyzed, and the URL field and Body content are stored and associated with the operation node of step 304, so that the operation URL content and the modified URL Body content can be directly used in the subsequent CSRF attack test; URL content example: Disable: POST / webui / ?g=sec_app_audit_policy_disable Enable: POST / webui / ?g=sec_app_audit_policy_enable Delete: POST / webui / ?g=sec_app_audit_policy_delete View: POST / webui / ?g=sec_app_audit_policy_appcater_jsondata Example of Body content: Host: 10.0.75.56 Cookie: USERSESSID=vn8cVq6J%2CygSuQV-TEZZ2ZTLjx6Lmc0p Content-Length: 83 Sec-Ch-Ua: "Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109" Sec-Ch-Ua-Mobile: ?0 Authorization: Y User-Agent: Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 109.0.0.0 Safari / 537.36 Content-Type: application / x-www-form-urlencoded; charset=UTF-8 Accept: * / * X-Requested-With: XMLHttpRequest Sec-Ch-Ua-Platform: "Windows" Origin: https: / / 10.0.75.56 Sec-Fetch-Site: same-origin Sec-Fetch-Mode: cors Sec-Fetch-Dest: empty Referer: https: / / 10.0.75.56 / webui / ?g=sec_ipv4_policy_show Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 The test operation node graph is associated with the URL content, and preparation for CSRF testing begins; Step 306: Check whether the request is a POST request: You can see it in the specific content of the URL, so you can verify it; Change the POST method to a GET request, move all parameters to the URL, delete the token and send it down, and check whether the device under test responds normally to the modified URL content; Delete the token in the request body and send the configuration to check whether the device under test responds to the modified request. Add the Authorization:N request header to the request, delete the token and resend the request to see if it can be bypassed. For example: 1. Perform CSRF test on the control strategy module; 2. In the test node operation diagram, we can know that the control strategy modules include: create, delete, enable, and disable modules; 3. Perform 4-step test verification on the 4 modules of the control strategy according to step 306; 4. Whenever the modified CSRF request is re-issued, and the device returns a successful operation or successful configuration, it is determined that CSRF exists; in conclusion: By using the tool provided by the present invention, the complication of the tester's workflow is fundamentally solved, repetitive work is reduced, the work efficiency of the overall test team is effectively improved, and resource waste is avoided. More testers can be devoted to other testing work, and the CSRF test can be completely handed over to automation for testing.

[0040] In summary, the present invention provides a CSRF testing method for a gateway, comprising: logging into a device to be tested and obtaining root node information of the device to be tested; based on the root node information, obtaining menu bar node information, and associating the root node information with the menu bar node information to generate a test node operation diagram; clicking an operation button corresponding to the test node operation diagram through a browser to obtain the URL content and Body content of the corresponding test node; and performing a CSRF test on the gateway based on the URL content and the Body content.

[0041] The CSRF testing method for a gateway provided by the present invention obtains the root node information of a device to be tested, and associates the root node information with the menu bar node information to be tested, so as to generate a test node operation diagram. When a test is required, the URL content and the Body content of the test node can be automatically obtained by clicking an operation button of the test node operation diagram through a browser, thereby realizing the CSRF test. For a tester, only the operation button needs to be clicked, and the process is simple. The tester does not need to manually analyze the link of each request, and the entire test process can be realized automatically, thereby solving the technical problems of low test efficiency and easy errors in the existing CSRF testing method.

[0042] like Figure 4 As shown, the present invention also provides a CSRF testing device 400 for a gateway, comprising: The first acquisition module 401 is used to log in to the device to be tested and obtain the root node information of the device to be tested; An association module 402 is used to obtain menu bar node information based on the root node information, and associate the root node information with the menu bar node information to generate a test node operation diagram; The second acquisition module 403 is used to click the operation button corresponding to the test node operation diagram through the browser to obtain the URL content and Body content of the corresponding test node; The testing module 404 is used to perform a CSRF test on the gateway based on the URL content and the Body content.

[0043] The CSRF testing device for a gateway provided in the above embodiment can implement the technical solution described in the above gateway CSRF testing method embodiment. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above gateway CSRF testing method embodiment, which will not be repeated here.

[0044] like Figure 5 As shown, the present invention also provides an electronic device 500. The electronic device 500 includes a processor 501, a memory 502 and a display 503. Figure 5 Only some components of the electronic device 500 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0045] In some embodiments, the memory 502 may be an internal storage unit of the electronic device 500, such as a hard disk or memory of the electronic device 500. In other embodiments, the memory 502 may also be an external storage device of the electronic device 500, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 500.

[0046] Furthermore, the memory 502 may include both an internal storage unit of the electronic device 500 and an external storage device. The memory 502 is used to store application software installed in the electronic device 500 and various data.

[0047] In some embodiments, the processor 501 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 502, such as the CSRF test method of the gateway in the present invention.

[0048] In some embodiments, the display 503 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 503 is used to display information on the electronic device 500 and to display a visual user interface. The components 501-503 of the electronic device 500 communicate with each other via a system bus.

[0049] In some embodiments of the present invention, when the processor 501 executes the CSRF test program of the gateway in the memory 502, the following steps may be implemented: Log in to the device to be tested and obtain the root node information of the device to be tested; Based on the root node information, menu bar node information is acquired, and the root node information is associated with the menu bar node information to generate a test node operation diagram; Click the operation button corresponding to the test node operation diagram through the browser to obtain the URL content and Body content of the corresponding test node; A CSRF test is performed on the gateway based on the URL content and the Body content.

[0050] It should be understood that: when the processor 501 executes the CSRF test program of the gateway in the memory 502, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.

[0051] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 500 mentioned, and the electronic device 500 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic device may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 500 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).

[0052] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the CSRF test method of the gateway provided by the above methods, the method comprising: Log in to the device to be tested and obtain the root node information of the device to be tested; Based on the root node information, menu bar node information is acquired, and the root node information is associated with the menu bar node information to generate a test node operation diagram; Click the operation button corresponding to the test node operation diagram through the browser to obtain the URL content and Body content of the corresponding test node; A CSRF test is performed on the gateway based on the URL content and the Body content.

[0053] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0054] The CSRF test method, device, electronic device and medium of the gateway provided by the present invention are introduced in detail above. Specific examples are used in this article to illustrate the principle and implementation mode of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A gateway CSRF testing method, It is characterized in that include: Log in to the device to be tested and obtain the root node information of the device to be tested; Based on the root node information, menu bar node information is acquired, and the root node information is associated with the menu bar node information to generate a test node operation diagram; Click the operation button corresponding to the test node operation diagram through the browser to obtain the URL content and Body content of the corresponding test node; A CSRF test is performed on the gateway based on the URL content and the Body content.

2. The CSRF testing method for a gateway according to claim 1, It is characterized in that Log in to the device to be tested and obtain the root node information of the device to be tested, including: Log in to the device to be tested and obtain the tested page returned by the device to be tested; The page to be tested is parsed to obtain the root node information of the device to be tested.

3. The CSRF testing method for a gateway according to claim 1, It is characterized in that Based on the root node information, menu bar node information is obtained, including: Based on the root node information, click the corresponding root node positions in sequence through the browser to jump to the root node page; Get the left tree directory corresponding to the root node page; Associating the root node information with the left tree directory to generate a test path; Based on the test path, menu bar node information is obtained.

4. The CSRF testing method for a gateway according to claim 3, It is characterized in that Based on the test path, menu bar node information is obtained, including: Based on the test path, enter the function module to be tested in the menu bar to obtain the tested page information; Based on the tested page information, menu bar node information is obtained.

5. The CSRF testing method for a gateway according to any one of claims 1 to 4, It is characterized in that Performing a CSRF test on the gateway based on the URL content and the Body content includes: When it is determined that the network request in the URL content is a POST request, modify the network request in the URL content to a GET request, and add the Body content to the URL content to obtain a modified URL content; Perform CSRF testing on the gateway based on modified URL content.

6. The CSRF testing method for a gateway according to claim 5, It is characterized in that Modify the network request in the URL content to a GET request, and add the Body content to the URL content to obtain the modified URL content, including: The network request in the URL content is modified to a GET request, and the remaining content after deleting the Token information in the Body content is added to the URL content to obtain the modified URL content.

7. The CSRF testing method for a gateway according to claim 5, It is characterized in that Perform CSRF testing on the gateway based on the modified URL content, including: Send the modified URL content to the device to be tested, and obtain the response information returned by the device to be tested; When it is determined based on the response information that the modified URL content is sent successfully or the device to be tested returns an operation successfully, it is determined that CSRF exists in the gateway.

8. A CSRF testing device for a gateway, It is characterized in that include: The first acquisition module is used to log in to the device to be tested and obtain the root node information of the device to be tested; An association module, used to obtain menu bar node information based on the root node information, and associate the root node information with the menu bar node information to generate a test node operation diagram; The second acquisition module is used to click the operation button corresponding to the test node operation diagram through the browser to obtain the URL content and Body content of the corresponding test node; The testing module is used to perform a CSRF test on the gateway based on the URL content and the Body content.

9. An electronic device, It is characterized in that comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps of the CSRF testing method for the gateway as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the CSRF testing method for a gateway as described in any one of claims 1 to 7 are implemented.