Ejemplo n.º 1
0
def custom(saved=False):
    """the function returns the custom rules page when the user is logged in"""
    utils = Webutils()
    if utils.check_login() is True:
        payload = utils.get_default_payload("Custom")
        payload.rules = utils.get_rule_list("custom")
        payload.custom = utils.get_rule_status("custom") == "custom"
        payload.saved = saved
        return render_template('custom.html', vars=payload)
    return login("", None)
Ejemplo n.º 2
0
def ports(saved=False):
    """the function returns the ports page when the user is logged in"""
    utils = Webutils()
    if utils.check_login() is True:
        payload = utils.get_default_payload("Ports")
        payload.tcp = utils.get_rule_list("tcp")
        payload.udp = utils.get_rule_list("udp")
        payload.custom = False
        if utils.get_rule_status("tcp") == "custom" or utils.get_rule_status(
                "udp") == "custom":
            payload.custom = True
        payload.saved = saved
        return render_template('ports.html', vars=payload)
    return login("", None)
Ejemplo n.º 3
0
def blacklist_save():
    """
    the function saves the blacklist rules into the corresponding rulesfile
    """
    utils = Webutils()
    if utils.check_login() is True:
        ipaddress = ""
        rulelist = utils.get_rule_list("blacklist")

        for key, value in request.form.items():
            if key == "ipadr":
                # then a new ip address is blacklisted
                ipaddress = value
                rulelist.append(ipaddress)
                utils.save_rule_list("blacklist", rulelist)
            else:
                # then a old ip address is removed
                ipaddress = key
                rulelist.remove(ipaddress)
                utils.save_rule_list("blacklist", rulelist)
        return blacklist(True)
    return login("", None)
Ejemplo n.º 4
0
def remove_port(port, ruletype):
    """the function removes a port from the opened port rules file"""
    utils = Webutils()
    rulelist = utils.get_rule_list(ruletype)
    rulelist.remove(port)
    utils.save_rule_list(ruletype, rulelist)
Ejemplo n.º 5
0
def add_port(port, ruletype):
    """the function adds a port to the opened port rules file"""
    utils = Webutils()
    rulelist = utils.get_rule_list(ruletype)
    rulelist.append(port)
    utils.save_rule_list(ruletype, rulelist)