Method for tracing path of attack on smart contract on blockchain
View Patent ↗The present disclosure provides a method for tracing a path of an attack on a smart contract on a blockchain, belonging to the technical field of blockchains. The method specifically includes: determining a hacker's attack address, and determining an attack's start time and an attack's stop time according to a data record of the hacker's attack address; and determining hash values of all transactions from a hacker's attack destination address between the attack's start time and the attack's stop time automatically, and obtaining a fungible token and a non-fungible token by parsing the hash values automatically. The problems of large error and low efficiency during original manual extraction are solved, accuracy and efficiency are higher, and the overall security is improved.
1 . A method for tracing a path of an attack on a smart contract on a blockchain, the method comprising:
S1: determining a hacker's attack address, and determining an attack's start time and an attack's stop time according to a data record of the hacker's attack address; and
S2: determining hash values of all transactions from a hacker's attack destination address between the attack's start time and the attack's stop time automatically, and obtaining a fungible token and a non-fungible token by parsing the hash values automatically, wherein the hash values of all the transactions from the hacker's attack destination address are queried according to the following steps:
S21, querying hash values of all transactions from the hacker's attack address between the attack's start time and the attack's stop time;
S22, obtaining the hacker's attack destination address by parsing the hash values of the transactions from the hacker's attack address, and recording all transaction records of the hacker's attack destination address; and
S23, reading all the transaction records of the hacker's attack destination address and the hacker's attack destination address value corresponding to the hacker's attack destination address, and querying and storing the hash values of all the transactions initiated by the hacker's attack address and taking the hacker's attack destination address as an attack target between the attack's start time and the attack's stop time.
2 . The method for tracing a path of an attack on a smart contract on a blockchain according to claim 1 , wherein the hash values of all the transactions from the hacker's attack address between the attack's start time and the attack's stop time are queried through a Web3 Application Programming Interface (API).
3 . The method for tracing a path of an attack on a smart contract on a blockchain according to claim 1 , wherein the hacker's attack address is determined by reading a character string beginning with a symbol “0x” on the blockchain.
4 . The method for tracing a path of an attack on a smart contract on a blockchain according to claim 1 , wherein the hacker's attack destination address is determined according to a transaction address label value of the hacker's attack destination address.
5 . The method for tracing a path of an attack on a smart contract on a blockchain according to claim 1 , wherein the hash values are parsed automatically to obtain an event “Internal Transactions” and an event “Tokens Transferred”.
6 . The method for tracing a path of an attack on a smart contract on a blockchain according to claim 5 , wherein the event “Internal Transactions” is parsed by querying at least one of a keyword “Transfer”, a keyword “send” and a keyword “call”, to obtain a transferred-out token.
7 . The method for tracing a path of an attack on a smart contract on a blockchain according to claim 5 , wherein the event “Tokens Transferred” is parsed by querying at least one of a keyword “Transfer”, a keyword “send” and a keyword “call”, to obtain a transferred-out fungible token and a transferred-out non-fungible token.
8 . A non-transitory computer-readable storage medium, storing a computer program, wherein when the computer program is executed in a computer, the computer executes the method for tracing a path of an attack on a smart contract on a blockchain according to claim 1 .
9 . The non-transitory computer-readable storage medium according to claim 8 , wherein the hash values of all the transactions from the hacker's attack address between the attack's start time and the attack's stop time are queried through a Web3 Application Programming Interface (API).
10 . The non-transitory computer-readable storage medium according to claim 8 , wherein the hacker's attack address is determined by reading a character string beginning with a symbol “0x” on the blockchain.
11 . The non-transitory computer-readable storage medium according to claim 8 , wherein the hacker's attack destination address is determined according to a transaction address label value of the hacker's attack destination address.
12 . The non-transitory computer-readable storage medium according to claim 8 , wherein the hash values are parsed automatically to obtain an event “Internal Transactions” and an event “Tokens Transferred”.
13 . The non-transitory computer-readable storage medium according to claim 12 , wherein the event “Internal Transactions” is parsed by querying at least one of a keyword “Transfer”, a keyword “send” and a keyword “call”, to obtain a transferred-out token.
14 . The non-transitory computer-readable storage medium according to claim 12 , wherein the event “Tokens Transferred” is parsed by querying at least one of a keyword “Transfer”, a keyword “send” and a keyword “call”, to obtain a transferred-out fungible token and a transferred-out non-fungible token.