Alliance chain replay attack testing method, device, electronic device and storage medium
By deploying test programs in the alliance chain network and replaying transactions and detecting transaction hash values, the problem of inability to test alliance chain security in the existing technology is solved, and the replay attack detection and protection of the alliance chain network is realized.
Patent Information
- Application Number
- CN202111323148.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-05
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2041-11-05
AI Technical Summary
There is a lack of a method for replay attack testing of alliance chains in the prior art, and it is impossible to detect and evaluate whether the alliance chain network is affected by replay attacks, resulting in the inability to effectively resist attacks initiated by malicious nodes or compromised organizations.
Build a test program, deploy it to the alliance chain network as a test server node, send transaction requests through the client, record transaction hash values, and replay transactions in the alliance chain network, query historical transaction hash values to generate test results , determine whether the alliance chain is affected by the replay attack.
A replay attack test on the alliance chain network is implemented to detect whether it is affected by the replay attack and its degree of harm, and to provide protective measures to resist malicious behavior.
Smart Images

Figure CN114064470B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a testing method, device, electronic device and storage medium for alliance chain replay attacks. Background Art
[0002] Blockchain technology (also known as distributed ledger technology) is a decentralized distributed database technology with the characteristics of openness, transparency, immutability, and trustworthiness. It is suitable for many application scenarios such as data tracing, information sharing, and information anti-counterfeiting. With the development of Internet technology, more and more security issues are constantly arising. Replay attacks are currently a common means of attack. In the actual operation of the blockchain network, replay attacks may occur. The so-called replay attack on the blockchain network refers to a node that resubmits a transaction that has already been submitted due to malicious intent or technical failure, causing the blockchain network to repeat the same transaction, wasting the computing power of the blockchain network and possibly causing other losses. Therefore, the replay test technology is of great significance to the protection of individuals or enterprises.
[0003] The alliance chain is a semi-centralized system deployed across organizations. Multiple organizations within the alliance chain share a shared ledger. It is necessary to consider the possibility of malicious organization nodes joining or an organization being compromised, and resist attacks launched by internal nodes. However, in the existing technology, there is no method to test the alliance chain for replay attacks, and it is impossible to test whether the security of the alliance chain itself is affected by replay attacks. Summary of the invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present invention provides a testing method, device, electronic device and storage medium for alliance chain replay attacks.
[0005] In a first aspect, the present invention provides a testing method for a consortium chain replay attack, the testing method for a consortium chain replay attack comprising: constructing a test program, and deploying the test program to the consortium chain network as a test server node; sending a transaction request to the test server node through a client to generate a transaction, and recording the transaction hash value generated by the transaction; sending the transaction data generated by the transaction to other nodes through the test server node, and replaying the transaction; querying historical transactions in the consortium chain network, and checking all transaction hash values after replaying the transaction to generate a test result; and determining whether the consortium chain network is affected by the replay attack based on the test result.
[0006] Optionally, the building of the test program includes: analyzing the source code of the alliance chain, obtaining the transaction communication code of the alliance chain transaction node, the transaction node of the alliance chain includes one of the following: a network node for maintaining the ledger, a network node for providing consensus services; modifying the transaction data communication code, the modified transaction data communication code is used to replay the transaction a specified number of times; compiling the modified transaction data communication code to obtain the test program.
[0007] Optionally, when the acquired transaction communication code is the code of a network node for maintaining an account book, deploying the test program into the alliance chain network to become a test server node includes: deploying the test program into the alliance chain network as a network node for maintaining an account book to form the test server node; or when the acquired transaction communication code is the code of a network node for providing consensus services, deploying the test program into the alliance chain network to become a test server node includes: deploying the test program into the alliance chain network as a network node for providing consensus services to form the test server node.
[0008] Optionally, sending the transaction data generated by the transaction to other nodes through the test server node, and replaying the transaction includes: when the test server node is a network node that maintains the ledger, sending the transaction data generated by the transaction to other network nodes that maintain the ledger through the test server node, and replaying the transaction through the test server node; or when the test server node is a network node that provides consensus services, sending the transaction data generated by the transaction to the network node that maintains the ledger and other network nodes that provide consensus services through the test server node, and replaying the transaction through the test server node.
[0009] Optionally, the checking of all transaction hash values after replaying the transaction to generate a test result includes: checking whether there are multiple transaction hash values generated by the transaction in the alliance chain; if so, generating a record of multiple identical transaction hash values as the test result.
[0010] Optionally, determining whether the alliance chain network is affected by a replay attack based on the test result includes: when only one transaction among the transactions in the test result has the aforementioned hash value, determining that the alliance chain network is not affected by the replay attack; or when multiple transactions among the transactions in the test result have the aforementioned hash value, determining that the alliance chain network is affected by a replay attack.
[0011] Optionally, after determining whether the alliance chain network is affected by a replay attack according to the test results, the method further includes: generating an alarm prompt when it is determined that the alliance chain network is affected by a replay attack.
[0012] In a second aspect, the present invention provides a testing device for a consortium chain replay attack, the testing device for a consortium chain replay attack comprising: a program construction module, used to construct a test program, and deploy the test program to the consortium chain network as a test server node; a transaction request module, used to send a transaction request to the test server node through a client to generate a transaction, and record the transaction hash value returned by the test server node to the client; a replay module, used to send the transaction data generated by the transaction to other nodes through the test server node, and replay the transaction; a check module, used to query historical transactions in the consortium chain network, and check all transaction hash values after replaying the transaction to generate a test result; a judgment module, which determines whether the consortium chain network is affected by the replay attack based on the test result.
[0013] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0014] Memory, used to store computer programs;
[0015] The processor is used to implement the steps of the alliance chain replay attack testing method described in any embodiment of the first aspect when executing the program stored in the memory.
[0016] In a fourth aspect, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for testing the consortium chain replay attack as described in any embodiment of the first aspect are implemented.
[0017] The above technical solution provided by the embodiment of the present invention has the following advantages compared with the prior art:
[0018] The method provided by the embodiment of the present invention constructs a test program and deploys the test program to the alliance chain network as a test server node; sends a transaction request to the test server node through a client to generate a transaction, and records the transaction hash value generated by the transaction; sends the transaction data generated by the transaction to other nodes through the test server node, and replays the transaction; queries historical transactions in the alliance chain network, and checks all transaction hash values after replaying the transaction to generate a test result; determines whether the alliance chain network is affected by the replay attack based on the test result, thereby realizing a replay attack test on the encrypted transaction communication of the alliance chain network, and further detecting whether the alliance chain network is affected by the replay attack and the degree of damage. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0020] In order to more clearly illustrate the embodiments of the present invention 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.
[0021] Figure 1 A basic flow chart of a test method for a consortium chain replay attack provided by an embodiment of the present invention;
[0022] Figure 2 A basic structural diagram of a test device for alliance chain replay attack provided by an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] Figure 1 A flowchart of a test method for a consortium chain replay attack provided by an embodiment of the present invention includes but is not limited to:
[0026] S101, build a test program, and deploy the test program to the alliance chain network to become a test server node;
[0027] S102, sending a transaction request to the test server node through the client to generate a transaction, and recording the transaction hash value generated by the transaction;
[0028] S103, sending the transaction data generated by the transaction to other nodes through the test server node, and replaying the transaction;
[0029] S104, querying historical transactions in the alliance chain network, and checking all transaction hash values after replaying the transaction to generate a test result;
[0030] S105. Determine whether the alliance chain network is affected by a replay attack based on the test result.
[0031] It is important to understand that the consortium chain is decentralized and information is encrypted. Taking the Hyperledger fabric consortium chain as an example, the fabric network is composed of multiple nodes from multiple organizations. The multiple organizations in the fabric network share transaction ledgers. Therefore, it is necessary to guard against the possibility of malicious organization nodes joining, or if an organization is compromised, the attacker will send the transaction data of the node to other nodes for replay, causing various security issues.
[0032] In some examples of this embodiment, the building of the test program includes: analyzing the source code of the alliance chain, obtaining the transaction communication code of the alliance chain transaction node, the transaction node of the alliance chain includes one of the following: a network node that maintains the ledger, a network node that provides consensus services; modifying the transaction data communication code, and the modified transaction data communication code is used to replay the transaction a specified number of times; compiling the modified transaction data communication code to obtain the test program. It should be understood that, taking the fabric consortium chain as an example, this embodiment first needs to obtain the technical source code of the consortium chain, and obtain the transaction communication code of the network node peer that maintains the ledger and the network node orderer node that provides consensus services in the Fabric system through code analysis. Specifically, the transaction communication code of the consortium chain transaction node includes but is not limited to: transaction synchronization code between orderer nodes, orderer node sending transaction code to peer node, and main peer node synchronizing transaction code to other peer nodes; analyzing the source code of the consortium chain, obtaining the transaction communication code of the consortium chain transaction node includes but is not limited to: analyzing the source code of the consortium chain, obtaining the code location where the consortium chain system server sends transaction data, and then obtaining the transaction communication code of the consortium chain transaction node, and then compiling it as a test program, that is, the test program includes: orderer program and / or peer program.
[0033] Continuing with the above example, when the acquired transaction communication code is the code of a network node for maintaining an account book, the deploying of the test program into the alliance chain network to become a test server node includes: deploying the test program into the alliance chain network as a network node for maintaining an account book to form the test server node; or when the acquired transaction communication code is the code of a network node for providing consensus services, the deploying of the test program into the alliance chain network to become a test server node includes: deploying the test program into the alliance chain network as a network node for providing consensus services to form the test server node; taking the fabric alliance chain as an example, the above-mentioned test program (orderer program and / or peer program) is deployed in the existing fabric alliance chain network.
[0034] In some examples of this embodiment, a transaction request is sent to a test server node through a client to generate a transaction, and a transaction hash value generated by the transaction is recorded. Then, the transaction data generated by the transaction is sent to other nodes through the test server node, and the transaction is replayed;
[0035] Continuing with the above example, sending the transaction data generated by the transaction to other nodes through the test server node and replaying the transaction includes: when the test server node is a network node that maintains the ledger, sending the transaction data generated by the transaction to other network nodes that maintain the ledger through the test server node, and replaying the transaction through the test server node; or when the test server node is a network node that provides consensus services, sending the transaction data generated by the transaction to the network node that maintains the ledger and other network nodes that provide consensus services through the test server node, and replaying the transaction through the test server node; that is, after receiving the transaction, the test program of the test server node will send the transaction data to other nodes and replay the above transaction.
[0036] In some examples of this embodiment, historical transactions are queried in the alliance chain network, and all transaction hash values after replaying the transaction are checked to generate a test result; the checking of all transaction hash values after replaying the transaction to generate a test result includes: checking whether there are multiple transaction hash values generated by the transaction in the alliance chain; if so, generating a record of multiple identical transaction hash values as the test result. If not, generating a record of multiple identical transaction hash values as the test result; it should be understood that when the test server node replays the transaction in the alliance chain network, if the alliance chain is affected by a replay attack, multiple identical transaction hash values will be generated for the transaction; when the test server node replays the transaction in the alliance chain network, if the alliance chain is not affected by a replay attack, multiple identical transaction hash values will not be generated for the transaction. Therefore, it is possible to determine whether the alliance chain network has been affected by a replay attack by querying the historical transactions of the transaction and the transaction hash value corresponding to the transaction.
[0037] Continuing with the above example, in some examples, determining whether the alliance chain network is affected by the replay attack based on the test results includes: when only one of the transactions in the test results has the hash value, determining that the alliance chain network is not affected by the replay attack; or, when multiple transactions in the test results have the hash value, determining that the alliance chain network is affected by the replay attack; that is, when the transaction has only one corresponding transaction, it proves that the alliance chain is not affected when the transaction is replayed, and therefore no other transactions are generated; when the transaction corresponds to multiple transactions, it means that the alliance chain is affected by the replay attack. Specifically, when the transaction corresponds to multiple transactions and the results of each transaction are displayed as successful, it is determined that the alliance chain network is completely affected by the replay attack; when the transaction corresponds to multiple transactions and the results of the hash values of each transaction are one successful and multiple failed, it is determined that the alliance chain network is partially affected by the replay attack.
[0038] In some examples of this embodiment, after determining whether the alliance chain network is affected by a replay attack based on the test results, the method further includes: when it is determined that the alliance chain network is affected by a replay attack, generating an alarm prompt to prompt relevant personnel that the alliance chain network is affected by a replay attack.
[0039] The test method for alliance chain replay attack provided in this embodiment builds a test program and deploys the test program to the alliance chain network as a test server node; sends a transaction request to the test server node through the client to generate a transaction, and records the transaction hash value returned by the test server node to the client; sends the transaction data generated by the transaction to other nodes through the test server node, and replays the transaction; queries historical transactions in the alliance chain network, and checks all transaction hash values after replaying the transaction to generate a test result; determines whether the alliance chain network is affected by the replay attack based on the test result, realizes the effect of replay attack test on the encrypted transaction communication of the alliance chain network, and then detects whether the alliance chain network is affected by the replay attack and the degree of damage.
[0040] This embodiment also provides a test device for alliance chain replay attack, such as Figure 2 As shown, the test device for the alliance chain replay attack includes:
[0041] Program construction module 1, used to build a test program and deploy the test program to the alliance chain network to become a test server node;
[0042] Transaction request module 2, used to send a transaction request to the test server node through the client to generate a transaction, and record the transaction hash value generated by the transaction;
[0043] Replay module 3, used to send the transaction data generated by the transaction to other nodes through the test server node, and replay the transaction;
[0044] The checking module 4 is used to query historical transactions in the alliance chain network and check all transaction hash values after replaying the transaction to generate a test result;
[0045] The judgment module 5 determines whether the alliance chain network is affected by the replay attack according to the test result.
[0046] like Figure 3As shown, an embodiment of the present invention provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0047] Memory 113, used for storing computer programs;
[0048] In one embodiment of the present invention, the processor 111 is used to execute the program stored in the memory 113 to implement the test method for the alliance chain replay attack provided by any of the aforementioned method embodiments, including: building a test program and deploying the test program to the alliance chain network as a test server node; sending a transaction request to the test server node through a client to generate a transaction, and recording the transaction hash value generated by the transaction; sending the transaction data generated by the transaction to other nodes through the test server node, and replaying the transaction; querying historical transactions in the alliance chain network, and checking all transaction hash values after replaying the transaction to generate a test result; determining whether the alliance chain network is affected by the replay attack based on the test result.
[0049] An embodiment of the present invention also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the testing method for consortium chain replay attack provided in any of the aforementioned method embodiments are implemented.
[0050] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0051] The above description is only a specific embodiment of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but should conform to the widest scope consistent with the principles and novel features invented herein.
Claims
1. A test method for alliance chain replay attack, It is characterized in that The test method for the consortium chain replay attack includes: Build a test program and deploy the test program to the alliance chain network to become a test server node; Sending a transaction request to the test server node through the client to generate a transaction, and recording the transaction hash value generated by the transaction; Sending the transaction data generated by the transaction to other nodes through the test server node, and replaying the transaction; Query historical transactions in the consortium chain network, and check all transaction hash values after replaying the transactions to generate test results; Determine whether the alliance chain network is affected by the replay attack based on the test results.
2. The method according to claim 1, It is characterized in that The construction test program includes: Analyze the source code of the alliance chain to obtain the transaction communication code of the alliance chain transaction node, where the alliance chain transaction node includes one of the following: a network node that maintains the ledger and a network node that provides consensus services; Modifying the transaction data communication code, wherein the modified transaction data communication code is used to replay the transaction a specified number of times; The modified transaction data communication code is compiled to obtain the test program.
3. The method according to claim 2, It is characterized in that When the acquired transaction communication code is a code of a network node for maintaining a ledger, deploying the test program into the alliance chain network to become a test server node includes: deploying the test program as a network node for maintaining a ledger into the alliance chain network to form the test server node; or When the acquired transaction communication code is the code of a network node providing consensus services, deploying the test program into the alliance chain network to become a test server node includes: deploying the test program into the alliance chain network as a network node providing consensus services to form the test server node.
4. The method according to claim 3, It is characterized in that Sending the transaction data generated by the transaction to other nodes through the test server node, and replaying the transaction includes: When the test server node is a network node that maintains the ledger, the transaction data generated by the transaction is sent through the test server node to other network nodes that maintain the ledger, and the transaction is replayed through the test server node; or When the test server node is a network node that provides consensus services, the transaction data generated by the transaction is sent to the network node that maintains the ledger and other network nodes that provide consensus services through the test server node, and the transaction is replayed through the test server node.
5. The method according to claim 4, It is characterized in that The checking of all transaction hash values after replaying the transaction to generate a test result includes: Checking whether there are multiple transaction hash values generated by the transaction in the alliance chain; If so, a record of multiple identical transaction hash values is generated as the test result.
6. The method according to claim 5, It is characterized in that Determining whether the alliance chain network is affected by a replay attack according to the test results includes: When the test result is that only one of the transactions has the hash value, it is determined that the consortium chain network is not affected by the replay attack; or, When the test result shows that there are multiple transactions with the hash value, it is determined that the alliance chain network is affected by a replay attack.
7. The method according to claim 6, It is characterized in that After determining whether the alliance chain network is affected by a replay attack according to the test result, the method further includes: When it is determined that the alliance chain network is affected by a replay attack, an alarm prompt is generated.
8. A test device for alliance chain replay attack, It is characterized in that The test device for the alliance chain replay attack includes: A program construction module is used to build a test program and deploy the test program to the alliance chain network to become a test server node; A transaction request module, used to send a transaction request to the test server node through a client to generate a transaction, and record a transaction hash value generated by the transaction; A replay module, used to send the transaction data generated by the transaction to other nodes through the test server node, and replay the transaction; A checking module, used to query historical transactions in the alliance chain network and check all transaction hash values after replaying the transaction to generate a test result; The judgment module determines whether the alliance chain network is affected by the replay attack according to the test result.
9. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor is used to implement the steps of the alliance chain replay attack testing method described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by the processor, the steps of the method for testing the consortium chain replay attack as described in any one of claims 1 to 7 are implemented.
