Osiris

  1. 基于oyente的环境

  2. 升级支持Python3

  3. print()

  4. 删除z3文件夹(如果z3已安装)

  5. 安装HTMLParser

    pip install HTMLParser
    
  6. 安装HTMLParser

    pip install HTMLParser
    
  7. osiris.pyfrom HTMLParser import HTMLParser替换为from html.parser import HTMLParser

    disasm_out = disasm_p.communicate()[0]替换为disasm_out = disasm_p.communicate()[0].decode('utf-8', 'strict')

  8. utils.pyreturn solc_p.communicate()[0]替换为return solc_p.communicate()[0].decode('utf-8', 'strict')

    (int, long)替换为six.integer_types/int

    import six import logging 添加log = logging.getLogger(__name__)

  9. source_map.py

    def __get_source(self):
        fname = self.__get_filename()
        if SourceMap.sources.has_key(fname):
            return SourceMap.sources[fname]
        else:
            SourceMap.sources[fname] = Source(fname)
            return SourceMap.sources[fname]

    替换为

    def __get_source(self): # 两个_
        fname = self.__get_filename()
        if fname not in SourceMap.sources:
            SourceMap.sources[fname] = Source(fname)
        return SourceMap.sources[fname]
  10. ast_helper.pydef extract_state_definitions(self, c_name):插入base_contracts = list(base_contracts)

  11. symExec.pyfor (attr, default) in attr_defaults.iteritems():替换为for (attr, default) in six.iteritems(attr_defaults):,并且import six,

    if visited_edges.has_key(current_edge):替换为if current_edge in visited_edges:

    temp = long(math.ceil((mem_location + no_bytes) / float(32)))替换为

    if six.PY2:
        temp = long(math.ceil((mem_location + no_bytes) / float(32)))
    else:
        temp = int(math.ceil((mem_location + no_bytes) / float(32)))

    temp = long(math.ceil((address + 32) / float(32)))替换为

    if six.PY2:
        temp = long(math.ceil((address + 32) / float(32)))
    else:
        temp = int(math.ceil((address + 32) / float(32)))

    temp = long(math.ceil((stored_address + 32) / float(32)))替换为

    if six.PY2:
        temp = long(math.ceil((stored_address + 32) / float(32)))
    else:
        temp = int(math.ceil((stored_address + 32) / float(32)))

    temp = long(math.ceil((stored_address + 1) / float(32)))替换为

    if six.PY2:
        temp = long(math.ceil((stored_address + 1) / float(32)))
    else:
        temp = int(math.ceil((stored_address + 1) / float(32)))

    input += binascii.unhexlify('%064x' % value)替换为input += binascii.unhexlify('%064x' % value).decode('utf-8', 'strict')

    address += 1 + (len(instruction.split(' ')[1].replace("0x", "")) / 2)替换为address += 1 + (len(instruction.split(' ')[1].replace("0x", "")) // 2)

  12. basicblock.py(int, long)替换为six.integer_types, import six

  13. taintFlow.py中的所有取整/替换为//

  14. apt install graphviz pip install graphviz根据生成的.dot生成png流程图

======

An analysis tool to detect integer bugs in Ethereum smart contracts. Osiris is based on Oyente.

Quick Start

A container with the dependencies set up can be found here.

To open the container, install docker and run:

docker pull christoftorres/osiris && docker run -i -t christoftorres/osiris

To evaluate the SimpleDAO contract inside the container, run:

python osiris/osiris.py -s datasets/SimpleDAO/SimpleDAO_0.4.19.sol

and you are done!

Custom Docker image build

docker build -t osiris .
docker run -it osiris:latest

Full installation

Install the following dependencies

solc

$ sudo add-apt-repository ppa:ethereum/ethereum
$ sudo apt-get update
$ sudo apt-get install solc

evm from go-ethereum

  1. https://geth.ethereum.org/downloads/ or
  2. By from PPA if your using Ubuntu
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository -y ppa:ethereum/ethereum
$ sudo apt-get update
$ sudo apt-get install ethereum

z3 Theorem Prover version 4.6.0.

Download the source code of version z3-4.6.0

Install z3 using Python bindings

$ python scripts/mk_make.py --python
$ cd build
$ make
$ sudo make install

Requests library

pip install requests

web3 library

pip install web3

pysha3 library

pip install pysha3

Evaluating Ethereum Contracts

#evaluate a local solidity contract
python osiris.py -s <contract filename>

Run python osiris.py --help for a complete list of options.