Beispiel #1
0
def ntorrent():
    content = request.get_json(silent=True)
    name = content["name"]
    parts = content["parts"]
    file_hash = content["fileHash"]
    ip = content["ip"]
    ext = content["ext"]
    key = content["key"]
    db.addData(name, parts, file_hash, ext, ip, key)
    return jsonify({"code": 200})
Beispiel #2
0
def addData(source_ip, destination_ip, protocol, label):
    switchData = getSwitchData()
    if switchData is not None:
        # there's data okay oo
        for switch in switchData:
            data = []
            data.append(source_ip) # source ip
            data.append(destination_ip) # destination ip
            data.append(protocol) # protocol
            data.append(switch) # switch_mac
            port_info = switchData[switch]['port_reply'][0]['port']
            p1_data = port_info[0]
            p2_data = port_info[1]
            p3_data = port_info[2]
            p4_data = port_info[3]

            # p1, p2, p3, p4
            data.append(0)
            data.append(1)
            data.append(2)
            data.append(3)

            # p1 data
            data.append(p1_data['receive_packets'])
            data.append(p1_data['transmit_packets'])
            data.append(p1_data['receive_bytes'])
            data.append(p1_data['transmit_bytes'])
            
            # p2 data
            data.append(p2_data['receive_packets'])
            data.append(p2_data['transmit_packets'])
            data.append(p2_data['receive_bytes'])
            data.append(p2_data['transmit_bytes'])

            # p3 data
            data.append(p3_data['receive_packets'])
            data.append(p3_data['transmit_packets'])
            data.append(p3_data['receive_bytes'])
            data.append(p3_data['transmit_bytes'])


            # p4 data
            data.append(p4_data['receive_packets'])
            data.append(p4_data['transmit_packets'])
            data.append(p4_data['receive_bytes'])
            data.append(p4_data['transmit_bytes'])

            # label
            data.append(label)

            # add data to db
            db.addData(data)
Beispiel #3
0
def torrent():
    content = request.get_json(silent=True)
    payload = jwtVerify(request.headers.get("token"))
    if payload != -1:
        return jsonify({"code": 2})
    print(content)
    name = content["name"]
    parts = content["parts"]
    file_hash = content["fileHash"]
    ip = content["ip"]
    ext = content["ext"]
    key = content["key"]
    db.addData(name, parts, file_hash, ext, ip, key)
    syncAllTorrent(name, parts, file_hash, ip, ext, key)
    return jsonify({"code": 200})
Beispiel #4
0
def process(pkt, node, timeSeen):
    ip = pkt.getlayer(IP)
    ether = pkt.getlayer(Ether)
    pprint.pprint(pkt)
    d.default('[+] Time: {}'.format(timeSeen))
    # add to db
    id = db.addData(ether.src, ether.dst, ip.src, ip.dst, timeSeen, node, "",
                    "", "icmp")

    # forward data to classify
    cf.classify(pkt, "icmp", node, timeSeen, id)
def addToBlockChain(uid):
    pendT = getPendingTransaction(uid)
    addData(getLastIndex(), pendT.transaction, parser.parse(pendT.timeStamp))
    return setFlag(uid, "1")
Beispiel #6
0
from db import addData
import json, datetime

for i in range(0, 100):
    data = {}
    timeStamp = datetime.datetime.now()
    data["name"] = "Amey" + str(i)
    addData(i, json.dumps(data), timeStamp)