CN112055003A - A method for generating private protocol fuzzing test cases based on byte length classification - Google Patents
A method for generating private protocol fuzzing test cases based on byte length classification Download PDFInfo
- Publication number
- CN112055003A CN112055003A CN202010872171.9A CN202010872171A CN112055003A CN 112055003 A CN112055003 A CN 112055003A CN 202010872171 A CN202010872171 A CN 202010872171A CN 112055003 A CN112055003 A CN 112055003A
- Authority
- CN
- China
- Prior art keywords
- byte
- private protocol
- test case
- length
- protocol
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 103
- 238000000034 method Methods 0.000 title claims abstract description 79
- 230000035772 mutation Effects 0.000 claims description 56
- 238000004891 communication Methods 0.000 claims description 12
- 238000010998 test method Methods 0.000 claims description 3
- 230000008859 change Effects 0.000 abstract description 3
- 230000008569 process Effects 0.000 description 8
- 230000002159 abnormal effect Effects 0.000 description 5
- 238000012544 monitoring process Methods 0.000 description 5
- 238000004458 analytical method Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 3
- 238000010921 in-depth analysis Methods 0.000 description 3
- 239000000306 component Substances 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000010076 replication Effects 0.000 description 2
- 238000012093 association test Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000000052 comparative effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 239000008358 core component Substances 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000005065 mining Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/14—Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
- H04L63/1408—Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
- H04L63/1425—Traffic logging, e.g. anomaly detection
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/14—Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
- H04L63/1433—Vulnerability analysis
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
本发明公开了一种基于字节长度分类的私有协议模糊测试用例生成方法,包括,利用MSA数据流对比分析私有协议的特征以确定私有协议字节长度是否可变;若私有协议字节长度可变,则对其可变字段进行内容的变异;若私有协议字节长度不变,则对其不变字段进行内容的变异和字节长度上下限的变异;根据变异后的结果生成新的测试用例,并将测试用例发送到目标设备,完成测试用例的生成。本发明结合工业控制系统私有协议高实时性和高可靠性的特点,对其进行漏洞挖掘,从而防患于未然,本方法对测试人员技术水平要求较低,不需要对协议进行深度解析,也不需要对测试技术有更高的要求。
The invention discloses a method for generating a fuzzy test case of a private protocol based on byte length classification. If the byte length of the private protocol does not change, the content of the invariant field and the upper and lower limits of the byte length will be mutated; a new test will be generated according to the mutated result. use case, and send the test case to the target device to complete the generation of the test case. The invention combines the characteristics of high real-time and high reliability of the private protocol of the industrial control system to mine the loopholes, so as to prevent problems before they occur. There is no need for higher requirements on testing techniques.
Description
技术领域technical field
本发明涉及私有协议模糊测试的技术领域,尤其涉及一种基于字节长度分类的私有协议模糊测试用例生成方法。The invention relates to the technical field of private protocol fuzz testing, in particular to a method for generating a private protocol fuzz test case based on byte length classification.
背景技术Background technique
近年来,电网系统中可编程控制器被攻击事件时有发生,严重危害国民经济建设,例如震惊世界的乌克兰电网遭受黑客攻击,导致大面积停电事故等,电网的安全运行需要更高的要求。In recent years, programmable controllers in the power grid system have been attacked from time to time, which seriously endangered the national economic construction. For example, the Ukrainian power grid that shocked the world was attacked by hackers, resulting in large-scale power outages. The safe operation of the power grid requires higher requirements.
本发明聚焦到电网中的可编程控制器的通信安全性研究,对可编程控制器的通信协议用真实的环境进行安全实验验证存在的问题,对于已知问题我们可以采取安全防护措施以弥补缺陷,防止被黑客利用,但是对于未知漏洞我们却无能为力。The present invention focuses on the research on the communication security of the programmable controller in the power grid. The communication protocol of the programmable controller is verified by the security experiment in the real environment. For the known problems, we can take safety protection measures to make up for the defects. , to prevent being exploited by hackers, but there is nothing we can do about unknown vulnerabilities.
模糊测试被广泛应用于漏洞挖掘,但这些测试大多没有考虑到跨协议或者多协议的测试,这些模糊测试是不适合工业控制系统的通信协议。当前工业控制系统模糊测试方法,模糊数据过于简单随机、对于异常定位精度不高、测试效率低下等缺点,针对工业控制系统私有协议的模糊测试测试用例生成方法更是如此。Fuzz testing is widely used in vulnerability mining, but most of these tests do not consider cross-protocol or multi-protocol testing, which is not suitable for communication protocols in industrial control systems. The current fuzzing method of industrial control system has shortcomings such as too simple and random fuzzy data, low accuracy for abnormal location, and low test efficiency, especially the method of fuzzing test case generation for the private protocol of industrial control system.
本发明结合工业控制系统私有协议高实时性和高可靠性的特点,提出一种基于字节长度分类的私有协议模糊测试用例生成方法,对其进行漏洞挖掘,从而防患于未然。本方法对测试人员技术水平要求较低,不需要对协议进行深度解析,也不需要对测试技术有更高的要求。Combining the characteristics of high real-time performance and high reliability of the private protocol of the industrial control system, the invention proposes a method for generating a fuzzy test case of a private protocol based on byte length classification, and exploits its loopholes to prevent problems before they occur. This method has lower requirements on the technical level of testers, does not require in-depth analysis of the protocol, and does not require higher requirements on testing technology.
发明内容SUMMARY OF THE INVENTION
本部分的目的在于概述本发明的实施例的一些方面以及简要介绍一些较佳实施例。在本部分以及本申请的说明书摘要和发明名称中可能会做些简化或省略以避免使本部分、说明书摘要和发明名称的目的模糊,而这种简化或省略不能用于限制本发明的范围。The purpose of this section is to outline some aspects of embodiments of the invention and to briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the abstract and title of the application to avoid obscuring the purpose of this section, abstract and title, and such simplifications or omissions may not be used to limit the scope of the invention.
鉴于上述现有存在异常定位精度不高、测试效率低下的问题,提出了本发明。In view of the above-mentioned problems of low abnormal positioning accuracy and low test efficiency, the present invention is proposed.
因此,本发明解决的技术问题是:提高异常定位精度及测试效率。Therefore, the technical problem to be solved by the present invention is to improve the abnormal positioning accuracy and the testing efficiency.
为解决上述技术问题,本发明提供如下技术方案:利用MSA数据流对比分析私有协议的特征以确定所述私有协议字节长度是否可变;若所述私有协议字节长度可变,则对其可变字段进行内容的变异;若所述私有协议字节长度不变,则对其不变字段进行内容的变异和所述字节长度上下限的变异;根据变异后的结果生成新的测试用例,并将所述测试用例发送到目标设备,完成所述测试用例的生成。In order to solve the above-mentioned technical problems, the present invention provides the following technical solutions: utilize the MSA data stream to compare and analyze the characteristics of the private protocol to determine whether the private protocol byte length is variable; if the private protocol byte length is variable, then The content of the variable field is mutated; if the byte length of the private protocol remains unchanged, the content of the invariant field and the upper and lower limits of the byte length are mutated; a new test case is generated according to the mutated result , and send the test case to the target device to complete the generation of the test case.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述私有协议的特征包括协议特征值、协议版本号、字段长度、功能码、功能码特征值和数据值。As a preferred solution of the method for generating a fuzz test case of a private protocol based on byte length classification according to the present invention, the characteristics of the private protocol include protocol feature value, protocol version number, field length, function code, function code Eigenvalues and data values.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述私有协议字段包括长度可变的字节和长度不变的字节。As a preferred solution of the method for generating private protocol fuzzing test cases based on byte length classification according to the present invention, wherein: the private protocol field includes bytes with variable length and bytes with constant length.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述私有协议字段值上下限变异定义包括,打破所述协议特征规定的字节长度范围,将所述字节长度进行加长或者缩短,再次变异其内容。As a preferred solution of the method for generating private protocol fuzzing test cases based on byte length classification according to the present invention, wherein: the definition of the upper and lower limit variation of the private protocol field value includes breaking the byte length range specified by the protocol feature , lengthen or shorten the byte length, and mutate its content again.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述字段格式变异包括根据输入字段格式调用所定义的类进行变异。As a preferred solution of the method for generating a private protocol fuzzing test case based on byte length classification according to the present invention, the field format mutation includes calling a defined class to perform mutation according to the input field format.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述新的字节数据包括,定义字节翻转突变生成所述测试用例,基于指定的变异字节根据二进制位翻转的方法生成新的字节数据。As a preferred solution of the method for generating a fuzz test case for a private protocol based on byte length classification, wherein: the new byte data includes defining a byte flip mutation to generate the test case, based on the specified The mutated byte generates new byte data according to the method of bit flipping.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述字节块变异包括,定义从默认值复制一个字节块,每个突变向前移动一个字节类;基于通信协议中有部分内容是固定值,则将需要变异的字段变换成固定值,一次移动半个字节。As a preferred solution of the method for generating private protocol fuzzing test cases based on byte length classification according to the present invention, wherein: the byte block mutation includes: copying a byte block from the default value, each mutation forward Move a byte class; based on part of the content in the communication protocol is a fixed value, then convert the field that needs to be mutated into a fixed value, and move half a byte at a time.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述执行块数据变异包括,根据变异时复制部分执行块数据,将复制的数据放于需要变异字节的之后,再改变其说明长度的数据。As a preferred solution of the method for generating a private protocol fuzzing test case based on byte length classification according to the present invention, wherein: performing the block data mutation includes: performing the block data according to the copy part during mutation, and placing the copied data in the After the bytes need to be mutated, change the data of the specified length.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述基于种子字段长度字节的基础上变异包括,定义基于执行块突变的基类,根据变异生成测试用例中变异的种子,基于所述种子字段长度字节进行变异。As a preferred solution of the method for generating private protocol fuzzing test cases based on byte length classification according to the present invention, wherein: the mutation based on the seed field length bytes includes defining a base class based on performing block mutation, Generate a seed for mutation in the test case according to the mutation, and perform mutation based on the length bytes of the seed field.
作为本发明所述的基于字节长度分类的私有协议模糊测试用例生成方法的一种优选方案,其中:所述顺序变异包括,基于指定的长度的范围内利用0~9全排列的方法包括关联测试方法和分层测试方法。As a preferred solution of the method for generating private protocol fuzzing test cases based on byte length classification according to the present invention, wherein: the sequence variation includes, the method for using full permutation of 0 to 9 within the range of the specified length includes association Test methods and layered test methods.
本发明的有益效果:本发明结合工业控制系统私有协议高实时性和高可靠性的特点,对其进行漏洞挖掘,从而防患于未然,本方法对测试人员技术水平要求较低,不需要对协议进行深度解析,也不需要对测试技术有更高的要求。Beneficial effects of the present invention: the present invention combines the characteristics of high real-time performance and high reliability of the private protocol of the industrial control system to mine loopholes, so as to prevent problems before they occur. In-depth analysis of the protocol does not require higher requirements for testing technology.
附图说明Description of drawings
为了更清楚地说明本发明实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。其中:In order to illustrate the technical solutions of the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort. in:
图1为本发明的一个实施例提供一种基于字节长度分类的私有协议模糊测试用例生成方法的测试用例生成的流程图;1 provides a flowchart of a test case generation method for a private protocol fuzzing test case generation method based on byte length classification according to an embodiment of the present invention;
图2为本发明的一个实施例提供一种基于字节长度分类的私有协议模糊测试用例生成方法的模糊测试的流程图;2 provides a flowchart of a fuzzing test of a method for generating a private protocol fuzzing test case based on byte length classification according to an embodiment of the present invention;
图3为本发明的一个实施例提供一种基于字节长度分类的私有协议模糊测试用例生成方法的私有协议特征识别和数据结构设计图。FIG. 3 provides a private protocol feature identification and data structure design diagram of a method for generating a private protocol fuzzing test case based on byte length classification according to an embodiment of the present invention.
具体实施方式Detailed ways
为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合说明书附图对本发明的具体实施方式做详细的说明,显然所描述的实施例是本发明的一部分实施例,而不是全部实施例。基于本发明中的实施例,本领域普通人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明的保护的范围。In order to make the above objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Example. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
在下面的描述中阐述了很多具体细节以便于充分理解本发明,但是本发明还可以采用其他不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本发明内涵的情况下做类似推广,因此本发明不受下面公开的具体实施例的限制。Many specific details are set forth in the following description to facilitate a full understanding of the present invention, but the present invention can also be implemented in other ways different from those described herein, and those skilled in the art can do so without departing from the connotation of the present invention. Similar promotion, therefore, the present invention is not limited by the specific embodiments disclosed below.
其次,此处所称的“一个实施例”或“实施例”是指可包含于本发明至少一个实现方式中的特定特征、结构或特性。在本说明书中不同地方出现的“在一个实施例中”并非均指同一个实施例,也不是单独的或选择性的与其他实施例互相排斥的实施例。Second, reference herein to "one embodiment" or "an embodiment" refers to a particular feature, structure, or characteristic that may be included in at least one implementation of the present invention. The appearances of "in one embodiment" in various places in this specification are not all referring to the same embodiment, nor are they separate or selectively mutually exclusive from other embodiments.
本发明结合示意图进行详细描述,在详述本发明实施例时,为便于说明,表示器件结构的剖面图会不依一般比例作局部放大,而且所述示意图只是示例,其在此不应限制本发明保护的范围。此外,在实际制作中应包含长度、宽度及深度的三维空间尺寸。The present invention is described in detail with reference to the schematic diagrams. When describing the embodiments of the present invention in detail, for the convenience of explanation, the sectional views showing the device structure will not be partially enlarged according to the general scale, and the schematic diagrams are only examples, which should not limit the present invention. scope of protection. In addition, the three-dimensional spatial dimensions of length, width and depth should be included in the actual production.
同时在本发明的描述中,需要说明的是,术语中的“上、下、内和外”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本发明和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。此外,术语“第一、第二或第三”仅用于描述目的,而不能理解为指示或暗示相对重要性。At the same time, in the description of the present invention, it should be noted that the orientation or positional relationship indicated in terms such as "upper, lower, inner and outer" is based on the orientation or positional relationship shown in the accompanying drawings, which is only for the convenience of describing the present invention. The invention and simplified description do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operate in a particular orientation, and therefore should not be construed as limiting the invention. Furthermore, the terms "first, second or third" are used for descriptive purposes only and should not be construed to indicate or imply relative importance.
本发明中除非另有明确的规定和限定,术语“安装、相连、连接”应做广义理解,例如:可以是固定连接、可拆卸连接或一体式连接;同样可以是机械连接、电连接或直接连接,也可以通过中间媒介间接相连,也可以是两个元件内部的连通。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本发明中的具体含义。Unless otherwise expressly specified and limited in the present invention, the term "installation, connection, connection" should be understood in a broad sense, for example: it may be a fixed connection, a detachable connection or an integral connection; it may also be a mechanical connection, an electrical connection or a direct connection. The connection can also be indirectly connected through an intermediate medium, or it can be the internal communication between two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood in specific situations.
实施例1Example 1
对于公开的工业控制系统通信协议,我们可以根据协议规范很清楚的知道协议的内容,然后指定测试策略,但是对于私有协议,我们无法知道协议规范内容,需要我们对协议进行初步解析。当前工业控制系统模糊测试方法,模糊数据过于简单随机、对于异常定位精度不高、测试效率低下等缺点,另外测试者需要对协议非常熟悉,当前的方法对工业控制系统私有协议的模糊测试更是无法达到高标准,高覆盖率和高效率的要求。For the public industrial control system communication protocol, we can clearly know the content of the protocol according to the protocol specification, and then specify the test strategy, but for the private protocol, we cannot know the content of the protocol specification, and we need to perform a preliminary analysis of the protocol. The current fuzzing method for industrial control systems has shortcomings such as too simple and random fuzzing data, low accuracy for abnormal positioning, and low testing efficiency. In addition, testers need to be very familiar with the protocol. The current method is especially useful for fuzzing private protocols of industrial control systems. Unable to meet high standards, high coverage and high efficiency requirements.
参照图1~3,为本发明的一个实施例,提供了一种基于字节长度分类的私有协议模糊测试用例生成方法,包括:Referring to Figures 1 to 3, an embodiment of the present invention provides a method for generating a private protocol fuzzing test case based on byte length classification, including:
S1:利用MSA数据流对比分析私有协议的特征以确定私有协议字节长度是否可变。需要说明的是,私有协议的特征包括协议特征值、协议版本号、字段长度、功能码、功能码特征值和数据值;私有协议字段包括长度可变的字节和长度不变的字节。S1: Use the MSA data stream to compare and analyze the characteristics of the private protocol to determine whether the byte length of the private protocol is variable. It should be noted that the characteristics of the private protocol include protocol characteristic value, protocol version number, field length, function code, function code characteristic value and data value; the private protocol field includes variable length bytes and invariable length bytes.
其中,私有协议的字段长度不可变是指某协议特征的字节长度值是定值,其私有协议的字段长度可变是指某协议特征的字节长度不确定,长度会根据需要进行调整。Among them, the invariable field length of a private protocol means that the byte length value of a certain protocol feature is a fixed value, and the variable field length of a private protocol means that the byte length of a certain protocol feature is uncertain, and the length will be adjusted as needed.
具体的,工业控制系统中私有协议根据功能任务的需要,通常比其它协议更加复杂,其特征主要包括协议特征值、协议版本号、字段长度、功能码、功能码特征值和数据值。首先根据测试目标协议的原始数据利用MSA数据流对比进行特征分析,识别出字段的字节长度,再进行下一步操作。Specifically, the private protocol in the industrial control system is usually more complex than other protocols according to the needs of functional tasks, and its features mainly include protocol characteristic value, protocol version number, field length, function code, function code characteristic value and data value. Firstly, according to the original data of the test target protocol, use MSA data flow comparison to carry out feature analysis, identify the byte length of the field, and then proceed to the next step.
其私有协议字段的字节长度可以分为长度可变的字节和长度不变的字节。某些协议特征的字节长度是固定值,但某些字段的字节长度根据数据传输需要进行相应的调节,同一个报文中不同字段间有相应的联系,比如上一字段的数值是下一字段的长度,把字节长度固定的字段和字节长度不固定的字段分开。The byte length of its private protocol field can be divided into variable-length bytes and invariant-length bytes. The byte length of some protocol features is a fixed value, but the byte length of some fields is adjusted according to the needs of data transmission. There are corresponding connections between different fields in the same message. For example, the value of the previous field is the following: The length of a field, which separates fields with a fixed length in bytes from fields with a non-fixed length in bytes.
S2:若私有协议字节长度可变,则对其可变字段进行内容的变异;若私有协议字节长度不变,则对其不变字段进行内容的变异和字节长度上下限的变异。S2: If the byte length of the private protocol is variable, the content of the variable field is mutated; if the byte length of the private protocol remains unchanged, the content of the invariant field and the upper and lower limits of the byte length are mutated.
其中,私有协议字段值上下限变异定义包括,打破协议特征规定的字节长度范围,将字节长度进行加长或者缩短,再次变异其内容;Among them, the definition of the upper and lower limit variation of the private protocol field value includes breaking the byte length range specified by the protocol characteristics, lengthening or shortening the byte length, and mutating its content again;
字段格式变异包括根据输入字段格式调用所定义的类进行变异;Field format mutation includes mutation according to the class defined by the input field format call;
其中,新的字节数据包括,定义字节翻转突变生成测试用例,基于指定的变异字节根据二进制位翻转的方法生成新的字节数据;Among them, the new byte data includes defining a byte flip mutation to generate a test case, and generating new byte data according to the method of binary bit flip based on the specified mutation byte;
字节块变异包括,定义从默认值复制一个字节块,每个突变向前移动一个字节类;基于通信协议中有部分内容是固定值,则将需要变异的字段变换成固定值,一次移动半个字节。Byte block mutation includes, defining copying a byte block from the default value, and moving forward a byte class for each mutation; based on some content in the communication protocol is a fixed value, then the field that needs to be mutated is transformed into a fixed value, once Move half a byte.
执行块数据变异包括,根据变异时复制部分执行块数据,将复制的数据放于需要变异字节的之后,再改变其说明长度的数据;Executing the block data mutation includes executing the block data according to the copy part during mutation, placing the copied data after the bytes that need to be mutated, and then changing the data of its description length;
基于种子字段长度字节的基础上变异包括,定义基于执行块突变的基类,根据变异生成测试用例中变异的种子,基于种子字段长度字节进行变异。Mutation based on the seed field length bytes includes defining the base class for performing block mutation, generating the seed for mutation in the test case according to the mutation, and mutating based on the seed field length bytes.
顺序变异包括,基于指定的长度的范围内利用0~9全排列的方法包括关联测试方法和分层测试方法。Sequential variation includes, based on a range of specified lengths, methods using full permutation of 0 to 9, including association testing methods and hierarchical testing methods.
具体的,对字段的字节长度固定的字段,我们只进行内容的变异生成测试用例,对长度上下限的变异不再考虑,此类字段如果超出字段的长度,在协议解析时超出的部分按照下一个特征值进行解析,不再是此字段的变异内容,下一字段的变异会在下一字段的数值变异中体现。基于其字段的字节长度不固定的字段,我们除了进行内容的变异外,还要进行字段长度上下限的变异。定义字段长度上下限的变异,主要是打破协议规定的长度范围,在协议的规定长度范围外,每增加一个字节或者减少一个字节都在进行一次新的内容变异。Specifically, for fields with a fixed byte length, we only generate test cases by mutating the content, and no longer consider the variation of the upper and lower limits of the length. If such fields exceed the length of the field, the excess part during protocol analysis will be The next eigenvalue is parsed, it is no longer the mutation content of this field, and the mutation of the next field will be reflected in the numerical mutation of the next field. Based on the field whose byte length is not fixed, we not only mutate the content, but also mutate the upper and lower limits of the field length. Defining the variation of the upper and lower limits of the field length is mainly to break the length range specified by the protocol. Outside the specified length range of the protocol, a new content mutation is performed for each additional byte or a byte decreased.
其中,内容变异策略有几种变异方法,主要包括:Among them, there are several mutation methods for content mutation strategies, including:
方法一、定义字段执行N个连续位的位翻转突变类,指定变异的字段后,把需要变异的字段进行二进制翻转操作生成测试用例。Method 1: Define a field to perform a bit-flip mutation class of N consecutive bits. After specifying the field to be mutated, perform a binary flip operation on the field that needs to be mutated to generate a test case.
方法二、定义从默认值复制一个字节块,每个突变向前移动一个字节类,在通信协议中有部分内容是固定值,对需要变异的字段变换成固定值,一次移动半个字节。Method 2. Define to copy a byte block from the default value, and move forward a byte class for each mutation. In the communication protocol, some content is a fixed value. Convert the field that needs to be mutated to a fixed value, and move half a word at a time. Festival.
方法三、定义使用多个重复执行块复制,测试用例每次变异只针对需要变异的字段,无需变异的字段进行重复执行块复制,保证通信报文的完整性。Method 3: Define the use of multiple repeated block replication. Each mutation of the test case is only for the fields that need to be mutated, and the fields that do not need to be mutated repeatedly perform block replication to ensure the integrity of the communication message.
方法四、定义用于执行块突变的基类,变异生成测试用例是利用有变异的种子,基于种子字段长度字节进行变异。Method 4: Define a base class for performing block mutation. The mutation generation test case is to use the mutated seed to mutate based on the seed field length bytes.
方法五、定义从默认值中删除一个字节块,每个突变向前移动一个字节类,在通信报文中有许多字节块,删除某个字节块生成新的测试用例。Method 5. Definition Delete a byte block from the default value, move forward a byte class for each mutation, there are many byte blocks in the communication message, delete a byte block to generate a new test case.
方法六、定义将一个字节块从默认值设置为特定值,每个突变向前移动一个字节类,对需要变异的字段设置成某些协议固定的值,每次变异移动一个字节。Method 6. Definition Set a byte block from the default value to a specific value, move one byte class forward for each mutation, set the field that needs to be mutated to a fixed value of some protocols, and move one byte for each mutation.
方法七、定义翻转消息中连续字节的数量,每个突变向前移动一个字节类。Method 7. Define the number of consecutive bytes in the flip message, and each mutation moves forward by one byte class.
方法八、根据输入字段格式调用所定义的类进行变异。Method 8: Call the defined class to mutate according to the input field format.
进一步的,上述方法一中字节翻转突变生成测试用例,在指定的变异字节按照二进制位翻转的方法生成新的字节数据,新的字节数据作为新的测试用例。上述方法二中在需要变异的字节中,字节内容变换成固定值,比如功能码识别字符,在变异的过程中,从变异字节第一位开始每次向后移动1Bit,然后从第一位开始向后移动2Bit,以此类推,直到从第一位变异后,下一次移动位数大于字节长度;上述方法三中,在变异时复制部分执行块数据,把复制的数据放在需要变异字节的后面,然后改变其说明长度的数据,作为新的测试用例。上述方法四中,确定变异的字节,确定字节的长度和取值范围,在此基础上进行随机突变生成新的测试用例。上述方法五中,在变异字节中删除一个字节,从开始到结尾依次生成新的测试用例,然后删除两个字节,同样从开始到结尾依次生成新的测试用例,直到把需要变异的内容全部删除。Further, in the above method 1, the test case is generated by byte flip mutation, and new byte data is generated according to the method of binary bit flip in the specified mutant byte, and the new byte data is used as a new test case. In the above method 2, in the byte to be mutated, the content of the byte is converted into a fixed value, such as the function code identification character. During the mutation process, the first bit of the mutated byte is moved backward by 1 bit each time, and then from the first bit. One bit starts to move backward by 2Bit, and so on, until after the mutation from the first bit, the next shift bit is greater than the byte length; in the above method three, copy part of the execution block data during mutation, and put the copied data in the It is necessary to mutate the back of the byte, and then change the data of its description length, as a new test case. In the above-mentioned method 4, the mutated bytes are determined, the length and value range of the bytes are determined, and a new test case is generated by random mutation on this basis. In the above method five, delete one byte in the mutation byte, generate a new test case from the beginning to the end, and then delete two bytes, and also generate a new test case from the beginning to the end in turn, until the test case that needs to be mutated is generated. All content is deleted.
其中,该方法可以涵盖其它关联测试和分层测试方法,因该方法使用的变异策略,每次变异一种协议特征,其他协议特征不变,所以该方法涵盖关联测试和分层测试方法。Among them, this method can cover other association testing and hierarchical testing methods. Because of the mutation strategy used in this method, one protocol feature is mutated each time, and other protocol features remain unchanged, so this method covers association testing and hierarchical testing methods.
S3:根据变异后的结果生成新的测试用例,并将测试用例发送到目标设备,完成测试用例的生成。S3: Generate a new test case according to the mutated result, and send the test case to the target device to complete the generation of the test case.
更加具体的,如图2所示确定目标,模糊测试首先要确定的是测试目标和测试范围,在没有确定测试对象和测试范围的情况下,无法对模糊测试工具或技术做出选择。通常我们需要考虑以下问题:被测目标类型,如被测目标是什么类型的控制器,根据可编程控制器的版本信息,识别所使用的通信协议,是应用层协议还是传输层协议,被测目标历史上是否出现过漏洞,漏洞原因在哪里等。如图2中识别输入,几乎所有可被人利用的漏洞都是因为设备接受了非法数据的输入,并且在处理输入数据时,没有首先清除非法数据或按照非法数据的指令操作,列举输入数据对模糊测试的成功至关重要。不能定位向目标设备输入数据对模糊测试会产生严重的影响,不能精确定位漏洞,任何发向目标设备的输入数据都应该经过构造设计,这些输入必须根据协议规约格式设定,输入数据应该包含信息头部,参数信息,功能码和数据类型等等,所有这些数据都应该被认为是模糊测试的测试用例,都应该是模糊测试变量。如图2中生成模糊测试数据,客户机一旦识别出输入向量,就可以根据识别信息生成模糊测试变量数据,可依据测试对象的特征,制定相应的模糊测试数据生成策略,例如可通过变异己有的数据动态生成数据,不管选择什么策略,生成模糊测试数据过程中都应该引入自动化。如图2中执行模糊测试,执行过程可能包括发送数据包给目标设备、启动设备或下载程序。同样,这个过程中有不断地进行测试用例生成,发送测试用例,异常监控等功能,因此测试过程自动化也是至关重要的,没有自动化,就不能成功执行有效的模糊测试。如图2中检测异常,在模糊测试过程中,对故障或异常的监视过程有重要意义,例如,如果我们没有办法准确指出是哪一个数据包引起崩溃,那么向目标设备发送10000个模糊测试数据包,最终导致设备崩溃便失去意义,监视可以采用多种形式,同时不应该依赖目标设备和所选择的模糊测试类型。如图2中检测潜在漏洞,模糊测试过程中有异常监测功能,一旦被异常监测功能监测到目标有故障发生,则需要确定所发现的漏洞是否可重现,重现故障首先要进行漏洞定位,然后使用最常用的手段就是重放检测,即调用数据包重放工具将转储的网络数据包进行重放。重现成功后,还需进一步判断该Bug是否可被利用,这是一个典型的人工过程,需要具备安全领域的专业知识。More specifically, as shown in Figure 2 to determine the target, the first thing to do in fuzz testing is to determine the test target and test scope. Without determining the test object and test scope, it is impossible to choose fuzzing tools or techniques. Usually we need to consider the following issues: the type of the target to be tested, such as what type of controller the target is, identify the communication protocol used, whether it is an application layer protocol or a transport layer protocol, according to the version information of the programmable controller Whether there have been loopholes in the history of the target, where is the cause of the loopholes, etc. Identify the input as shown in Figure 2. Almost all exploitable loopholes are because the device accepts the input of illegal data, and when processing the input data, it does not first clear the illegal data or operate according to the instructions of the illegal data, and enumerate the input data pairs. The success of fuzzing is critical. The failure to locate the input data to the target device will have a serious impact on the fuzzing test, and the vulnerability cannot be accurately located. Any input data sent to the target device should be structured and designed. These inputs must be set according to the protocol specification format, and the input data should contain information. Headers, parameter information, function codes and data types, etc., all of these data should be considered as fuzzing test cases and should be fuzzing variables. The fuzz test data is generated as shown in Figure 2. Once the client recognizes the input vector, it can generate fuzz test variable data according to the identification information, and can formulate corresponding fuzz test data generation strategies according to the characteristics of the test object. The data is generated dynamically from the data, and no matter what strategy is chosen, automation should be introduced in the process of generating fuzzing data. Perform fuzzing as shown in Figure 2. The execution process may include sending data packets to the target device, booting the device, or downloading a program. Similarly, there are functions such as continuous test case generation, test case sending, exception monitoring, etc. in this process, so the automation of the test process is also crucial. Without automation, effective fuzzing cannot be successfully performed. Detecting anomalies as shown in Figure 2. During the fuzzing process, the monitoring process for faults or anomalies is of great significance. For example, if we have no way to pinpoint which packet caused the crash, then send 10,000 fuzzing data to the target device. Packages that eventually crash the device are meaningless, monitoring can take many forms and should not depend on the target device and the type of fuzzing chosen. Potential vulnerabilities are detected as shown in Figure 2. There is an anomaly monitoring function in the fuzzing process. Once the target has a fault detected by the anomaly monitoring function, it is necessary to determine whether the discovered vulnerability can be reproduced. To reproduce the fault, the vulnerability must be located first. Then the most commonly used method is replay detection, that is, the data packet replay tool is called to replay the dumped network data packets. After the reproduction is successful, it is necessary to further determine whether the bug can be exploited. This is a typical manual process and requires professional knowledge in the security field.
如图3所示,对协议特征进行提取,对协议字段的长度可变与否进行分类,然后进行不同的变异策略。其中本发明不仅可以用于私有协议,对公开协议同样适用。As shown in Figure 3, the protocol features are extracted, the length of the protocol field is variable or not, and then different mutation strategies are carried out. The present invention can be used not only for private protocols, but also for public protocols.
实施例2Example 2
对本方法中采用的技术效果加以验证说明,本实施例选择OpenVAS(开放式漏洞评估系统)与本发明方法进行对比测试,以科学论证的手段对比试验结果,以验证本方法所具有的真实效果。The technical effect adopted in this method is verified and explained. In this embodiment, OpenVAS (Open Vulnerability Assessment System) is selected to carry out a comparative test with the method of the present invention, and the test results are compared by means of scientific demonstration to verify the real effect of the method.
其中,OpenVAS(开放式漏洞评估系统)是一个包含着相关工具的网络扫描器,其核心部件是一个服务器,包括一套网络漏洞测试程序,可以检测远程系统和应用程序中的安全问题。如图1所示,利用Kitty模糊测试框架结合ISF中的工控协议组件及传统技术方案对西门子S7comm协议执行模糊测试协议进行模糊测试挖掘漏洞。首先Kitty设定接口和目标,并且能够和目标进行三次连接以及COTP两次连接,接着调用ISF工控协议组件中的协议原始数据,模糊测试模块会根据变异方法对原始数据进行变异,生成测试用例,并发送给目标设备,而开放式漏洞评估系统直接通过网络漏洞测试程序将所测漏洞发送至服务器。其测试数据对比结果如下表所示:Among them, OpenVAS (Open Vulnerability Assessment System) is a network scanner containing related tools. Its core component is a server, including a set of network vulnerability testing programs, which can detect security problems in remote systems and applications. As shown in Figure 1, using the Kitty fuzzing framework combined with the industrial control protocol components in the ISF and traditional technical solutions to fuzz the Siemens S7comm protocol execution fuzzing protocol to mine loopholes. First, Kitty sets the interface and target, and can connect to the target three times and COTP twice, and then call the original data of the protocol in the ISF industrial control protocol component. The fuzzing module will mutate the original data according to the mutation method to generate test cases. and sent to the target device, while the Open Vulnerability Assessment System directly sends the tested vulnerabilities to the server through the network vulnerability testing program. The test data comparison results are shown in the following table:
通过两种方法相对比数据可知,使用本发明方法可以检测三个漏洞,相较于OpenVAS方法可以多检测出2个,本发明方法还可以检测出未知漏洞且耗费的时间相较于传统方案降低了816s,大大的降低了时间成本,且本发明对私有协议无需进行深度解析就可以进行模糊测试,避免了传统模糊测试生成测试用例时需要测试人员熟练掌握协议相关知识,极大减少了测试人员的负担,提高异常定位精度及测试效率,增加了测试的范围。By comparing the data between the two methods, it can be seen that three vulnerabilities can be detected by using the method of the present invention. Compared with the OpenVAS method, two more vulnerabilities can be detected. The method of the present invention can also detect unknown vulnerabilities and consume less time than the traditional solution. 816s, greatly reducing the time cost, and the present invention can perform fuzz testing without in-depth analysis of private protocols, avoiding the need for testers to be proficient in protocol-related knowledge when generating test cases in traditional fuzz testing, and greatly reducing the number of testers. It can improve the accuracy of abnormal location and test efficiency, and increase the scope of testing.
应说明的是,以上实施例仅用以说明本发明的技术方案而非限制,尽管参照较佳实施例对本发明进行了详细说明,本领域的普通技术人员应当理解,可以对本发明的技术方案进行修改或者等同替换,而不脱离本发明技术方案的精神和范围,其均应涵盖在本发明的权利要求范围当中。It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be Modifications or equivalent substitutions without departing from the spirit and scope of the technical solutions of the present invention should be included in the scope of the claims of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010872171.9A CN112055003B (en) | 2020-08-26 | 2020-08-26 | Method for generating private protocol fuzzy test case based on byte length classification |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010872171.9A CN112055003B (en) | 2020-08-26 | 2020-08-26 | Method for generating private protocol fuzzy test case based on byte length classification |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112055003A true CN112055003A (en) | 2020-12-08 |
CN112055003B CN112055003B (en) | 2022-12-23 |
Family
ID=73600894
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010872171.9A Active CN112055003B (en) | 2020-08-26 | 2020-08-26 | Method for generating private protocol fuzzy test case based on byte length classification |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112055003B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113381998A (en) * | 2021-06-08 | 2021-09-10 | 上海天旦网络科技发展有限公司 | Deep learning-based application protocol auxiliary analysis system and method |
CN114205340A (en) * | 2021-12-23 | 2022-03-18 | 绿盟科技集团股份有限公司 | Fuzzy test method and device based on intelligent power equipment |
WO2022247738A1 (en) * | 2021-05-24 | 2022-12-01 | 国网湖北电力有限公司电力科学研究院 | Electric internet-of-things protocol vulnerability detection system and method based on fuzzy testing |
CN117453573A (en) * | 2023-12-22 | 2024-01-26 | 信联科技(南京)有限公司 | Fuzzy test case generation method and engine based on protocol feature matching and mutation policy selection |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2014082908A1 (en) * | 2012-11-28 | 2014-06-05 | Siemens Aktiengesellschaft | Method and apparatus for generating test case for fuzz test |
CN105763392A (en) * | 2016-02-19 | 2016-07-13 | 中国人民解放军理工大学 | Industrial control protocol fuzzing test method based on protocol state |
CN106330601A (en) * | 2016-08-19 | 2017-01-11 | 北京匡恩网络科技有限责任公司 | Test case generating method and device |
CN108173854A (en) * | 2017-12-28 | 2018-06-15 | 广东电网有限责任公司东莞供电局 | Safety monitoring method for power private protocol |
CN109040081A (en) * | 2018-08-10 | 2018-12-18 | 哈尔滨工业大学(威海) | A kind of protocol fields conversed analysis system and method based on BWT |
CN110597734A (en) * | 2019-09-23 | 2019-12-20 | 电子科技大学 | A fuzzy test case generation method suitable for industrial control private protocol |
-
2020
- 2020-08-26 CN CN202010872171.9A patent/CN112055003B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2014082908A1 (en) * | 2012-11-28 | 2014-06-05 | Siemens Aktiengesellschaft | Method and apparatus for generating test case for fuzz test |
CN105763392A (en) * | 2016-02-19 | 2016-07-13 | 中国人民解放军理工大学 | Industrial control protocol fuzzing test method based on protocol state |
CN106330601A (en) * | 2016-08-19 | 2017-01-11 | 北京匡恩网络科技有限责任公司 | Test case generating method and device |
CN108173854A (en) * | 2017-12-28 | 2018-06-15 | 广东电网有限责任公司东莞供电局 | Safety monitoring method for power private protocol |
CN109040081A (en) * | 2018-08-10 | 2018-12-18 | 哈尔滨工业大学(威海) | A kind of protocol fields conversed analysis system and method based on BWT |
CN110597734A (en) * | 2019-09-23 | 2019-12-20 | 电子科技大学 | A fuzzy test case generation method suitable for industrial control private protocol |
Non-Patent Citations (2)
Title |
---|
刘金永等: "一种西门子S7私有协议的Fuzzing漏洞检测方法", 《上海电力大学学报》 * |
张亚丰等: "基于范式语法的工控协议Fuzzing测试技术", 《计算机应用研究》 * |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2022247738A1 (en) * | 2021-05-24 | 2022-12-01 | 国网湖北电力有限公司电力科学研究院 | Electric internet-of-things protocol vulnerability detection system and method based on fuzzy testing |
CN113381998A (en) * | 2021-06-08 | 2021-09-10 | 上海天旦网络科技发展有限公司 | Deep learning-based application protocol auxiliary analysis system and method |
CN113381998B (en) * | 2021-06-08 | 2022-11-22 | 上海天旦网络科技发展有限公司 | Deep learning-based application protocol auxiliary analysis system and method |
CN114205340A (en) * | 2021-12-23 | 2022-03-18 | 绿盟科技集团股份有限公司 | Fuzzy test method and device based on intelligent power equipment |
CN114205340B (en) * | 2021-12-23 | 2024-04-02 | 绿盟科技集团股份有限公司 | Fuzzy test method and device based on intelligent power equipment |
CN117453573A (en) * | 2023-12-22 | 2024-01-26 | 信联科技(南京)有限公司 | Fuzzy test case generation method and engine based on protocol feature matching and mutation policy selection |
CN117453573B (en) * | 2023-12-22 | 2024-04-02 | 信联科技(南京)有限公司 | Fuzzy test case generation method and engine based on protocol feature matching and mutation policy selection |
Also Published As
Publication number | Publication date |
---|---|
CN112055003B (en) | 2022-12-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112055003B (en) | Method for generating private protocol fuzzy test case based on byte length classification | |
CN109379329B (en) | Network security protocol fuzzy test method and system based on LSTM | |
CN105763392A (en) | Industrial control protocol fuzzing test method based on protocol state | |
CN105721255A (en) | Industrial control protocol vulnerability mining system based on fuzzy test | |
Pan et al. | Review of PLC security issues in industrial control system | |
CN105204487A (en) | Intrusion detection method and intrusion detection system for industrial control system based on communication model | |
CN114050979A (en) | Industrial control protocol safety test system and device | |
CN113886225B (en) | A fuzzy testing system and method for unknown industrial control protocols | |
Xiong et al. | A vulnerability detecting method for Modbus-TCP based on smart fuzzing mechanism | |
Faisal et al. | Modeling Modbus TCP for intrusion detection | |
CN108337266A (en) | A kind of efficient protocol client vulnerability mining method and system | |
CN103209173A (en) | Vulnerability mining method of network protocols | |
CN113315767A (en) | Electric power Internet of things equipment safety detection system and method | |
Banik et al. | Implementing man-in-the-middle attack to investigate network vulnerabilities in smart grid test-bed | |
CN113987504A (en) | A vulnerability detection method for network asset management | |
Wang et al. | An adaptive fuzzing method based on transformer and protocol similarity mutation | |
CN108183897A (en) | A kind of information physical emerging system safety risk estimating method | |
Men et al. | Machine learning methods for industrial protocol security analysis: Issues, taxonomy, and directions | |
CN110572296A (en) | A security detection method for communication protocol consistency of Internet of Things terminal equipment | |
CN102624587B (en) | System and method capable of achieving defect detection for IEC60870-5-101/104 communication protocol | |
CN113836539A (en) | Full-process disposal system and method for loopholes in power industrial control system based on accurate testing | |
Tu et al. | A vulnerability mining system based on fuzzing for IEC 61850 protocol | |
CN103856373B (en) | Web system robustness testing method based on HTTP mutation | |
CN110399724A (en) | A dynamic fuzzing technology based on typical vulnerability characteristics of power industrial control system | |
Lan et al. | Review on fuzz testing for protocols in industrial control systems |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |