Ejemplo n.º 1
0
def default_api_consumer():
    """Consumes the example API at the lovely jsonplaceholder.typicode.com
    and sends to the message queue."""
    r = requests.get('https://jsonplaceholder.typicode.com/posts')
    if r.status_code != 200:
        msg = "ERROR: API returned status code {}.".format(r.status_code)
        redis_store.publish(managers.REDIS_PUBSUB_CHANNEL, msg)
        return msg
    msg = r.json()
    pb = redis_store.publish(managers.REDIS_PUBSUB_CHANNEL, msg)
    flask_app.logger.info(pb)
    return msg
Ejemplo n.º 2
0
def algo(submenu):
    if submenu == 'jamming':
        form = Jamming()
        if request.method == 'GET':
            form.timeout.default = redis_store.get('algo:JammingEventTimeout')
            form.process()
        if form.validate_on_submit():
            flash("success jamming settings")
            previous = redis_store.get('algo:JammingEventTimeout')
            if previous != form.timeout.data:
                redis_store.set('algo:JammingEventTimeout', form.timeout.data)
                redis_store.publish('algo', 'algo:JammingEventTimeout')
            return redirect(url_for('siem'))
        return render_template('jamming.html', form=form)
    elif submenu == 'wlanattack':
        form = WLANAttack()
        if request.method == 'GET':
            form.timeout.default = redis_store.get(
                'algo:WlanAttackEventTimeout')
            form.process()
        if form.validate_on_submit():
            previous = redis_store.get('algo:WlanAttackEventTimeout')
            if previous != form.timeout.data:
                redis_store.set('algo:WlanAttackEventTimeout',
                                form.timeout.data)
                redis_store.publish('algo', 'algo:WlanAttackEventTimeout')
            flash("success WLAN ATtack settings")
            return redirect(url_for('siem'))
        return render_template('wlanattack.html', form=form)
    elif submenu == 'bruteforcelogin':
        form = BruteForceLogin()
        if request.method == 'GET':
            form.timeout.default = redis_store.get(
                'algo:BruteForceLoginEventTimeout')
            form.duration.default = redis_store.get(
                'algo:BruteForceLoginWindow')
            form.count.default = redis_store.get('algo:BruteForceLoginThd')
            form.process()
        if form.validate_on_submit():
            previous_to = redis_store.get('algo:BruteForceLoginEventTimeout')
            previous_win = redis_store.get('algo:BruteForceLoginWindow')
            previous_thd = redis_store.get('algo:BruteForceLoginThd')
            if previous_to != form.timeout.data:
                redis_store.set('algo:BruteForceLoginEventTimeout',
                                form.timeout.data)
                redis_store.publish('algo', 'algo:BruteForceLoginEventTimeout')
            if previous_win != form.duration.data:
                redis_store.set('algo:BruteForceLoginWindow',
                                form.duration.data)
                redis_store.publish('algo', 'algo:BruteForceLoginWindow')
            if previous_thd != form.count.data:
                redis_store.set('algo:BruteForceLoginThd', form.count.data)
                redis_store.publish('algo', 'algo:BruteForceLoginThd')
            #form.process()
            flash("success Brute Force Login settings")
            return redirect(url_for('siem'))
        return render_template('bruteforcelogin.html', form=form)
    elif submenu == 'radiuslogin':
        form = RadiusLogin()
        if request.method == 'GET':
            form.timeout.default = redis_store.get(
                'algo:RadiusLoginEventTimeout')
            form.duration.default = redis_store.get('algo:RadiusLoginWindow')
            form.count.default = redis_store.get('algo:RadiusLoginThd')
            form.process()
        if form.validate_on_submit():
            previous_to = redis_store.get('algo:RadiusLoginEventTimeout')
            previous_win = redis_store.get('algo:RadiusLoginWindow')
            previous_thd = redis_store.get('algo:RadiusLoginThd')

            if previous_to != form.timeout.data:
                redis_store.set('algo:RadiusLoginEventTimeout',
                                form.timeout.data)
                redis_store.publish('algo', 'algo:RadiusLoginEventTimeout')
            if previous_win != form.duration.data:
                redis_store.set('algo:RadiusLoginWindow', form.duration.data)
                redis_store.publish('algo', 'algo:RadiusLoginWindow')
            if previous_thd != form.count.data:
                redis_store.set('algo:RadiusLoginThd', form.count.data)
                redis_store.publish('algo', 'algo:RadiusLoginThd')
            flash("success Radius Login settings")
            return redirect(url_for('siem'))
        return render_template('radiuslogin.html', form=form)
Ejemplo n.º 3
0
def basic(submenu):
    print("* " + submenu)
    if submenu == 'networksetting':
        form = LANConfiguration()
        ip_mode = scriptutils.get_ip_mode()
        ip_addr = scriptutils.get_ipaddr()
        subnet_mask = scriptutils.get_subnet_mask()
        default_gwaddr = scriptutils.get_defaultgwaddr()
        dnsservers = scriptutils.get_dnsservers()

        if request.method == 'GET':
            print("ip_mode = {}".format(ip_mode))
            form.ip_mode.default = 1 if ip_mode == 'static' else 2
            form.ip_address.default = ip_addr
            form.subnet_mask.default = subnet_mask
            form.default_gateway_address.default = default_gwaddr
            form.primary_dns_ip_address.default = dnsservers[0]
            form.secondary_dns_ip_address.default = dnsservers[1] if len(
                dnsservers) == 2 else ''
            form.process()

        if form.validate_on_submit():
            flash("success network settings")
            print("ip_address = {}".format(form.ip_address.data))

            ip_mode = form.ip_mode.data
            if ip_mode == '1':
                print("setting for static networking")
                ipaddr = form.ip_address.data
                subnet = form.subnet_mask.data
                gw = form.default_gateway_address.data
                dns1 = form.primary_dns_ip_address.data
                dns2 = form.secondary_dns_ip_address.data
                scriptutils.do_staticnetworking(ipaddr, subnet, gw, dns1, dns2)

            return redirect(url_for('siem'))
        return render_template('lanconfiguration.html', form=form)
    elif submenu == 'administration':
        form = SystemInformation()

        if request.method == 'GET':
            form.system_contact.default = redis_store.get('agent:syscontact')
            form.system_location.default = redis_store.get('agent:syslocation')
            form.ro_commstring.default = redis_store.get('agent:rocommunity')
            form.process()

        if form.validate_on_submit():
            flash("success sys administration settings")
            prev_sc = form.system_contact.default = redis_store.get(
                'ugent:syscontact')
            prev_sl = form.system_location.default = redis_store.get(
                'agent:syslocation')
            prev_ro = form.ro_commstring.default = redis_store.get(
                'agent:rocommunity')
            if prev_sc != form.system_contact.data:
                redis_store.set('agent:syscontact', form.system_contact.data)
                redis_store.publish('agent', 'agent:syscontact')
            if prev_sl != form.system_location.data:
                redis_store.set('agent:syslocation', form.system_location.data)
                redis_store.publish('agent', 'agent:syslocation')
            if prev_ro != form.ro_commstring.data:
                redis_store.set('agent:rocommunity', form.ro_commstring.data)
                redis_store.publish('agent', 'agent:rocommunity')
            return redirect(url_for('siem'))
        return render_template('systeminformation.html', form=form)
Ejemplo n.º 4
0
def publish(data):
    msg_json = json.dumps({"data": data, "type": "message"})
    return redis_store.publish('label', msg_json)
Ejemplo n.º 5
0
def publish():
    redis_store.publish('test-channel', 'some data from test channel')
    return 'publish'