Last active
June 15, 2023 20:14
-
-
Save st3b1t/36c11896e6389344b42ecf1afe616cf1 to your computer and use it in GitHub Desktop.
Bitcoin node info without RPC access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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