https://github.com/alext234/rpc-sniffer
Capture and decode (Ethereum) JSON RPC traffic
https://github.com/alext234/rpc-sniffer
blockchain ethereum jsonrpc network python sniffing
Last synced: 3 months ago
JSON representation
Capture and decode (Ethereum) JSON RPC traffic
- Host: GitHub
- URL: https://github.com/alext234/rpc-sniffer
- Owner: alext234
- License: mit
- Created: 2018-03-22T20:03:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-26T09:49:52.000Z (about 8 years ago)
- Last Synced: 2025-12-16T15:23:21.345Z (6 months ago)
- Topics: blockchain, ethereum, jsonrpc, network, python, sniffing
- Language: Python
- Size: 26.4 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/alext234/rpc-sniffer)
# 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
```
(activate python virtualenv)
git clone https://github.com/alext234/rpc-sniffer
cd rpc-sniffer
python setup.py install
```
# Usage
A `pcap` file can be given as the parameter:
```
> rpc-sniffer.py tests/data/web3_clientVersion.pcap
INFO:root:Sniff network packets and decode JSONRPC on HTTP
id method params result
1 web3_clientVersion []
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):
```
> sudo su
> (activate python virtualenv)
> rpc-sniffer.py lo
```
You will able to see the decoded traffic when you interact with a local RPC node via web3, for example.
```
id method params result
1 eth_accounts []
1 eth_getTransactionCount ['0x70974f6673fa922eac3c2cd433d762e93db9399e', 'latest']
1 0x30
1 net_version []
1 99
1 eth_gasPrice []
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).