CN116662207B - Fuzzy test method for block chain network - Google Patents
Fuzzy test method for block chain network Download PDFInfo
- Publication number
- CN116662207B CN116662207B CN202310906031.2A CN202310906031A CN116662207B CN 116662207 B CN116662207 B CN 116662207B CN 202310906031 A CN202310906031 A CN 202310906031A CN 116662207 B CN116662207 B CN 116662207B
- Authority
- CN
- China
- Prior art keywords
- test
- fuzz
- rpc
- blockchain network
- blockchain
- 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.)
- Active
Links
- 238000010998 test method Methods 0.000 title 1
- 238000012360 testing method Methods 0.000 claims abstract description 134
- 238000000034 method Methods 0.000 claims abstract description 27
- 238000012544 monitoring process Methods 0.000 claims description 14
- 230000008859 change Effects 0.000 claims description 8
- 230000005540 biological transmission Effects 0.000 claims description 5
- 230000008569 process Effects 0.000 claims description 4
- 230000004044 response Effects 0.000 abstract description 3
- 238000001514 detection method Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 2
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 239000002131 composite material Substances 0.000 description 1
- 230000001934 delay Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000005065 mining Methods 0.000 description 1
- 230000035772 mutation Effects 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
- 238000000844 transformation Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
- 238000012038 vulnerability analysis Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/362—Debugging of software
- G06F11/3624—Debugging of software by performing operations on the source code, e.g. via a compiler
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3698—Environments for analysis, debugging or testing of software
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Computer Security & Cryptography (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Software Systems (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
Description
技术领域Technical Field
本发明涉及一种针对区块链网络进行模糊测试的方法,属于区块链安全技术领域。The present invention relates to a method for performing fuzzy testing on a blockchain network, and belongs to the technical field of blockchain security.
背景技术Background technique
目前针对区块链网络的模糊测试方法较少,已有方法通常是针对区块链网络的智能合约、共识算法、虚拟机或加密算法等某个模块进行测试,或者针对区块链网络的特定漏洞分析挖掘进行测试,显然都在测试覆盖方面存在局限。Currently, there are relatively few fuzz testing methods for blockchain networks. Existing methods usually test a module of the blockchain network, such as smart contracts, consensus algorithms, virtual machines, or encryption algorithms, or perform tests on specific vulnerability analysis and mining of the blockchain network. Obviously, there are limitations in test coverage.
申请公布号为CN115357902A的中国发明专利申请提出了一种面向区块链系统的模糊测试方法,其利用Web3,人工分析区块链底层代码,定位弱点代码,构造弱点种子,并人工构造相应的弱点检测代码,然后利用模糊测试方法对区块链系统进行测试。显然其侧重于发现区块链系统特定方面的漏洞,很难覆盖区块链系统的整体情况,且测试覆盖率侧重于覆盖特定弱点相关代码,对于测试覆盖整体性未做考虑。例如未考虑测试区块链系统的查询区块链交易、查询区块、区块链最新状态、交易费查询等代码逻辑。另外,此方法通过Web3发送网络数据进行模糊测试,这种通过网络协议进行模糊测试的做法效率较低。The Chinese invention patent application with application publication number CN115357902A proposes a fuzz testing method for blockchain systems, which uses Web3 to manually analyze the underlying blockchain code, locate the weak code, construct the weak seed, and manually construct the corresponding weakness detection code, and then uses the fuzz testing method to test the blockchain system. Obviously, it focuses on discovering vulnerabilities in specific aspects of the blockchain system, and it is difficult to cover the overall situation of the blockchain system. In addition, the test coverage focuses on covering the code related to specific weaknesses, and the overall test coverage is not considered. For example, the code logic of querying blockchain transactions, querying blocks, the latest status of the blockchain, and querying transaction fees in the test blockchain system is not considered. In addition, this method sends network data through Web3 for fuzz testing. This method of fuzz testing through network protocols is inefficient.
申请公布号为CN114357459A的中国发明专利申请提出了一种面向区块链系统的信息安全检测方法,其对区块链系统的各个层进行安全检测,需要构建漏洞数据库,但其提及的模糊测试方法仅针对区块链系统的智能合约进行安全检测,测试覆盖率低。The Chinese invention patent application with application publication number CN114357459A proposes an information security detection method for blockchain systems. It performs security detection on each layer of the blockchain system and needs to build a vulnerability database. However, the fuzzy testing method mentioned therein only performs security detection on the smart contracts of the blockchain system, and the test coverage is low.
发明内容Summary of the invention
本发明的目的在于提供一种针对区块链网络进行模糊测试的方法,其解决了现有技术中针对区块链网络的测试覆盖率低的问题。The purpose of the present invention is to provide a method for performing fuzzy testing on a blockchain network, which solves the problem of low test coverage for a blockchain network in the prior art.
为了实现上述目的,本发明采用了以下技术方案:In order to achieve the above object, the present invention adopts the following technical solutions:
一种针对区块链网络进行模糊测试的方法,包括步骤:A method for fuzz testing a blockchain network, comprising the steps of:
1)根据RPC接口传输的参数类型,生成用于模糊测试的优质种子,其中,所述优质种子用于表示支持所述RPC接口传输的参数类型的测试种子;1) Generate a high-quality seed for fuzz testing according to the parameter type transmitted by the RPC interface, wherein the high-quality seed is used to represent a test seed supporting the parameter type transmitted by the RPC interface;
2)更改各所述RPC接口获取数据的方式;2) Change the way each RPC interface obtains data;
3)利用所述优质种子对区块链网络进行模糊测试。3) Use the high-quality seeds to perform fuzz testing on the blockchain network.
在具体实施时,步骤1)具体包括:In the specific implementation, step 1) specifically includes:
1-1)整理区块链网络涉及的各所述RPC接口传输参数所对应的所有类型,定义出参数类型集合P;1-1) Arrange all types corresponding to the RPC interface transmission parameters involved in the blockchain network and define a parameter type set P;
1-2)针对所述参数类型集合P的不同参数类型分别生成种子数据;1-2) Generate seed data for different parameter types of the parameter type set P respectively;
1-3)整理各所述RPC接口各自所对应的参数类型;1-3) Arrange the parameter types corresponding to each of the RPC interfaces;
1-4)针对随机选择的所述RPC接口生成优质种子,建立用于模糊测试的种子数据库。1-4) Generate high-quality seeds for the randomly selected RPC interface and establish a seed database for fuzz testing.
在具体实施时,较佳的方案是,所述步骤1-4)包括:随机选择一个所述RPC接口,基于所述步骤1-1)~1-3),针对所述RPC接口对应的各参数类型分别生成种子作为优质种子,存储并建立所述种子数据库。In a specific implementation, a preferred solution is that the step 1-4) includes: randomly selecting one of the RPC interfaces, generating seeds as high-quality seeds for each parameter type corresponding to the RPC interface based on the steps 1-1) to 1-3), and storing and establishing the seed database.
在具体实施时,所述步骤2)具体包括:分析区块链网络涉及所述RPC接口的代码,找到关于所述RPC接口的网络数据接收代码,将所述网络数据接收代码更改为从本地模糊测试器获取,其中,针对区块链网络,每个节点部署一个模糊测试器作为所述本地模糊测试器。In the specific implementation, the step 2) specifically includes: analyzing the code of the blockchain network involving the RPC interface, finding the network data receiving code about the RPC interface, and changing the network data receiving code to obtain it from a local fuzz tester, wherein, for the blockchain network, each node deploys a fuzz tester as the local fuzz tester.
在具体实施时,较佳的方案是,使用模糊测试器提供的编译工具对所述网络数据接收代码进行编译,生成插装后的区块链程序,以使所述插装后的区块链程序支持测试覆盖率监测,且尽可能覆盖区块链网络提供的所有所述RPC接口调用,引导模糊测试器调用所有所述RPC接口。In the specific implementation, the better solution is to use the compilation tool provided by the fuzz tester to compile the network data receiving code to generate an instrumented blockchain program, so that the instrumented blockchain program supports test coverage monitoring and covers all the RPC interface calls provided by the blockchain network as much as possible, and guide the fuzz tester to call all the RPC interfaces.
在具体实施时,较佳的方案是,所述RPC接口的所述网络数据接收代码的更改遵循以下逻辑:In specific implementation, a preferred solution is that the change of the network data receiving code of the RPC interface follows the following logic:
从所述本地模糊测试器获取模糊测试数据;Obtain fuzz testing data from the local fuzz tester;
随机选择一个所述RPC接口及其参数类型;Randomly select one of the RPC interfaces and its parameter types;
将所述模糊测试数据转换为所述RPC接口对应的参数类型;Convert the fuzzy test data into a parameter type corresponding to the RPC interface;
调用RPC底层方法处理所述参数类型后通过选择的所述RPC接口传输进入。The RPC underlying method is called to process the parameter type and then transmitted through the selected RPC interface.
在具体实施时,所述步骤3)具体包括:In specific implementation, the step 3) specifically includes:
3-1)为区块链网络部署模糊测试管理器,其中,所述模糊测试管理器包括节点管理模块、节点监控模块和测试报告模块;3-1) Deploy a fuzzy test manager for the blockchain network, wherein the fuzzy test manager includes a node management module, a node monitoring module and a test reporting module;
3-2)所述节点管理模块控制多个节点执行模糊测试,其中:对于每个所述节点,将种子数据库和插装后的区块链程序作为本地模糊测试器的输入;3-2) The node management module controls multiple nodes to perform fuzz testing, wherein: for each of the nodes, the seed database and the inserted blockchain program are used as inputs of the local fuzz tester;
3-3)所述节点监控模块监控每个所述节点的运行情况,其中:如果所有所述节点的测试覆盖率在规定时间内不再增长,则停止测试;3-3) The node monitoring module monitors the operation status of each node, wherein: if the test coverage of all nodes does not increase within a specified time, the test is stopped;
3-4)所述测试报告模块收集每个所述节点的模糊测试信息,生成测试报告。3-4) The test report module collects the fuzzy test information of each node and generates a test report.
在具体实施时,较佳的方案是,在所述步骤3-2)中,选择的多个所述节点部署到不同的网络区域,其中,所述网络区域是指阿里云的不同服务器所在区域。In specific implementation, a better solution is that in step 3-2), the selected multiple nodes are deployed to different network areas, wherein the network areas refer to areas where different servers of Alibaba Cloud are located.
在具体实施时,较佳的方案是,所述节点管理模块间隔设定时间随机选择一个所述节点进行停止或开启操作。In a specific implementation, a preferred solution is that the node management module randomly selects one of the nodes to stop or start the operation at a set interval.
在具体实施时,较佳的方案是,所述测试报告包括每个所述节点的IP信息、崩溃信息、引起崩溃的测试用例、测试覆盖率统计数据。In specific implementation, a preferred solution is that the test report includes the IP information of each node, crash information, test cases that caused the crash, and test coverage statistics.
本发明的优点是:The advantages of the present invention are:
本发明通过根据RPC接口生成优质种子、将模糊测试数据修改为从本地模糊测试器获取以及部署模糊测试管理器对区块链网络实施优化测试策略,有效实现了对区块链网络的较全面测试,提高了针对区块链网络的测试覆盖率,且测试效率高,响应快,实用性强。The present invention generates high-quality seeds according to the RPC interface, modifies the fuzzy test data to be obtained from the local fuzz tester, and deploys a fuzzy test manager to implement an optimized test strategy for the blockchain network, thereby effectively achieving a more comprehensive test of the blockchain network, improving the test coverage for the blockchain network, and having high test efficiency, fast response, and strong practicality.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1是本发明针对区块链网络进行模糊测试的方法的实施流程图。FIG1 is a flowchart of an implementation method of the present invention for performing fuzzy testing on a blockchain network.
图2是区块链网络部署模糊测试管理器的示意图。Figure 2 is a schematic diagram of a blockchain network deployment fuzz testing manager.
具体实施方式Detailed ways
区块链网络是目前较流行的一种成熟网络。区块链网络实际上是一群分散的网络节点的集合,这些节点由不同的参与者组成,这些参与者共同维护一个账本数据库,这个账本数据库记录了历史所有的交易情况,区块链网络使用一些分布式共识算法以及密码学技术,使得这些账本数据极其难以被某个参与者随意更改,因此其被认为是一种去中心化的分布式数据库。而分布式系统是多个处理机通过通信线路互联而构成的一种松散耦合的系统。The blockchain network is a popular mature network. The blockchain network is actually a collection of a group of decentralized network nodes, which are composed of different participants. These participants jointly maintain a ledger database, which records all historical transactions. The blockchain network uses some distributed consensus algorithms and cryptography technologies, making it extremely difficult for these ledger data to be arbitrarily changed by a participant, so it is considered to be a decentralized distributed database. A distributed system is a loosely coupled system composed of multiple processors interconnected by communication lines.
针对区块链网络,本发明提出了一种模糊测试的方法,这里所指的模糊测试,是一种通过向目标系统提供非预期的输入并监视异常结果来发现软件漏洞的方法。For blockchain networks, the present invention proposes a fuzz testing method. The fuzz testing referred to here is a method for discovering software vulnerabilities by providing unexpected inputs to the target system and monitoring abnormal results.
如图1,具体来说,本发明针对区块链网络进行模糊测试的方法包括步骤:As shown in FIG1 , specifically, the method for performing fuzzy testing on a blockchain network of the present invention comprises the following steps:
1)根据RPC接口传输的参数类型,生成用于模糊测试的优质种子,其中,优质种子用于表示支持RPC接口传输的参数类型的测试种子。1) Generate high-quality seeds for fuzz testing according to the parameter types transmitted by the RPC interface, where the high-quality seeds are used to represent test seeds that support the parameter types transmitted by the RPC interface.
为了提高测试覆盖率,所生成的优质种子应尽可能广泛支持区块链网络的各RPC接口所传输的参数类型,具体包括步骤:In order to improve the test coverage, the generated high-quality seeds should support as many parameter types as possible transmitted by each RPC interface of the blockchain network, including the following steps:
1-1)整理区块链网络涉及的各RPC接口传输参数所对应的所有类型,定义出参数类型集合P;1-1) Sort out all types corresponding to the transmission parameters of each RPC interface involved in the blockchain network and define the parameter type set P;
例如,以以太坊为例,其参数类型集合P定义为:(account{string:address,string:privateKey},transaction{string:address,BN:gas,string:gasPrice,string:nonce...},BN,array, boolen, string, contract_data)For example, taking Ethereum as an example, its parameter type set P is defined as: (account{string:address,string:privateKey},transaction{string:address,BN:gas,string:gasPrice,string:nonce...},BN,array, boolen, string, contract_data)
其中,account表示符合以太坊账户类型的数据结构,transaction表示符合以太坊交易类型的数据结构,BN表示大数类型,array表示数组类型,boolen表示布尔类型,string表示字符串类型,contract_data表示智能合约数据类型。Among them, account represents the data structure that conforms to the Ethereum account type, transaction represents the data structure that conforms to the Ethereum transaction type, BN represents the large number type, array represents the array type, boolen represents the Boolean type, string represents the string type, and contract_data represents the smart contract data type.
1-2)针对参数类型集合P的不同参数类型分别生成种子数据;1-2) Generate seed data for different parameter types of parameter type set P;
例如,对于account数据结构,使用web3.eth.accounts.create熟知方法生成。对于transaction数据结构,表示复合类型,其子类型由其他类型构成,如对于以太坊transaction,其子类型由string、BN构成,则先产生子类型的种子数据,然后组合产生transaction数据结构的种子数据。对于BN类型,使用大数据类型库的随机方法生成。对于string类型,属于基础类型,使用随机函数库生成。对于contract_data类型,表示智能合约数据类型,可以先从网络下载智能合约ABI数据集,然后利用数据集并根据ABI规范泛化生成海量的种子数据。For example, for the account data structure, use the web3.eth.accounts.create well-known method to generate it. For the transaction data structure, it represents a composite type, and its subtypes are composed of other types. For example, for Ethereum transaction, its subtypes are composed of string and BN. First, generate the seed data of the subtype, and then combine to generate the seed data of the transaction data structure. For the BN type, use the random method of the large data type library to generate it. For the string type, which is a basic type, use the random function library to generate it. For the contract_data type, it represents the smart contract data type. You can first download the smart contract ABI data set from the Internet, and then use the data set and generalize it according to the ABI specification to generate a large amount of seed data.
1-3)整理各RPC接口各自所对应的参数类型;1-3) Sort out the parameter types corresponding to each RPC interface;
在实际实施时,可按照下面伪代码描述对每个RPC接口及其所对应的参数类型进行整理:In actual implementation, each RPC interface and its corresponding parameter type can be organized according to the following pseudo code description:
{{
"rpc_methods":["rpc_methods":[
{{
"name": "defaultAccount","name": "defaultAccount",
"params": []"params": []
},{},{
"name": "getBlock","name": "getBlock",
"params":["BN"]"params":["BN"]
},{},{
"name": "sendTransaction","name": "sendTransaction",
"params":["transaction"]"params":["transaction"]
},{},{
"name": "submitWork","name": "submitWork",
"params":["string", "string", "string"]"params":["string", "string", "string"]
}}
......
]]
}}
其中,“name”表示RPC接口的名称,“params”表示RPC接口对应的参数类型。Among them, "name" indicates the name of the RPC interface, and "params" indicates the parameter type corresponding to the RPC interface.
1-4)针对随机选择的RPC接口生成优质种子,建立用于模糊测试的种子数据库;1-4) Generate high-quality seeds for randomly selected RPC interfaces and establish a seed database for fuzz testing;
在实际实施时,具体包括:随机选择一个RPC接口,基于上述1-1)~1-3),针对此RPC接口对应的各参数类型分别生成种子作为优质种子,存储并建立种子数据库。In actual implementation, it specifically includes: randomly selecting an RPC interface, based on the above 1-1) to 1-3), generating seeds as high-quality seeds for each parameter type corresponding to this RPC interface, storing and establishing a seed database.
例如可按照下面伪代码描述生成优质种子并建立种子数据库:For example, you can generate high-quality seeds and establish a seed database according to the following pseudo code description:
seeds_count = Nseeds_count = N
seeds = []seeds = []
while N != 0:while N != 0:
#随机选择一个RPC接口#Randomly select an RPC interface
rpc_name, rpc_param_types = random_select_rpc()rpc_name, rpc_param_types = random_select_rpc()
#针对RPC接口的各参数类型分别生成种子#Generate seeds for each parameter type of the RPC interface
seed = generate_seed(rpc_name, rpc_param_types)seed = generate_seed(rpc_name, rpc_param_types)
#存储种子#Store seeds
seeds.push(seed)seeds.push(seed)
N = N - 1N = N - 1
#将种子写入文件保存,种子数据库建立#Write the seed into a file and save it. Create a seed database
write_seeds_to_files(seeds)write_seeds_to_files(seeds)
2)更改各RPC接口获取数据的方式,即,将各RPC接口从网络获取数据的获取数据方式更改为从本地模糊测试器获取数据,从而极大提高测试效率。2) Change the way each RPC interface obtains data, that is, change the way each RPC interface obtains data from the network to obtaining data from the local fuzz tester, thereby greatly improving the test efficiency.
更改的过程为:分析区块链网络涉及RPC接口的代码,找到关于RPC接口的网络数据接收代码(即RPC接口用于接收网络数据的代码),将网络数据接收代码更改为从本地模糊测试器获取。针对区块链网络内的各节点(图2示出了区块链网络设计有N个节点的情形),每个节点都会部署一个模糊测试器,记为本地模糊测试器。与从网络获取数据相区别,本地模糊测试器的设计目的在于,用于RPC接口从本节点部署的模糊测试器获取数据(如可从内存获取数据),从而提高测试速度。The process of the change is: analyze the code of the RPC interface involved in the blockchain network, find the network data receiving code about the RPC interface (that is, the code used by the RPC interface to receive network data), and change the network data receiving code to obtain it from the local fuzz tester. For each node in the blockchain network (Figure 2 shows the situation where the blockchain network is designed with N nodes), a fuzz tester will be deployed on each node, recorded as a local fuzz tester. Different from obtaining data from the network, the local fuzz tester is designed to obtain data from the fuzz tester deployed on this node (such as obtaining data from memory) for the RPC interface, thereby increasing the test speed.
进一步来说,使用模糊测试器提供的编译工具对网络数据接收代码进行编译,生成插装后的区块链程序,此处的插装后的区块链程序支持测试覆盖率(更确切地说,为模糊测试代码覆盖率)监测,并且为了提高测试覆盖率,应尽可能覆盖区块链网络提供的所有RPC接口调用,引导模糊测试器调用所有RPC接口,其中,RPC接口的网络数据接收代码的更改遵循以下伪代码描述的逻辑:Specifically, the network data receiving code is compiled using the compilation tool provided by the fuzz tester to generate an instrumented blockchain program. The instrumented blockchain program here supports test coverage (more precisely, fuzz test code coverage) monitoring, and in order to improve the test coverage, all RPC interface calls provided by the blockchain network should be covered as much as possible to guide the fuzz tester to call all RPC interfaces. The changes to the network data receiving code of the RPC interface follow the logic described in the following pseudo code:
while true:while true:
#从本地模糊测试器获取模糊测试数据(此处的模糊测试数据是指模糊测试器自己生成的字节数组数据,此数据可以是随机生成,也可以是使用变异算法生成,属于模糊测试引擎常见做法)#Get fuzz test data from the local fuzz tester (the fuzz test data here refers to the byte array data generated by the fuzz tester itself. This data can be generated randomly or using a mutation algorithm, which is a common practice of fuzz test engines)
bytes[] input= get_inputs_from_fuzzer()bytes[] input = get_inputs_from_fuzzer()
#随机选择一个RPC接口及其参数类型#Randomly select an RPC interface and its parameter type
rpc_name, rpc_param_types = random_select_rpc()rpc_name, rpc_param_types = random_select_rpc()
#将模糊测试数据转换为RPC接口对应的参数类型#Convert the fuzzy test data into the parameter type corresponding to the RPC interface
rpc_params = parse_params(input, rpc_param_types)rpc_params = parse_params(input, rpc_param_types)
#调用已有的RPC底层方法处理(进行诸如参数校验等处理后,调用更底层的区块链内部处理函数进行相关处理)参数类型后通过选择的RPC接口传输进入#Call the existing RPC underlying method for processing (after processing such as parameter verification, call the lower-level blockchain internal processing function for related processing) and enter the parameter type through the selected RPC interface transmission
invoke(rpc_name, rpc_params)invoke(rpc_name, rpc_params)
3)利用所述优质种子对区块链网络进行模糊测试。3) Use the high-quality seeds to perform fuzz testing on the blockchain network.
模糊测试过程具体包括:The fuzz testing process specifically includes:
3-1)为区块链网络部署模糊测试管理器,其中,模糊测试管理器包括节点管理模块、节点监控模块和测试报告模块;3-1) Deploy a fuzz test manager for the blockchain network, where the fuzz test manager includes a node management module, a node monitoring module, and a test report module;
3-2)节点管理模块控制多个节点执行模糊测试,其中:对于每个节点,将种子数据库和插装后的区块链程序作为本地模糊测试器的输入;3-2) The node management module controls multiple nodes to perform fuzz testing, where: for each node, the seed database and the instrumented blockchain program are used as inputs of the local fuzz tester;
3-3)节点监控模块监控每个节点的运行情况,其中:如果所有节点的测试覆盖率在规定时间内不再增长,则停止测试;3-3) The node monitoring module monitors the operation of each node, where: if the test coverage of all nodes does not increase within the specified time, the test is stopped;
3-4)测试报告模块收集每个节点的模糊测试信息,生成测试报告。3-4) The test report module collects the fuzzy test information of each node and generates a test report.
具体来说,在本发明中,区块链网络设置有模糊测试管理器,用于管理、监控各节点以及生成测试报告。如图2,模糊测试管理器包括节点管理模块、节点监控模块和测试报告模块,其中:Specifically, in the present invention, the blockchain network is provided with a fuzzy test manager for managing and monitoring each node and generating a test report. As shown in Figure 2, the fuzzy test manager includes a node management module, a node monitoring module and a test report module, wherein:
节点管理模块主要用于部署、启动和停止节点,以及管理节点上部署的本地模糊测试器等。The node management module is mainly used to deploy, start and stop nodes, as well as manage the local fuzz testers deployed on the nodes.
节点管理模块执行模糊测试的方式示例:An example of how the node management module performs fuzz testing:
run_fuzzer-i [种子文件夹] [插装后的区块链程序]run_fuzzer-i [seed folder] [instrumented blockchain program]
其中,run_fuzzer-i用于启动第i个节点的插装后的区块链程序,并依据种子文件夹中的优质种子不断生成新的模糊测试数据传输入插装后的区块链程序。Among them, run_fuzzer-i is used to start the plugged-in blockchain program of the i-th node, and continuously generate new fuzz test data based on the high-quality seeds in the seed folder and transmit it into the plugged-in blockchain program.
较佳地方案是,上述选择的多个节点应部署到不同的网络区域。真实的区块链网络(公共网络)一般是全球任意节点,各个节点之间的数据同步会有延迟特性,因此区块链网络会有代码处理这样的数据同步延迟。为了追求更高的测试覆盖率,应尽可能模拟现实环境。因此,这里的网络区域可以是阿里云的不同服务器所在区域,以能够模拟现实的区块链网络情况。例如,阿里云服务器的中国香港区、孟买区、华中区域、华北区域等网络区域,这样,当节点之间数据同步时,由于各个网络区域之间的网络延迟等因素,会使得因网络因素,数据终/中断传输或网络暂时不可到达,从而使区块链网络自身的数据同步模块触发节点同步数据错误处理代码逻辑,进而能够提高测试覆盖率。The preferred solution is that the multiple nodes selected above should be deployed to different network areas. The real blockchain network (public network) is generally any node in the world, and the data synchronization between each node will have a delay characteristic, so the blockchain network will have code to handle such data synchronization delay. In order to pursue higher test coverage, the real environment should be simulated as much as possible. Therefore, the network area here can be the area where different servers of Alibaba Cloud are located, so as to simulate the real blockchain network situation. For example, the network areas of Alibaba Cloud servers in Hong Kong, Mumbai, Central China, and North China. In this way, when data is synchronized between nodes, due to factors such as network delays between various network areas, data transmission will be terminated/interrupted or the network will be temporarily unreachable due to network factors, so that the data synchronization module of the blockchain network itself triggers the node synchronization data error handling code logic, thereby improving the test coverage.
另外,为了确保能够测试到节点数据同步时的错误处理逻辑,进一步提高测试覆盖率,节点管理模块应间隔设定时间(如若干分钟)随机选择一个节点进行停止或开启操作。In addition, in order to ensure that the error handling logic during node data synchronization can be tested and further improve the test coverage, the node management module should randomly select a node to stop or start at a set time interval (such as several minutes).
节点监控模块用于获取整个区块链网络的模糊测试状态。进一步来说,为了确保测试能够收敛来停止测试,节点监控模块应周期性地收集每个节点的测试覆盖率情况,从而可以当监控的所有节点的测试覆盖率在规定时间内不再增长时停止模糊测试,避免无限制测试。The node monitoring module is used to obtain the fuzz testing status of the entire blockchain network. Furthermore, in order to ensure that the test can converge to stop the test, the node monitoring module should periodically collect the test coverage of each node, so that the fuzz testing can be stopped when the test coverage of all monitored nodes does not increase within the specified time, avoiding unlimited testing.
测试报告模块用于收集测试每个节点产生的数据,从而生成测试报告。测试报告包括每个节点的IP信息、崩溃信息、引起崩溃的测试用例、测试覆盖率统计数据等。The test report module is used to collect the data generated by each node in the test to generate a test report. The test report includes the IP information of each node, crash information, test cases that caused the crash, test coverage statistics, etc.
在本发明中,RPC(Remote Procedure Call的缩写,远程过程调用)是客户端与区块链网络交互的一套协议和接口。用户通过RPC接口可查询区块链相关信息(如区块、区块高度、节点连接等)及发送交易等。In this invention, RPC (abbreviation of Remote Procedure Call) is a set of protocols and interfaces for clients to interact with blockchain networks. Users can query blockchain-related information (such as blocks, block heights, node connections, etc.) and send transactions through the RPC interface.
在本发明中,p2p层(Peer-to-peer networking的缩写,对等网络)是区块链中通过对等形式与相邻的节点进行数据传输/同步(如区块同步、交易同步等)的一种网络层。In the present invention, the p2p layer (abbreviation of Peer-to-peer networking, peer-to-peer network) is a network layer in the blockchain that transmits/synchronizes data (such as block synchronization, transaction synchronization, etc.) with adjacent nodes in a peer-to-peer manner.
本发明通过根据RPC接口生成优质种子、将模糊测试数据修改为从本地模糊测试器获取以及部署模糊测试管理器对区块链网络实施优化测试策略,有效实现了对区块链网络的较全面测试,提高了针对区块链网络的测试覆盖率,且测试效率高,响应快,实用性强。The present invention generates high-quality seeds according to the RPC interface, modifies the fuzzy test data to be obtained from the local fuzz tester, and deploys a fuzzy test manager to implement an optimized test strategy for the blockchain network, thereby effectively achieving a more comprehensive test of the blockchain network, improving the test coverage for the blockchain network, and having high test efficiency, fast response, and strong practicality.
以上所述是本发明较佳实施例及其所运用的技术原理,对于本领域的技术人员来说,在不背离本发明的精神和范围的情况下,任何基于本发明技术方案基础上的等效变换、简单替换等显而易见的改变,均属于本发明保护范围之内。The above are preferred embodiments of the present invention and the technical principles used therein. For those skilled in the art, any obvious changes such as equivalent transformations, simple replacements, etc. based on the technical solution of the present invention, without departing from the spirit and scope of the present invention, are within the scope of protection of the present invention.
Claims (5)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310906031.2A CN116662207B (en) | 2023-07-24 | 2023-07-24 | Fuzzy test method for block chain network |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310906031.2A CN116662207B (en) | 2023-07-24 | 2023-07-24 | Fuzzy test method for block chain network |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116662207A CN116662207A (en) | 2023-08-29 |
CN116662207B true CN116662207B (en) | 2024-07-12 |
Family
ID=87717335
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310906031.2A Active CN116662207B (en) | 2023-07-24 | 2023-07-24 | Fuzzy test method for block chain network |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116662207B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118409977B (en) * | 2024-07-04 | 2024-10-11 | 浙江大学 | A fuzz testing method for Ethereum virtual machine |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107231251A (en) * | 2017-05-23 | 2017-10-03 | 中国电子科技集团公司第四十研究所 | A kind of multi-node collaborative control method of networked distributed test system |
CN108304313A (en) * | 2017-01-13 | 2018-07-20 | 阿里巴巴集团控股有限公司 | It is a kind of for the device of data test, client and method |
CN113485927A (en) * | 2021-07-06 | 2021-10-08 | 西安京迅递供应链科技有限公司 | Test data generation method, device, equipment and storage medium |
CN113778879A (en) * | 2021-09-13 | 2021-12-10 | 上海幻电信息科技有限公司 | Fuzzy test method and device for interface |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20190394113A1 (en) * | 2018-06-25 | 2019-12-26 | Blocktest Global | Systems and methods to automatically evaluate blockchain-based solution performance |
CN111459786B (en) * | 2019-01-18 | 2023-08-29 | 南京大学 | A smart contract security testing method based on mutation fuzz |
CN113392402B (en) * | 2021-05-24 | 2022-08-05 | 国网湖北省电力有限公司电力科学研究院 | A system and method for vulnerability detection of power Internet of Things protocol based on fuzzing |
CN113626324B (en) * | 2021-08-04 | 2023-09-26 | 北京航空航天大学 | Fuzzy test method for Move language virtual machine |
EP4206967A1 (en) * | 2022-01-03 | 2023-07-05 | Tata Consultancy Services Limited | Automated method and system for finding vulnerabilities in a program using fuzzing |
-
2023
- 2023-07-24 CN CN202310906031.2A patent/CN116662207B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108304313A (en) * | 2017-01-13 | 2018-07-20 | 阿里巴巴集团控股有限公司 | It is a kind of for the device of data test, client and method |
CN107231251A (en) * | 2017-05-23 | 2017-10-03 | 中国电子科技集团公司第四十研究所 | A kind of multi-node collaborative control method of networked distributed test system |
CN113485927A (en) * | 2021-07-06 | 2021-10-08 | 西安京迅递供应链科技有限公司 | Test data generation method, device, equipment and storage medium |
CN113778879A (en) * | 2021-09-13 | 2021-12-10 | 上海幻电信息科技有限公司 | Fuzzy test method and device for interface |
Also Published As
Publication number | Publication date |
---|---|
CN116662207A (en) | 2023-08-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Neudecker et al. | A simulation model for analysis of attacks on the bitcoin peer-to-peer network | |
CN111459766A (en) | A call chain tracking and analysis method for microservice system | |
US6446120B1 (en) | Configurable stresser for a web server | |
EP0871938B1 (en) | Response time measurement apparatus and method | |
CN110650128B (en) | A system and method for detecting Ethereum digital currency theft attack | |
Meng et al. | State monitoring in cloud datacenters | |
US8560684B2 (en) | Network transaction discovery | |
CN111782620A (en) | Credit link automatic tracking platform and method thereof | |
CN100353714C (en) | Method for realizing Web service automatic test | |
CN108563571A (en) | Software interface test approach and system, computer readable storage medium, terminal | |
US7891000B1 (en) | Methods and apparatus for monitoring and reporting network activity of applications on a group of host computers | |
CN114389792B (en) | WEB log NAT (network Address translation) front-back association method and system | |
CN107800565A (en) | Method for inspecting, device, system, computer equipment and storage medium | |
CN116662207B (en) | Fuzzy test method for block chain network | |
CN110009201A (en) | A power data link system and method based on blockchain technology | |
CN112632527A (en) | API (application programming interface) testing method and system for service open platform | |
Novotny et al. | On-demand discovery of software service dependencies in MANETs | |
CN109525645A (en) | A kind of method and system for collecting the log of distributed storage cluster | |
CN109299116A (en) | Data synchronization method, device, equipment and readable storage medium | |
Iurman et al. | Towards cross-layer telemetry | |
CN115664992A (en) | Network operation data processing method and device, electronic equipment and medium | |
CN112333174B (en) | Reflection-type DDos IP scanning detection system | |
US9400729B2 (en) | System and method for determining topology of monitored entities | |
CN114785526B (en) | Multi-user multi-batch weight distribution calculation and storage processing system based on block chain | |
CN118827393A (en) | eBPF-based application observation link topology construction method and related equipment |
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 |