Пример #1
0
def getipinfo():
    ath = auth.Auth()
    if not ath.checkSession():
        return redirect(url_for('lock'))
    global save
    if 'sip' in request.args and 'dip' in request.args:
        sMemory = sharedMemory.sharedMemory()
        infot = sMemory.getRecord(request.args["sip"], request.args["dip"])
        while infot == -1:
            infot = sMemory.getRecord(request.args["sip"], request.args["dip"])
        proto = sMemory.parseProtocolo(infot[10])
        if save[0] == request.args["sip"] + request.args["sip"]:
            tupla = (proto, infot[8], infot[9])
            if tupla not in save:
                save.append(tupla)
        else:
            save = []
            save.append(request.args["sip"] + request.args["sip"])

        return render_template('getipinfo.html',
                               sip=request.args["sip"],
                               dip=request.args["dip"],
                               info=infot,
                               proto=proto,
                               save=save)
def signup():
    email = None
    errorMessage = ""
    if request.method == "POST":
        email = request.form.get("email")
        password = request.form.get("password")
        name = request.form.get("name")

        authWrapper = auth.Auth()
        databaseWrapper = db.Database()

        try:
            authWrapper.CreateUser(name, email, password)
            user = firebase_admin.auth.get_user_by_email(email)
            publicKey, privateKey = databaseWrapper.CreateUser(user=user)

            session['userId'] = user.uid
            session['email'] = user.email
            session['publicKey'] = publicKey
            session['privateKey'] = privateKey

            return redirect(url_for('inbox'))
        except requests.exceptions.HTTPError as err:
            errorDict = ast.literal_eval(err.strerror)
            errorMessage = errorDict["error"]["message"]
        except ValueError as err:
            errorMessage = err
        except firebase_admin._auth_utils.EmailAlreadyExistsError as err:
            errorMessage = err
        except firebase_admin.exceptions.InvalidArgumentError as err:
            errorMessage = err
    return render_template('signup.html', errorMessage=errorMessage)
Пример #3
0
def lock():

    if 'password' in request.form:
        if auth.Auth().checkPassword(request.form["password"]):
            return redirect(url_for('index'))
    else:
        return render_template('lock.html', title="Iniciar sesión", error=True)
    return render_template('lock.html', title="Iniciar sesión", error=False)
Пример #4
0
def rjsonTable():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.args:
            if not ath.checkKey(request.args["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))
    jTable = jsonTable.jsonTable()
    return jTable.getTable()
Пример #5
0
def getblockip():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.args:
            if not ath.checkKey(request.args["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))

    block = blockIP.blockIP()
    return block.getTable()
Пример #6
0
def api():
    ath = auth.Auth()
    if not ath.checkSession():
        return redirect(url_for('lock'))
    if 'key' in request.args:
        ath.generateKey()

    return render_template('api.html',
                           title="API REST",
                           url=request.url_root,
                           key=ath.getKey())
Пример #7
0
def StopTrace():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.args:
            if not ath.checkKey(request.args["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))

    chk = checker.Checker()
    chk.updateValue('8')
    return "0"
Пример #8
0
def configServer():
    cnf = config.Config()
    if 'timecheck' in request.form:
        cnf.updateConfig(request.form["ppslimit"], request.form["mbitslimit"],
                         request.form["timecheck"], request.form["blocktime"],
                         request.form["deleteRegister"])

    ath = auth.Auth()
    if not ath.checkSession():
        return redirect(url_for('lock'))
    return render_template('config.html',
                           title="Configuración del cortafuegos",
                           config=cnf.getConfig())
Пример #9
0
def shutdown():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.form:
            if not ath.checkKey(request.form["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))
    if 'shutdown' in request.form:
        chk = checker.Checker()
        chk.updateValue('s')
        chk.shutdown_server()
    return render_template('shutdown.html', title="Apagar el cortafuegos")
Пример #10
0
def makeclean():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.form:
            if not ath.checkKey(request.form["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))
    if 'clean' in request.form or 'authkey' in request.form:
        chk = checker.Checker()
        chk.updateValue('c')
        return "0"
    return "-1"
Пример #11
0
def unblockport():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.form:
            if not ath.checkKey(request.form["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))
    if 'port' in request.form:
        block = blockPort.BlockPort()
        block.unBlockPort(request.form["port"])
        return "0"
    return "1"
Пример #12
0
def getTrace():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.args:
            if not ath.checkKey(request.args["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))
    if os.path.exists("../data/guardian.pcap"):
        with open("../data/guardian.pcap", 'rb') as file:
            return send_file(io.BytesIO(file.read()),
                             attachment_filename='guardian.pcap',
                             mimetype='text/plain')
    return "1"
Пример #13
0
def unblock():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.form:
            if not ath.checkKey(request.form["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))

    if 'ip' in request.form:
        block = blockIP.blockIP()
        block.deleteIP(request.form["ip"], 0)
        return "0"
    return "1"
Пример #14
0
def blockport():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.form:
            if not ath.checkKey(request.form["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))

    if 'time' in request.form and 'port' in request.form:
        block = blockPort.BlockPort()
        block.blockPort(request.form["port"], request.form["time"])
    if 'authkey' in request.form:
        return "0"
    else:
        return render_template('blockPort.html', title="Bloquear Puertos")
Пример #15
0
def blockip():
    ath = auth.Auth()
    if not ath.checkSession():
        if 'authkey' in request.form:
            if not ath.checkKey(request.form["authkey"]):
                return "-1"
        else:
            return redirect(url_for('lock'))
    if 'ip' in request.form and 'time' in request.form:
        block = blockIP.blockIP()
        block.saveIP(request.form["ip"], 0, request.form["time"])

    if 'authkey' in request.form:
        return "0"
    else:
        return render_template('blockIP.html', title="Bloquear Dirección IP")
def login():
    if request.method == "GET":
        if 'userId' in session:
            return redirect(url_for('inbox'))
        else:
            return render_template('index.html', title="Login/Sign Up!")

    if request.method == "POST":
        authWrapper = auth.Auth()

        email = request.form.get("email")
        password = request.form.get("password")
        response = authWrapper.LoginUser(email, password)

        if response['userId'] and response['idToken']:
            session['userId'] = response['userId']
            session['email'] = response['email']
            session['publicKey'] = response['publicKey']
            session['privateKey'] = response['privateKey']

            return redirect(url_for('inbox'))
        else:
            errorMessage = response['message']
            return render_template('index.html', errorMessage=errorMessage)
Пример #17
0
def index():
    ath = auth.Auth()
    if not ath.checkSession():
        return redirect(url_for('lock'))
    return render_template('index.html', title="Información general")
Пример #18
0
def exit():
    ath = auth.Auth().exit()
    return redirect(url_for('lock'))