Port security automated testing method, device, equipment and storage medium

Through the automated testing method, the first network card sends ARP broadcast packets and querys the number of learning addresses through the second network card, solving the problem that manual testing cannot quickly and accurately evaluate port security policies, and achieving efficient and accurate port security testing.

CN118713924BActive Publication Date: 2025-02-18SHENZHEN FENGRUNDA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411119205.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-15
Publication Date
2025-02-18
Estimated Expiration
2044-08-15

AI Technical Summary

Technical Problem

Existing manual testing methods cannot quickly and accurately evaluate the behavior of switch ports in the face of a large number of MAC address learning requests, especially in dynamically changing network environments. How to quickly and accurately test and verify the effectiveness of port security policies becomes a Technical problems that need to be solved urgently.

Method used

A port security automation test method is proposed, which sends a preset number of address resolution protocol broadcast packets to the switch through the first network card, and querys the number of learning physical addresses through the second network card, and conducts port security tests based on the preset and actual learning addresses.

Benefits of technology

It realizes automation of port security testing, improves testing efficiency and accuracy, reduces human errors, ensures the reliability and consistency of test results, and improves the quality and efficiency of network security maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118713924B_ABST
    Figure CN118713924B_ABST
Patent Text Reader

Abstract

The present application discloses a port security automated testing method, device, equipment and storage medium, which relates to the technical field of network security, and discloses a port security automated testing method, including: when the port test security testing function of the first network card is turned on, a preset number of address resolution protocol broadcast packets are sent to the switch through the first network card; after detecting that the address resolution protocol broadcast packet has been sent, the preset number of learned physical addresses is queried through the second network card to obtain the number of learned physical addresses of the first network card; the port security test is performed according to the preset number of learned physical addresses and the number of learned physical addresses. By using the first network card to send a preset number of broadcast packets to the switch, and using the second network card to query the number of learned addresses, the problem of low efficiency of manual configuration and verification in traditional port security testing is solved, and the technical effect of improving network security and reliability is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network security technology, and in particular to a port security automated testing method, device, equipment and storage medium. Background Art

[0002] In the current network environment, port security is one of the key technologies to ensure that the network is not subject to unauthorized access. Traditional port security testing methods rely on manual operations, which construct and send messages by using various packet sending tools such as xcap or Xiaobing. This process is not only complicated and cumbersome, but also inefficient and prone to errors. These manual testing methods cannot meet the needs of fast, accurate and repeatable automated testing in modern network environments. The technical benefits are that through automated testing methods, the testing efficiency can be significantly improved, human errors can be reduced, and the correct implementation of port security policies can be ensured.

[0003] However, the technical problem is that the existing manual testing methods cannot effectively verify the behavior of the switch port when facing a large number of MAC address learning requests. Especially in a dynamically changing network environment, how to quickly and accurately test and verify the effectiveness of the port security policy has become a technical problem that needs to be solved urgently. This not only affects the maintenance of network security, but also limits the network administrator's ability to monitor and respond to network status.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of the present application is to provide a port security automated testing method, device, equipment and storage medium, aiming to solve the technical problem that the existing manual testing method cannot accurately and quickly evaluate the port security function.

[0006] To achieve the above object, the present application proposes a port security automation method, which is applied to a port security automation test system, wherein the port security automation test system comprises: a first network card, a switch and a second network card, wherein the first network card, the switch and the second network card communicate with each other based on a secure shell protocol; the method comprises:

[0007] When the port test security test function of the first network card is turned on, sending a preset number of address resolution protocol broadcast packets to the switch through the first network card;

[0008] After detecting that the address resolution protocol broadcast packet has been sent, querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card;

[0009] The port security test is performed according to the preset number of learned physical addresses and the number of learned physical addresses.

[0010] In one embodiment, the port security automated testing system further includes a connection module; before the step of sending a preset number of address resolution protocol broadcast packets to the switch through the first network card when the port test security test function of the first network card is turned on, it also includes:

[0011] Sending a connection instruction to the connection module through the second network card;

[0012] The connection module connects the switch and the second network card according to the connection instruction to enable a port test security test function of the first network card;

[0013] Setting the penalty mode of the port security function to protection mode;

[0014] Set the preset number of learning physical addresses in the protection mode.

[0015] In one embodiment, the port security automated testing system further includes a network packet processing module; when the port test security test function of the first network card is turned on, the step of sending a preset number of address resolution protocol broadcast packets to the switch through the first network card includes:

[0016] When the port test security test function of the first network card is turned on, generating a construction instruction to the network packet processing module through the first network card;

[0017] The network packet processing module constructs a preset number of address resolution protocol broadcast packets according to the construction instruction and sends them to the switch.

[0018] In one embodiment, the port security automated testing system further includes a regular expression module; after detecting that the address resolution protocol broadcast packet has been sent, the step of querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card includes:

[0019] After detecting that the address resolution protocol broadcast packet has been sent, generating a call instruction through the second network card;

[0020] Retrieving a preset learning physical address quantity through the retrieval instruction, and sending the retrieval instruction to the regular expression module;

[0021] The regular expression module parses the learned physical address of the first network card according to the calling instruction to obtain the number of learned physical addresses.

[0022] In one embodiment, the port security automated testing system further includes a time module, and the step of performing the port security test according to the number of learned physical addresses includes:

[0023] Set the aging time of the physical address to the preset time;

[0024] When the waiting time of the time module reaches the preset time, setting the port penalty mode of the first network card access to the restriction mode, and setting the preset number of learning physical addresses in the restriction mode;

[0025] Sending a preset number of address resolution protocol broadcast packets through the first network card;

[0026] After detecting that the address resolution protocol broadcast packet has been sent, querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card;

[0027] When the number of learned physical addresses is equal to the preset number of learned physical addresses and the switch outputs the port log, it is determined that the port security test passes.

[0028] In one embodiment, when the number of learned physical addresses is equal to the preset number of learned physical addresses and the switch outputs the port log, after the step of determining that the port security test passes, the step further includes:

[0029] When the waiting time of the time module reaches the preset time, setting the port penalty mode to which the second network card is connected to the shutdown mode, and setting the preset number of learning physical addresses in the shutdown mode;

[0030] After the preset number of address resolution protocol broadcast packets are sent, detecting whether the port connected to the second network card is in a closed state;

[0031] When the port to which the second network card is connected is in a closed state, it is determined that the port security test passes.

[0032] In one embodiment, the port security automated testing system further includes a storage module; after the step of performing the port security test according to the number of learned physical addresses, it further includes:

[0033] Obtaining the test result of the port security test;

[0034] The test result is written into a target storage location through the storage module.

[0035] In addition, to achieve the above-mentioned purpose, the present application also proposes a port security automated testing device, the port security automated testing device comprising: a packet sending module, used to send a preset number of address resolution protocol broadcast packets to a switch through the first network card when the port test security test function of the first network card is turned on;

[0036] A query module, configured to query the preset number of learned physical addresses through the second network card after detecting that the address resolution protocol broadcast packet has been sent, and obtain the number of learned physical addresses of the first network card;

[0037] A testing module is used to perform the port security test according to the number of learned physical addresses.

[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a port security automated testing device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the port security automated testing method described above.

[0039] In addition, to achieve the above objectives, the present application also proposes a storage medium, which is a computer-readable storage medium, and stores a computer program on the storage medium. When the computer program is executed by a processor, the steps of the port security automated testing method described above are implemented.

[0040] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the port security automated testing method described above are implemented.

[0041] One or more technical solutions proposed in this application have at least the following technical effects:

[0042] By adopting programmed technical means, the automated testing function is deployed on the first network card, and the network packet processing module is used to generate and send a preset number of broadcast packets to the switch, which solves the tediousness of manually sending test traffic and improves the repeatability and accuracy of the test. Subsequently, the second network card is used in combination with the regular expression module to parse the response of the switch, automatically query and verify the number of learned physical addresses, and through the automated result collection and verification process, manual testing errors are avoided and the accuracy of the test results is ensured. Compared with existing manual testing technology, this solution realizes the automation of the port security testing process, improves testing efficiency, reduces human intervention, ensures the consistency and reliability of the test, and improves the quality and efficiency of network security maintenance. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0045] Figure 1 A flow chart of the first embodiment of the method for automated port security testing provided by the present application;

[0046] Figure 2 This is a structural block diagram of the first embodiment of the port security automated testing system of the present application;

[0047] Figure 3 A flow chart of the second embodiment of the method for automated port security testing provided in this application;

[0048] Figure 4 This is a schematic diagram of the module structure of the port security automated testing device according to an embodiment of the present application;

[0049] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the port security automated testing method in the embodiment of the present application.

[0050] Description of Figure Numbers:

[0051] A first network card 10 ; a switch 20 ; and a second network card 30 .

[0052] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0053] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0054] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0055] The main solution of the embodiment of the present application is: when the port test security test function of the first network card is turned on, a preset number of address resolution protocol broadcast packets are sent to the switch through the first network card;

[0056] After detecting that the address resolution protocol broadcast packet has been sent, querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card;

[0057] The port security test is performed according to the preset number of learned physical addresses and the number of learned physical addresses.

[0058] In this embodiment, for the convenience of description, the following description is made by taking the identification port security automated testing device as the execution subject.

[0059] Since the existing manual testing methods cannot effectively verify the behavior of switch ports when facing a large number of MAC address learning requests, especially in a dynamically changing network environment, how to quickly and accurately test and verify the effectiveness of port security policies has become a technical problem that needs to be solved urgently. This not only affects the maintenance of network security, but also limits the network administrator's ability to monitor and respond to network status.

[0060] The present application provides a solution to automate the port security testing process, improve testing efficiency, reduce human intervention, ensure the consistency and reliability of testing, and improve the quality and efficiency of network security maintenance.

[0061] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a port security automated testing device, etc. The following takes the port security automated testing device as an example to illustrate this embodiment and the following embodiments.

[0062] Based on this, the present application embodiment provides a port security automated testing method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the port security automated testing method of the present application.

[0063] In this embodiment, the port security automated testing method includes steps S10 to S30:

[0064] Step S10, when the port test security test function of the first network card is turned on, sending a preset number of address resolution protocol broadcast packets to the switch through the first network card;

[0065] It should be noted that the first network card refers to the network interface card responsible for sending test traffic in the automated test system. The port test security test function refers to the function of the first network card, which can perform port security-related tests under the control of software. After turning on this function, the network card can automatically send specific network packets for testing.

[0066] In addition, it should be noted that the Address Resolution Protocol broadcast packet, or ARP broadcast packet, is a form of ARP request, which is sent to all devices in the LAN to inquire about the physical address corresponding to a specific IP address. ARP is a network layer protocol used to resolve the IP address of the network layer to the physical address of the link layer. These packets are used to trigger the switch port security mechanism.

[0067] It is understandable that the preset number of address resolution protocol broadcast packets refers to the number of ARP broadcast packets that need to be sent and has been determined and configured before the test. This number is an expected parameter of the test and is used to control the total number of ARP broadcast packets sent. In this embodiment, a preset number of 200 ARP broadcast packets are sent to test the port security function of the switch.

[0068] In addition, it is understood that a switch is a network device that forwards data packets to the correct destination based on the physical address information in the data packet. In port security testing, the switch is the object to be tested to test whether it can correctly learn and process physical addresses.

[0069] Reference Figure 2 , Figure 2 This is a structural block diagram of the first embodiment of the port security automated testing system of this application. Figure 2 As shown, the port security automated testing system includes: a first network card 10, a switch 20 and a second network card 30, wherein the first network card 10 and the switch 20 and the second network card 30 communicate with each other based on the secure shell protocol.

[0070] Step S20, after detecting that the address resolution protocol broadcast packet has been sent, querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card;

[0071] It should be noted that the second network card refers to a network card responsible for querying and verifying the test result, and the second network card obtains relevant data of the port security test by interacting with the switch.

[0072] In addition, it should be noted that the preset number of learned physical addresses refers to the maximum number of physical addresses allowed to be learned according to the port security policy set before the test starts. The preset number of learned physical addresses is an expected parameter of the test. In this embodiment, the specific value of the preset number of learned physical addresses is not limited.

[0073] The physical address usually refers to the MAC address, which is a unique address used by network devices such as computers, routers, and switches to identify themselves and conduct network communications at the data link layer. The physical address can ensure that Ethernet frames can be correctly sent and received in the network.

[0074] It can be understood that obtaining the number of physical addresses learned by the first network card means that the second network card queries the number of physical addresses actually learned by the port by sending a command to the switch to verify whether the port security policy works as expected.

[0075] Step S30, performing the port security test according to the preset number of learned physical addresses and the number of learned physical addresses.

[0076] It can be understood that the port security test is performed based on the preset number of learned physical addresses and the number of learned physical addresses to evaluate whether the port security policy works as expected based on the preset number of learned physical addresses and the number of physical addresses actually learned. If the number actually learned meets the preset value and the port can respond correctly when receiving an ARP broadcast packet that exceeds the limit, the test passes.

[0077] In a feasible implementation manner, before step S10, steps S01 to S04 may also be included:

[0078] Step S01, sending a connection instruction to the connection module through the second network card;

[0079] It should be noted that the connection module refers to a component in the port test system that is responsible for processing network connection requests and responses. The connection module may include but is not limited to a network protocol stack, an authentication mechanism, and a communication interface.

[0080] In addition, it should be noted that a connection instruction generally refers to a command or signal used to establish or configure a network connection. A connection instruction may include login information, configuration parameters or test instructions.

[0081] In this embodiment, the connection module may be a paramiko module, which is responsible for establishing and managing an SSH connection with the switch. The step of inventing the connection instruction may be that the second network card sends an SSH connection request through the paramiko module.

[0082] Step S02, the connection module connects the switch and the second network card according to the connection instruction to enable the port test security test function of the first network card;

[0083] It should be noted that the port test security test function refers to a security mechanism test implemented on the switch port to ensure that the port can correctly execute security policies, such as MAC address filtering, MAC address learning restrictions, and responses to violations.

[0084] Step S03, setting the penalty mode of the port security function to a protection mode;

[0085] It should be noted that the penalty mode of the port security function refers to the measures taken when a network device, such as a switch port, detects a violation of the port security policy. The purpose of these measures is to limit or prevent unauthorized network access and protect the network from attacks. Common penalty modes include shutdown mode, protection mode, and restriction mode.

[0086] In addition, it should be noted that in protection mode, the switch port will learn the MAC address of the device connected to the port and store it in the secure MAC address list. When the number of learned MAC addresses reaches the preset maximum number of secure MAC addresses, the port will enter the protection state to prevent unauthorized devices from accessing.

[0087] Step S04, setting the preset number of learning physical addresses in the protection mode.

[0088] It should be noted that the preset number of learned physical addresses refers to an expected value set before the test, which indicates the maximum number of MAC addresses that the switch port should learn under normal working conditions. This maximum number is an expected parameter of the test and is used to configure the port security policy.

[0089] In this embodiment, the maximum number of secure MAC addresses learned may be 100, indicating that the port can learn only 100 different MAC addresses at most. This embodiment does not specifically limit the value of the preset number of physical addresses to be learned.

[0090] In a feasible implementation, step S10 may include steps S11-S12:

[0091] Step S11, when the port test security test function of the first network card is turned on, generating a construction instruction to the network packet processing module through the first network card;

[0092] It should be noted that the network packet processing module refers to a network packet operation tool used to send, capture, parse and forge network packets. This network packet processing module is suitable for network testing, attack simulation, protocol analysis, packet injection, etc.

[0093] In addition, it should be noted that construction instructions refer to specific instructions generated by the test system and sent to the network packet processing module to guide the network packet processing module to construct specific network data packets. These construction instructions need to define the format, content and sending method of the data packet.

[0094] It is understandable that the construction instruction may specify the type, quantity, source address, destination address, and other possible parameters of the data packet to be constructed.

[0095] Step S12: the network packet processing module constructs a preset number of address resolution protocol broadcast packets according to the construction instruction, and sends them to the switch.

[0096] It should be noted that the preset number refers to the number of ARP broadcast packets that has been determined and configured before the test, and is an expected parameter of the test, used to control the total number of ARP broadcast packets sent. In this embodiment, the value of the preset number is not specifically limited.

[0097] In a specific implementation, the Python scapy module can be used as a network packet processing module, which is responsible for constructing and sending ARP broadcast packets. The sending process can be expressed as follows: the first network card generates a construction instruction to the scapy module, and the scapy module constructs 200 address resolution protocol broadcast packets according to the construction instruction and sends them to the switch.

[0098] In a feasible implementation, step S20 may include steps S21 to S23:

[0099] Step S21, after detecting that the address resolution protocol broadcast packet has been sent, generating a call instruction through the second network card;

[0100] It should be noted that the calling instruction is an instruction generated by the second network card after detecting that the address resolution protocol broadcast packet has been sent. The calling instruction is used to instruct the network packet processing module or the switch to query specific information.

[0101] Step S22, calling the preset learning physical address quantity through the calling instruction, and sending the calling instruction to the regular expression module;

[0102] It should be noted that the regular expression module is a component in the test system used to process and analyze text data. It is used for string matching, searching, replacing, and segmenting, and is suitable for complex string pattern matching and text processing tasks.

[0103] It can be understood that retrieving the preset number of learned physical addresses refers to obtaining the maximum number of MAC addresses allowed to be learned that is set according to the port security policy before the test begins.

[0104] Step S23, the regular expression module parses the learned physical address of the first network card according to the calling instruction to obtain the number of learned physical addresses.

[0105] It can be understood that parsing refers to using a regular expression module to analyze the learned physical addresses of the first network card to extract the number of MAC addresses actually learned.

[0106] In a feasible implementation, step S30 may include steps S31 to S35:

[0107] Step S31, setting the aging time of the physical address to a preset time;

[0108] It should be noted that the aging time refers to the time that a learned MAC address is retained in the MAC address table when no traffic to the corresponding address is received in a switch. After this time, the MAC address will be deleted from the table to prevent the address table from becoming outdated.

[0109] In addition, it should be noted that the preset time refers to the aging time value set according to the test requirements before the test. This preset aging time value is an expected parameter of the test and is used to control the aging behavior of the MAC address in the test environment.

[0110] Step S32, when the waiting time of the time module reaches the preset time, setting the port penalty mode of the first network card access to the restriction mode, and setting the preset number of learning physical addresses in the restriction mode;

[0111] It should be noted that the time module is a component used to control time-related operations in the test system, such as waiting and timing. It ensures that the test steps can be executed at the correct time. You can use Python's time module to implement the waiting function, such as time.sleep(10), which makes the test system wait for 10 seconds.

[0112] In addition, it should be noted that the restriction mode is a port penalty mode. In the restriction mode, when the number of MAC addresses learned by the port reaches the preset maximum number of secure MAC addresses, a port security log will be generated.

[0113] Step S33, sending a preset number of address resolution protocol broadcast packets through the first network card;

[0114] It can be understood that sending a preset number of address resolution protocol broadcast packets through the first network card can specifically be that the first network card sends 200 ARP broadcast packets through the scapy module.

[0115] Step S34, after detecting that the address resolution protocol broadcast packet has been sent, querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card;

[0116] It can be understood that querying the preset number of learned physical addresses by the second network card to obtain the number of learned physical addresses of the first network card is to use a regular expression module to filter and obtain the number of learned physical addresses of the first network card.

[0117] Step S35, when the number of learned physical addresses is equal to the preset number of learned physical addresses and the switch outputs the port log, it is determined that the port security test has passed.

[0118] It is understandable that the queried number of learned physical addresses is compared with the preset number of learned physical addresses. If the two are equal, it means that the switch has correctly learned the preset number of MAC addresses.

[0119] In addition, it is understandable that to check whether the switch has output port logs, the switch log system can be queried through the command line interface to see if there are any log records related to port security.

[0120] In the specific implementation process, set the MAC address aging time to 10 seconds to restore the environment. Use the time module to wait for 10 seconds, then change the penalty mode of the port connected to the first network card to the restriction mode, and keep the maximum number of learned secure MAC addresses at 100. Then use the second network card to send 200 ARP broadcast packets. After sending, check the following two results: use the re module to filter whether the number of learned mac addresses of the port connected to the first network card is 100; check whether there is a port security log output through the command line. If there is a log, it passes, otherwise it fails. If both of the above results are met, the port security test is considered to have passed.

[0121] In a feasible implementation manner, step S35 may further include steps S36 to S38:

[0122] Step S36, when the waiting time of the time module reaches the preset time, setting the port penalty mode of the second network card access to the shutdown mode, and setting the preset number of learning physical addresses in the shutdown mode;

[0123] It should be noted that when the port penalty mode is closed, when the number of MAC addresses learned by the port reaches the preset maximum number of secure MAC addresses, the switch will close the port and block all communications through the port.

[0124] In addition, it should be noted that the preset number of learned physical addresses in the closed mode refers to the maximum number of MAC addresses allowed to be learned in the port security policy.

[0125] Step S37, after the preset number of ARP broadcast packets are sent, detecting whether the port connected to the second network card is in a closed state;

[0126] It can be understood that after the preset number of address resolution protocol broadcast packets are sent, the port connected to the second network card is detected to be in a closed state. This means that when the port penalty mode is in the closed mode, the port is disabled because the condition is triggered when the preset number of MAC address learning is reached.

[0127] Step S38: When the port to which the second network card is connected is in a closed state, determining that the port security test passes.

[0128] It is understandable that if the port status is closed, the port security test is considered to have passed, which indicates that the port security function of the switch is working properly and can correctly close the port when the preset number of learned physical addresses is reached.

[0129] In this embodiment, a preset number of ARP broadcast packets are sent through the first network card to trigger the port security mechanism of the switch. The second network card is responsible for querying and verifying the port status to ensure that the port can respond correctly when receiving an ARP broadcast packet that exceeds the limit. Different port penalty modes are set, including protection mode, restriction mode and shutdown mode, to comprehensively test the behavior of the switch port under different security policies. By comparing the preset number of learned physical addresses with the actual number of learned physical addresses, it is evaluated whether the port security policy works as expected. At the same time, by using Python language development and combining paramiko, scapy, re, and time modules, automated testing of port security functions is achieved, solving the problems of low efficiency and complex processes in traditional manual port security testing.

[0130] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 3 , Figure 3 This is a flow chart of the second embodiment of the port security automated testing method of the present application. After step S30, the port security automated testing method further includes steps S40 to S50:

[0131] Step S40, obtaining the test result of the port security test;

[0132] It should be noted that the test result refers to the data generated by the system about the test execution and results after the port security test is completed. This usually includes information such as whether the test passed, port status, and the number of learned MAC addresses.

[0133] In the specific implementation process, the test results may include whether the port successfully learns the preset number of MAC addresses; the behavior of the port when receiving ARP broadcast packets exceeding the limit, such as whether it enters protection mode, restriction mode or shutdown mode; whether the switch outputs a port security log; whether the test passes, etc.

[0134] Step S50: writing the test result into a target storage location through the storage module.

[0135] It should be noted that the storage module refers to a software component for processing and generating table data. In the present embodiment, it refers to a Python openpyxl module for operating Excel files.

[0136] In addition, it should be noted that the target storage location refers to the file or database where the test results need to be saved, and the target storage location includes but is not limited to a local file system path, a network storage location or a database table.

[0137] It is understandable that after obtaining the test results, it is necessary to use the storage module to create or update an Excel file and write the test results into the specified cells.

[0138] This embodiment solves the problem of unsystematic and non-standard data collection and recording in traditional port security testing by means of automated testing and data recording. By obtaining detailed test results after the test is completed and writing these results into the target storage location file through the storage module, this embodiment realizes the systematic management and storage of test data. This method not only improves the traceability and analyzability of test results, but also facilitates subsequent audits and evaluations, ensuring the transparency and accuracy of network security testing.

[0139] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the port security automated testing method of the present application. More simple transformations based on this technical concept are all within the protection scope of the present application.

[0140] This application also provides a port security automated testing device, please refer to Figure 4 , the port security automated testing device comprises:

[0141] The packet sending module 10 is used to send a preset number of address resolution protocol broadcast packets to the switch through the first network card when the port test security test function of the first network card is turned on;

[0142] A query module 20, configured to query the preset number of learned physical addresses through the second network card after detecting that the address resolution protocol broadcast packet has been sent, to obtain the number of learned physical addresses of the first network card;

[0143] The testing module 30 is used to perform the port security test according to the number of learned physical addresses.

[0144] The port security automated testing device provided by the present application adopts the port security automated testing method in the above embodiment, which can solve the technical problem that the manual testing method cannot accurately and quickly evaluate the port security function. Compared with the prior art, the beneficial effects of the port security automated testing device provided by the present application are the same as the beneficial effects of the port security automated testing method provided by the above embodiment, and other technical features in the port security automated testing device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0145] The present application provides a port security automated testing device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the port security automated testing method in the above-mentioned embodiment 1.

[0146] Reference below Figure 5 , which shows a schematic diagram of the structure of a port security automated test device suitable for implementing the embodiment of the present application. The port security automated test device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The port security automated testing device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0147] like Figure 5As shown, the port security automated test equipment may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the port security automated test equipment are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the port security automated test device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a port security automated test device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.

[0148] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0149] The port security automated test device provided by the present application adopts the port security automated test method in the above embodiment, which can solve the technical problem that the manual test method cannot accurately and quickly evaluate the port security function. Compared with the prior art, the beneficial effects of the port security automated test device provided by the present application are the same as the beneficial effects of the port security automated test method provided by the above embodiment, and other technical features in the port security automated test device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0150] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0151] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0152] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the port security automated testing method in the above-mentioned embodiment.

[0153] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.

[0154] The computer-readable storage medium may be included in the port security automated test device; or may exist independently without being assembled into the port security automated test device.

[0155] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the port security automated test device, the port security automated test device: when the port test security test function of the first network card is turned on, sends a preset number of address resolution protocol broadcast packets to the switch through the first network card;

[0156] After detecting that the address resolution protocol broadcast packet has been sent, querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card;

[0157] The port security test is performed according to the preset number of learned physical addresses and the number of learned physical addresses.

[0158] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0159] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0160] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0161] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned port security automated testing method, and can solve the technical problem that the manual testing method cannot accurately and quickly evaluate the port security function. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the port security automated testing method provided by the above-mentioned embodiment, and will not be repeated here.

[0162] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned port security automated testing method when executed by a processor.

[0163] The computer program product provided by the present application can solve the technical problem that the manual testing method cannot accurately and quickly evaluate the port security function. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the port security automated testing method provided by the above embodiment, which will not be repeated here.

[0164] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A port security automated testing method, characterized in that: The method is applied to a port security automated testing system, the port security automated testing system comprising: a first network card, a switch and a second network card, the first network card and the switch and the second network card communicate based on a secure shell protocol; the method comprises: When the port security test function of the first network card is turned on, sending a preset number of address resolution protocol broadcast packets to the switch through the first network card; After detecting that the address resolution protocol broadcast packet has been sent, querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card; The port security automated testing system also includes a regular expression module; The step of querying the preset number of learned physical addresses through the second network card after detecting that the address resolution protocol broadcast packet has been sent to obtain the number of learned physical addresses of the first network card comprises: After detecting that the address resolution protocol broadcast packet has been sent, generating a call instruction through the second network card; Retrieving a preset learning physical address quantity through the retrieval instruction, and sending the retrieval instruction to the regular expression module; The regular expression module parses the learned physical address of the first network card according to the calling instruction to obtain the number of learned physical addresses; Performing a port security test according to the preset number of learned physical addresses and the number of learned physical addresses; The port security automated testing system further comprises a time module, and the step of performing a port security test according to the preset number of learned physical addresses and the number of learned physical addresses comprises: Set the aging time of the physical address to the preset time; When the waiting time of the time module reaches the preset time, setting the port penalty mode of the first network card access to the restriction mode, and setting the preset number of learning physical addresses in the restriction mode; Sending a preset number of address resolution protocol broadcast packets through the first network card; After detecting that the address resolution protocol broadcast packet has been sent, querying the preset number of learned physical addresses through the second network card to obtain the number of learned physical addresses of the first network card; When the number of learned physical addresses is equal to the preset number of learned physical addresses and the switch outputs the port log, determining that the port security test passes; After the step of determining that the port security test passes when the number of learned physical addresses is equal to the preset number of learned physical addresses and the switch outputs the port log, the step further includes: When the waiting time of the time module reaches the preset time, setting the port penalty mode to which the second network card is connected to the shutdown mode, and setting the preset number of learning physical addresses in the shutdown mode; After the preset number of address resolution protocol broadcast packets are sent, detecting whether the port connected to the second network card is in a closed state; When the port to which the second network card is connected is in a closed state, it is determined that the port security test passes.

2. The method according to claim 1, characterized in that The port security automated testing system further includes a connection module; before the step of sending a preset number of address resolution protocol broadcast packets to the switch through the first network card when the port security testing function of the first network card is turned on, it also includes: Sending a connection instruction to the connection module through the second network card; The connection module connects the switch and the second network card according to the connection instruction to enable the port security test function of the first network card; Setting the port penalty mode to protection mode; Set the preset number of learning physical addresses in the protection mode.

3. The method according to claim 1, characterized in that The port security automated testing system further includes a network packet processing module; when the port security testing function of the first network card is turned on, the step of sending a preset number of address resolution protocol broadcast packets to the switch through the first network card includes: When the port security test function of the first network card is turned on, generating a construction instruction to the network packet processing module through the first network card; The network packet processing module constructs a preset number of address resolution protocol broadcast packets according to the construction instruction and sends them to the switch.

4. The method according to claim 1, characterized in that The port security automated testing system further includes a storage module; after the step of performing the port security test according to the preset number of learned physical addresses and the number of learned physical addresses, it further includes: Get the test results of the port security test; The test result is written into a target storage location through the storage module.

5. A port security automated testing device, used to adopt the port security automated testing method according to any one of claims 1 to 4, characterized in that: The device comprises: A packet sending module, configured to send a preset number of address resolution protocol broadcast packets to the switch through the first network card when the port security test function of the first network card is turned on; A query module, configured to query the preset number of learned physical addresses through the second network card after detecting that the address resolution protocol broadcast packet has been sent, and obtain the number of learned physical addresses of the first network card; A testing module is used to perform a port security test according to the number of learned physical addresses.

6. A port security automated testing device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the port security automated testing method according to any one of claims 1 to 4.

7. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the port security automated testing method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Source MAC address learning limitation method and device, computing equipment and storage medium

    CN117792751A