项目作者: alext234

项目描述 :
Capture and decode (Ethereum) JSON RPC traffic
高级语言: Python
项目地址: git://github.com/alext234/rpc-sniffer.git
创建时间: 2018-03-22T20:03:29Z
项目社区:https://github.com/alext234/rpc-sniffer

开源协议:MIT License

下载


Build Status

rpc-sniffer

This tool captures network traffic and decode them if they contain (Ethereum) JSON RPC.
This might be useful in the following scenarios:

  • You want to know the exact RPC requests and responses sent to and from your Ethereum node.
  • You want to debug and understand what web3 sends out.
  • You want to capture the contents web3 sends out in order to use them in a different program.

Installation

The following assumes you already have Python virtualenv activated.
If not you may need to add sudo in front of the setup.py command.

  • Via the setup.py script
  1. (activate python virtualenv)
  2. git clone https://github.com/alext234/rpc-sniffer
  3. cd rpc-sniffer
  4. python setup.py install

Usage

A pcap file can be given as the parameter:

  1. > rpc-sniffer.py tests/data/web3_clientVersion.pcap
  2. INFO:root:Sniff network packets and decode JSONRPC on HTTP
  3. id method params result
  4. 1 web3_clientVersion []
  5. 1 Geth/v1.8.2-stable/linux-amd64/go1.9.2

Or a network interface can be given, for example with the local loopback interface lo (superuser is needed):

  1. > sudo su
  2. > (activate python virtualenv)
  3. > rpc-sniffer.py lo

You will able to see the decoded traffic when you interact with a local RPC node via web3, for example.

  1. id method params result
  2. 1 eth_accounts []
  3. 1 eth_getTransactionCount ['0x70974f6673fa922eac3c2cd433d762e93db9399e', 'latest']
  4. 1 0x30
  5. 1 net_version []
  6. 1 99
  7. 1 eth_gasPrice []
  8. 1 0x430e23400

Limitations

  • This tool does not support encrypted SSL traffic (e.g. when you interact with an infura.io node).

  • This tool does not support RPC traffic that spans multiple packets (development is in progress for this feature).