crytic / ethersplay

EVM dissassembler
GNU Affero General Public License v3.0
845 stars 118 forks source link

Function names are not recovered from bytecode for solidity 0.5.4 #47

Open wTendera opened 5 years ago

wTendera commented 5 years ago

As in issue title I could not recover the function names of smart contracts written in Solidity 0.5.4 First I tried with my own complex smart contracts, but in all cases only one 'function' - 0x40 was recognised even if smart contract had multiple functions.

I went for a simpler contract

contract SimpleStore {
  function set(uint _value) public {
    value = _value;
  }

  function get() public view returns (uint) {
    return value;
  }
  uint value;
}

Bytecode:

608060405234801561001057600080fd5b5060da8061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610604f576000357c01000000000000000000000000000000000000000000000000000000009004806360fe47b11460545780636d4ce63c14607f575b600080fd5b607d60048036036020811015606857600080fd5b8101908080359060200190929190505050609b565b005b608560a5565b6040518082815260200191505060405180910390f35b8060008190555050565b6000805490509056fea165627a7a72305820f8a3447634c2d8fdcd7d04231ce39c3b2399b50b0f60889ca4c53d57fb0cf2b40029

And the result was the same - functions set and get were not recognised.

Screenshot 2019-03-15 at 14 58 44 Screenshot 2019-03-15 at 14 58 36

I'm operating on OSX version of binary ninja.

montyly commented 5 years ago

Thank you for reporting the issue! We are going to look at it

joshwatson commented 5 years ago

First issue is that you are providing the constructor to Ethersplay, so that's what you're seeing as the function named 0x40. Per the README, you should run solc --bin-runtime file.sol to output just the runtime bytecode if that's what you want to look at in Ethersplay.

The second issue is actually an issue with evm_cfg_builder, which Ethersplay gets its CFG info from, so we should probably open a ticket on that repo.