Comments (8)
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.
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.
Hi @lsaether, were you able to solve the problem?
from mythril.
Closing due to inactivity.
from mythril.
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.
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.
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.
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)
- mythril install with last web3=6 HOT 2
- Can't run analysis using Docker on M1 Mac HOT 2
- `AttributeError: 'NoneType' object has no attribute 'get'` in `mythril/solidity/features.py` HOT 7
- An incorrect warning result
- Mythril analyze returning AttributeError HOT 2
- How to run custom plugin along with mythril? HOT 1
- Mythril cannot identify imported openzeppelin contracts in foundry project. HOT 5
- DeclarationError: Identifier already declared. HOT 8
- Does mythril have the following features HOT 4
- Mythril 0.24.4 raises an error on macOS HOT 2
- Inconsistency in the results of function seqeunce execution HOT 23
- Mythril is producing one liner success report without details. HOT 1
- External call does not change the storage of the callee contract.
- Solc experienced a fatal error while running myth on a Foundry-based project importing an OpenZeppelin library HOT 2
- Unchecked return value not flagged
- Missing support for transient storage opcodes HOT 1
- Mythril is very slow HOT 1
- Inconsistent results source vs bytecode HOT 3
- Misspelled Rootstock in the repository's about section
- Incoherent overflow detection HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mythril.