Esempio n. 1
0
def get_client():
    global client
    if client is not None:
        return client
    conn = mcrpc.RpcClient(NODE_IP, NODE_PORT, NODE_USER, NODE_PWD)
    try:
        info = conn.getblockchaininfo()
        logger.debug("Connected to {}".format(info))
        client = conn
        return conn
    except Exception as e:
        logger.warning("No connection to blockchain node: {}".format(e))
        return None
Esempio n. 2
0
def _verify(key):

    #client = mcrpc.RpcClient('159.89.226.46', '2778', 'multichainrpc', '5NVcmBy6YYHTj95XFp6ZrELdApxusaKrAtCxKs1K86Gc')
    client = mcrpc.RpcClient(settings.MULTICHAIN_IP, settings.MULTICHAIN_PORT,
                             settings.MULTICHAIN_RPCUSER,
                             settings.MULTICHAIN_RPCPASSWORD)

    tx_data = client.liststreamkeyitems('POACERT', key)[0]
    meta_data = tx_data['data']
    student_base64 = codecs.decode(meta_data, 'hex')
    student_json = json.loads(base64.b64decode(student_base64).decode())
    student_json['confirmations'] = tx_data['confirmations']
    if 'blocktime' in tx_data:
        student_json['blocktime'] = tx_data['blocktime']
    student_json['txid'] = tx_data['txid']
    student_json['key'] = tx_data['key']
    return student_json
Esempio n. 3
0
import time
import subprocess
import select
import mcrpc
import socket

f = subprocess.Popen(['tail','-F','/var/log/snort/alert'],\
        stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p = select.poll()
p.register(f.stdout)
client = mcrpc.RpcClient('127.0.0.1', '6736', 'test', 'test')
info = client.getinfo()
stream = "snort"
print(info)
hostname = socket.gethostname()
ipAddress = socket.gethostbyname(hostname)
print(hostname)
#client.create("stream", stream, True)
while True:
    if p.poll(1):
        s = f.stdout.readline()
        txid = client.publish(stream, hostname, {"text": s})
        client.subscribe(stream)
        resp = client.getstreamitem(stream, txid)
        s = resp["data"]["text"]
        print(s)
Esempio n. 4
0
fire_base_config = {
    'apiKey': "AIzaSyCOjJy7knbfdS5S5mVrM5XI0A-smuAWD1s",
    'authDomain': "test-ac807.firebaseapp.com",
    'databaseURL': "https://test-ac807.firebaseio.com",
    'projectId': "test-ac807",
    'storageBucket': "test-ac807.appspot.com",
    'messagingSenderId': "45638555993",
    'appId': "1:45638555993:web:bf01701c47d4881e721448",
    'measurementId': "G-BCVXJTSVYV"
}  # configuration of firebase database
firebase = pyrebase.initialize_app(fire_base_config) # connect firebase
storage = firebase.storage() # init the database


client = c = mcrpc.RpcClient(rpchost,rpcport,rpcuser,rpcpasswd)
addresses = c.getaddresses()
# streams = c.liststreams()
# list_streams = c.liststreams('*',True)
# peers = c.getpeerinfo()
# node_info = c.getinfo()
# json rpc commands


def bin2hex(binStr):
    return binascii.hexlify(binStr)
# convert binary to hex format


def hex2bin(hexStr):
    return binascii.unhexlify(hexStr)
Esempio n. 5
0
def _connect():
    client = mcrpc.RpcClient(settings.MULTICHAIN_IP, settings.MULTICHAIN_PORT, settings.MULTICHAIN_RPCUSER, \
                             settings.MULTICHAIN_RPCPASSWORD)
    return client