EtherSolve

EtherSolve is a tool for the control-flow graph extraction from Ethereum bytecode. It analyses smart contracts generated by Solidity. This package provides the executable JAR and the data used for the experimental validation.

TOC

Usage

To run the tool please use the provided JAR

java -jar EtherSolve.jar --help

Usage: ethersolve [-hV] [--re-entrancy] [-o=<outputFilename>] (-c | -r) (-j |
                  -H | -s | -d) <source>
EtherSolve, build an accurate CFG from Ethereum bytecode
      <source>        Bytecode string or file containing it
  -c, --creation      Parse bytecode as creation code
  -d, --dot           Export a dot-notation file
  -h, --help          Show this help message and exit.
  -H, --html          Export a graphic HTML report. Graphviz is required!
  -j, --json          Export a Json report
  -o, --output=<outputFilename>
                      Output file
  -r, --runtime       Parse bytecode as runtime code
      --re-entrancy   Execute re-entrancy detector and save output
  -s, --svg           Export a graphic SVG image. Graphviz is required!
  -V, --version       Print version information and exit.

The source can be both the bytecode or a path to a file containing it. Specify if the bytecode is creation code or runtime code, and the desired output type.

The tool has been tested on Linux x64 with Java 11.0.8. To produce a graphical output (Html or Svg) Graphviz is required.

To run the re-entrancy validator add the --re-entrancy option. The tool will create a CSV file containing the detections and their location in the code. Note that the re-entrancy corresponds to a "Store write after unsafe call".

Examples

To analise the smart contracts in the Example folder the comands can be the following:

java -jar EtherSolve.jar -c -H Examples/example_1_simple_creation.evm

java -jar EtherSolve.jar -c -j -o report.json Examples/example_2_ballot_creation.evm

java -jar EtherSolve.jar -r -H -o index.html Examples/example_3_dataset-sample_runtime.evm

java -jar EtherSolve.jar -c -H -o index.html Examples/example_4_re-entrancy-sample_creation.evm --re-entrancy

Dataset

The file dataset.csv contains the list of the smart contracts used in the experimental validation with additional information. The data used for the tool comparison and the re-entrancy validation are in the benchmark folder. Its structure is depicted in the following.

Bytecode-dataset-1000-contracts

This folder contains the bytecode on the 1000 smart contracts downloaded from EtherScan and used in the comparison. They are all runtime bytecode, directly taken from the blockchain.

Output-tools

This folder contains the results of the execution of the different tools on the dataset. For each tool there are 2 folders which contain the raw output given by the tool and our conversion in the intermediate representation used in the comparison. If the tool failed in producing an output, the intermediate representation is an empty CFG.

Moreover there is a spreadsheet that sums up the results. For each element of the dataset it is reported:

  • contract name
  • contract address
  • bytecode hash
  • licence
  • deployment date
  • Solidity version
  • evm version
  • number of transactions
  • balance (expressed in Wei)
  • bytecode length
  • computed Solidity version (By Ethersolve)
  • Candidate tool success (0 for fail, 1 for success)
  • EtherSolve success
  • Candidate execution time (ms)
  • EtherSolve execution time (ms)
  • Number of candidate nodes
  • Number of EtherSolve nodes
  • {CandidateNodes \ EtherSolveNodes} (set difference)
  • {EtherSolveNodes \ EtherSolveNodes}
  • EtherSolve Highest offset
  • Number of candidate nodes over EtherSolve Highest offset
  • Number of candidate edges
  • Number of EtherSolve edges
  • {CandidateEdges \ EtherSolveEdges} (set difference)
  • {EtherSolveEdges \ EtherSolveEdges}

Manual-inspection

This folder contains the smart contracts used in the manual inspection phase, with the raw output from the candidate tool, the HTML report from EtherSolve and the diffGraph. The diff graph uses this color schema:

  • Blue: Elements belonging only to the candidate CFG.
  • Red: Elements belonging only to EtherSolve CFG.
  • Black: Elements shared between the two CFGs.

Re-entrancy-results

This folder contains the smart contracts analyzed in the re-entrancy detector validation and a spreadsheet that sums up the results. There are the bytecodes of the smart contracts before and after the infection. The "all_*" folders contain all the bytecodes generated by the source file. The other ones only the biggest bytecode for each source file.

The "snippets" folder contains the snippets used by SolidiFI for the injection. The complete dataset used by SolidiFI can be found here.

The Spreadsheet contains two pages. The first one is a table with the results of each tool on each sample, with the number of injection, EtherSolve detection (pre and post injection) and the detections of the other tools. The second one is a graphical comparison of EtherSolve and Slither with the SolidiFI injections.