Some problems and solutions encountered by Mythril in testing smart contracts

Since the author is doing experiments related to smart contracts recently, using the Mythril tool to detect smart contracts, and encountered a series of problems in the process of using it, here are some suggestions for everyone.

 

The classification of contract defects when Mythril detects smart contracts is as follows

SWC ID: 116----------Indicates the classification number of the vulnerability

Severity: Low----------Indicates the severity of the vulnerability

Contarct: Roulette----------indicates the name of the detected contract

Function name: fallback----------indicates the name of the function that found the vulnerability

PC address: 70----------indicates the program counter, the abbreviation of Program Counter 

1. The detection method of Mythril

Myhtril detects smart contracts in two forms, one is detected based on the source file .sol of the smart contract sample, and the other is detected through the address of the smart contract

1. According to .sol to detect

$ myth analyze <solidity-file>

2. Detection by address

$ myth analyze -a <contract-address> 

 After downloading Mythril through docker here, I found that it is possible to detect through the first case, but not through the second case. You may need to download Mythril through pip3 , but downloading Mythril with pip3 is very cumbersome and will cause a lot of installation package, the author finally gave up, you can try. If the download is successful, you can pass the statement:

myth --version

To detect whether mythril is successfully downloaded through pip3 (note: if it is downloaded through docker, it will show failure when checking the myth version here, but you can use the first method to detect the contract (very outrageous! Shocking!)) 

Another possibility is that you need to go through the wall, but the author tried it and it didn’t work. You can also try it

2. It is too slow to detect the contract speed through .sol

Here are some supplementary statements for detecting contracts through Mythril:

Usually detection statement:

sudo docker run -v $(pwd):/home/test mythril/myth analyze /home/test/test.sol

Supplementary statement:

sudo docker run -v $(pwd):/home/test mythril/myth analyze /home/test/test.sol --solv 0.4.25 --solver-timeout 60 --execution-timeout 60 -o text -t 3

in:

  • solv is the specified solidity compiled version
  • solver-timeout solidity version download timeout
  • execution-timeout, execution timeout
  • o output format, optional text/markdown/json/jsonv2
  • t number of transactions

When we use the first method, that is, the source file.sol method to detect, it may take 2-4 hours to get the result. At this time, we can use the execution-timeout method, for example:

 sudo docker run -v $(pwd):/home/test mythril/myth analyze --execution-timeout 60 /home/test/test.sol

Control the time within 60s.

In this way, the detection efficiency will be greatly improved.

3. The network is unstable 

When testing contracts, it is necessary to maintain a stable network environment. Network instability has a great impact on detection, and the following situations may occur.

47d3993a14e04adda4c2e93cf8dfbf5b.png

Guess you like

Origin blog.csdn.net/qq_45138078/article/details/127695308