Giter Club home page Giter Club logo

Comments (8)

muellerberndt avatar muellerberndt commented on May 18, 2024

It looks like there are invalid characters in the input. One thing that may cause this are address placeholders in the byte code (those look like ___[contract-name]_____________). Mythril should replace those automatically, but maybe something isn't working as it should.

Not sure if you want to provide the bytecode you're analyzing? If you can, it would make debugging this easier.

from mythril.

lsaether avatar lsaether commented on May 18, 2024

That would make a lot of sense if that's what is going on. I'm analyzing solidity code which makes heavy use of libraries so the compiler may not be linking those automatically when I run Mythril on them.

What I'll do is run the contracts through the compiler first and make sure everything is linked then run the bytecode through Mythril like you're suggesting.

from mythril.

muellerberndt avatar muellerberndt commented on May 18, 2024

Hi @lsaether, were you able to solve the problem?

from mythril.

muellerberndt avatar muellerberndt commented on May 18, 2024

Closing due to inactivity.

from mythril.

recontrapablo avatar recontrapablo commented on May 18, 2024

I stumbled the same issue trying out mythril 0.15.8 on Ubuntu. I was able to track it down to the fact that my contract is importing a second .sol that defines a library.

I created a gist with 2 simple .sol files that trigger the error when one line is un-commented: https://gist.github.com/pablorubinstein/8e6d04c1bd9222f9e8f2819f93ad70e2

When running myth -x contract.sol I get

ValueError: non-hexadecimal number found in fromhex() arg at position 242

being the offending value:

hex_decoded_string: '[...]b600073__lib.sol:MyLib_________________________63b1a[...]'

@b-mueller: oddily, I'm able to trigger the issue outside the contract constructor, but the same code works properly in the constructor itself...

from mythril.

muellerberndt avatar muellerberndt commented on May 18, 2024

oddily, I'm able to trigger the issue outside the contract constructor, but the same code works properly in the constructor itself...

This makes sense because the constructor code is not included in the runtime bytecode, and is therefore currently not analyzed (this will however change at some point).

I think at this point it doesn't make sense to implement support for ___-style linking. We're planning to implement a lightweight NodeJS version of Mythril for developers soon, which will be focused on supporting common development environments. The Solidity/Truffle support of the myth CLI was tacked on and doesn't work properly in many situations.

from mythril.

muellerberndt avatar muellerberndt commented on May 18, 2024

The crash is resolved in 0.17.0 by relaxing the regex for detecting solo-style placeholders. Note that these are currently simply replaced by an all-zeroes address, so the linked library is not included in the analysis.

from mythril.

p0n1 avatar p0n1 commented on May 18, 2024

Contract Code:

pragma solidity 0.4.24;

library Math {
    function add(uint256 a, uint256 b) public pure returns (uint256) {
        return a+b;
    }
}

contract Test {
    function add(uint256 a, uint256 b) public pure {
        Math.add(a, b);
    }
}

Bytecode:

======= lib-test.sol:Test =======
Binary:
608060405234801561001057600080fd5b5061015c806100206000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063771602f714610046575b600080fd5b34801561005257600080fd5b5061007b600480360381019080803590602001909291908035906020019092919050505061007d565b005b73__lib-test.sol:Math_____________________63771602f783836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018281526020019250505060206040518083038186803b1580156100f057600080fd5b505af4158015610104573d6000803e3d6000fd5b505050506040513d602081101561011a57600080fd5b81019080805190602001909291905050505050505600a165627a7a72305820d8d824b475836c42c695a914c4658820b06e1da85e762f7aac0a1a78752353000029

Panic Reson:

65b005b73__lib-test.sol:Math_____________________63771602f78383604

Panic Log:

Traceback (most recent call last):
  File "/Users/tam/Work/mythril_dev/mythril/myth", line 9, in <module>
    mythril.interfaces.cli.main()
  File "/Users/tam/Work/mythril_dev/mythril/mythril/interfaces/cli.py", line 177, in main
    address, _ = mythril.load_from_solidity(args.solidity_file)  # list of files
  File "/Users/tam/Work/mythril_dev/mythril/mythril/mythril.py", line 329, in load_from_solidity
    for contract in get_contracts_from_file(file, solc_args=self.solc_args):
  File "/Users/tam/Work/mythril_dev/mythril/mythril/ether/soliditycontract.py", line 36, in get_contracts_from_file
    yield SolidityContract(input_file, name, solc_args)
  File "/Users/tam/Work/mythril_dev/mythril/mythril/ether/soliditycontract.py", line 92, in __init__
    super().__init__(code, creation_code, name=name)
  File "/Users/tam/Work/mythril_dev/mythril/mythril/ether/ethcontract.py", line 24, in __init__
    self.creation_disassembly = Disassembly(creation_code, enable_online_lookup=enable_online_lookup)
  File "/Users/tam/Work/mythril_dev/mythril/mythril/disassembler/disassembly.py", line 9, in __init__
    self.instruction_list = asm.disassemble(util.safe_decode(code))
  File "/Users/tam/Work/mythril_dev/mythril/mythril/ether/util.py", line 16, in safe_decode
    return bytes.fromhex(hex_encoded_string)
ValueError: non-hexadecimal number found in fromhex() arg at position 318

from mythril.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.