# Path: demonhunter/nodes/master/ext.py



import json
import time
from pathlib import Path
from flask import Flask, render_template, request, redirect, flash, url_for
from flask_login import login_required, logout_user, login_user, current_user
from .models import *
from .ext import db, login_manager, sockets
        flash('Agent deleted')
    else:
        flash('No Agent with this id')
    return redirect(url_for('agents_list'))

@app.route('/agents/call/<token>/', methods=['POST'])
def agents_call(token):
    a = Agent.query.filter_by(token=token).first()
    if not a or a.address != request.remote_addr:
        for ws in online_users:
            ws.send(json.dumps(
                    {'type':'alart',
                     'content':'An attack to manager or bad honeypot agent configuration',
                     'title':'Attack to manager ?'}
                )
            )
        return "ok"

    a.last_message = time.time()

    data = request.get_json()
    from_address = data['from']
    attack_time = data['time']
    protocol = data['protocol']
    del data['from']
    del data['time']
    del data['protocol']
    hpd = HoneypotData(
        protocol=protocol, honeypot_address=a.address,
        attack_time=attack_time, from_address=from_address, data=json.dumps(data))

# Path: demonhunter/nodes/master/ext.py



# Path: demonhunter/nodes/master/webapp.py
import json
import time
from pathlib import Path
from flask import Flask, render_template, request, redirect, flash, url_for
from flask_login import login_required, logout_user, login_user, current_user
from .models import *
from .ext import db, login_manager, sockets

        flash('Agent deleted')
    else:
        flash('No Agent with this id')
    return redirect(url_for('agents_list'))

@app.route('/agents/call/<token>/', methods=['POST'])
def agents_call(token):
    a = Agent.query.filter_by(token=token).first()
    if not a or a.address != request.remote_addr:
        for ws in online_users:
            ws.send(json.dumps(
                    {'type':'alart',
                     'content':'An attack to manager or bad honeypot agent configuration',
                     'title':'Attack to manager ?'}
                )
            )
        return "ok"

    a.last_message = time.time()

    data = request.get_json()
    from_address = data['from']
    attack_time = data['time']
    protocol = data['protocol']
    del data['from']
    del data['time']
    del data['protocol']
    hpd = HoneypotData(
        protocol=protocol, honeypot_address=a.address,
        attack_time=attack_time, from_address=from_address, data=json.dumps(data))

    db.session.add(hpd)