Skip to content

Instantly share code, notes, and snippets.

@st3b1t
Last active June 15, 2023 20:14
Show Gist options
  • Save st3b1t/36c11896e6389344b42ecf1afe616cf1 to your computer and use it in GitHub Desktop.
Save st3b1t/36c11896e6389344b42ecf1afe616cf1 to your computer and use it in GitHub Desktop.
Bitcoin node info without RPC access
#!/usr/bin/env python3
#
# don't require rpc auth.
#
# requirements:
# sudo apt-get install libssl-dev
# pip install python-bitcoinlib
# docs:
# https://github.com/petertodd/python-bitcoinlib
# usage:
# ./bitcoin_node_info.py <hostname>
import os, sys, socket, json
from bitcoin.messages import msg_version
server_ip = sys.argv[1]
server_port = 8333
s = socket.socket()
s.connect( (server_ip, server_port) )
msg = msg_version()
s.send( msg.to_bytes() )
ret = msg_version.from_bytes(s.recv(1924))
s.close()
listret = str(ret).split()
# print(ret)
# print(listret)
print(json.dumps(listret, indent = 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment