示例#1
0
文件: app.py 项目: czardoz/beeswarm
def configure_client(drone_id):
    config_dict = send_database_request('{0} {1}'.format(Messages.DRONE_CONFIG.value, drone_id))
    config_obj = DictWrapper(config_dict)
    form = ClientConfigurationForm(obj=config_obj)
    if not form.validate_on_submit():
        return render_template('configure-client.html', form=form, mode_name='Client', user=current_user)
    else:
        client_config = {'name': form.general__name.data,
                         'mode': 'client'}

        client_config['bait_timings'] = {
            'http': {
                'active_range': form.bait_timings__http__active_range.data,
                'sleep_interval': form.bait_timings__http__sleep_interval.data,
                'activation_probability': form.bait_timings__http__activation_probability.data
            },
            'ftp': {
                'active_range': form.bait_timings__ftp__active_range.data,
                'sleep_interval': form.bait_timings__ftp__sleep_interval.data,
                'activation_probability': form.bait_timings__ftp__activation_probability.data
            },
            'https': {
                'active_range': form.bait_timings__https__active_range.data,
                'sleep_interval': form.bait_timings__https__sleep_interval.data,
                'activation_probability': form.bait_timings__https__activation_probability.data
            },
            'pop3': {
                'active_range': form.bait_timings__pop3__active_range.data,
                'sleep_interval': form.bait_timings__pop3__sleep_interval.data,
                'activation_probability': form.bait_timings__pop3__activation_probability.data
            },
            'ssh': {
                'active_range': form.bait_timings__ssh__active_range.data,
                'sleep_interval': form.bait_timings__ssh__sleep_interval.data,
                'activation_probability': form.bait_timings__ssh__activation_probability.data
            },
            'pop3s': {
                'active_range': form.bait_timings__pop3s__active_range.data,
                'sleep_interval': form.bait_timings__pop3s__sleep_interval.data,
                'activation_probability': form.bait_timings__pop3s__activation_probability.data
            },
            'smtp': {
                'active_range': form.bait_timings__smtp__active_range.data,
                'sleep_interval': form.bait_timings__smtp__sleep_interval.data,
                'activation_probability': form.bait_timings__smtp__activation_probability.data
            },
            'vnc': {
                'active_range': form.bait_timings__vnc__active_range.data,
                'sleep_interval': form.bait_timings__vnc__sleep_interval.data,
                'activation_probability': form.bait_timings__vnc__activation_probability.data
            },
            'telnet': {
                'active_range': form.bait_timings__telnet__active_range.data,
                'sleep_interval': form.bait_timings__telnet__sleep_interval.data,
                'activation_probability': form.bait_timings__telnet__activation_probability.data
            }
        }

        send_database_request('{0} {1} {2}'.format(Messages.CONFIG_DRONE.value, drone_id,
                                                   json.dumps(client_config)))
        return render_template('finish-config-client.html', drone_id=drone_id, user=current_user)
示例#2
0
def configure_client(drone_id):
    config_dict = send_database_request('{0} {1}'.format(
        Messages.DRONE_CONFIG.value, drone_id))
    config_obj = DictWrapper(config_dict)
    form = ClientConfigurationForm(obj=config_obj)
    if not form.validate_on_submit():
        return render_template('configure-client.html',
                               form=form,
                               mode_name='Client',
                               user=current_user)
    else:
        client_config = {'name': form.general__name.data, 'mode': 'client'}

        client_config['bait_timings'] = {
            'http': {
                'active_range':
                form.bait_timings__http__active_range.data,
                'sleep_interval':
                form.bait_timings__http__sleep_interval.data,
                'activation_probability':
                form.bait_timings__http__activation_probability.data
            },
            'ftp': {
                'active_range':
                form.bait_timings__ftp__active_range.data,
                'sleep_interval':
                form.bait_timings__ftp__sleep_interval.data,
                'activation_probability':
                form.bait_timings__ftp__activation_probability.data
            },
            'https': {
                'active_range':
                form.bait_timings__https__active_range.data,
                'sleep_interval':
                form.bait_timings__https__sleep_interval.data,
                'activation_probability':
                form.bait_timings__https__activation_probability.data
            },
            'pop3': {
                'active_range':
                form.bait_timings__pop3__active_range.data,
                'sleep_interval':
                form.bait_timings__pop3__sleep_interval.data,
                'activation_probability':
                form.bait_timings__pop3__activation_probability.data
            },
            'ssh': {
                'active_range':
                form.bait_timings__ssh__active_range.data,
                'sleep_interval':
                form.bait_timings__ssh__sleep_interval.data,
                'activation_probability':
                form.bait_timings__ssh__activation_probability.data
            },
            'pop3s': {
                'active_range':
                form.bait_timings__pop3s__active_range.data,
                'sleep_interval':
                form.bait_timings__pop3s__sleep_interval.data,
                'activation_probability':
                form.bait_timings__pop3s__activation_probability.data
            },
            'smtp': {
                'active_range':
                form.bait_timings__smtp__active_range.data,
                'sleep_interval':
                form.bait_timings__smtp__sleep_interval.data,
                'activation_probability':
                form.bait_timings__smtp__activation_probability.data
            },
            'vnc': {
                'active_range':
                form.bait_timings__vnc__active_range.data,
                'sleep_interval':
                form.bait_timings__vnc__sleep_interval.data,
                'activation_probability':
                form.bait_timings__vnc__activation_probability.data
            },
            'telnet': {
                'active_range':
                form.bait_timings__telnet__active_range.data,
                'sleep_interval':
                form.bait_timings__telnet__sleep_interval.data,
                'activation_probability':
                form.bait_timings__telnet__activation_probability.data
            }
        }

        send_database_request('{0} {1} {2}'.format(Messages.CONFIG_DRONE.value,
                                                   drone_id,
                                                   json.dumps(client_config)))
        return render_template('finish-config-client.html',
                               drone_id=drone_id,
                               user=current_user)
示例#3
0
文件: app.py 项目: ichakra/beeswarm
def configure_client(id):
    db_session = database_setup.get_session()
    drone = db_session.query(Drone).filter(Drone.id == id).one()
    if drone.discriminator != 'client' or drone is None:
        abort(404, 'Drone with id {0} not found or invalid.'.format(id))
    config_dict = send_config_request('{0} {1}'.format(Messages.DRONE_CONFIG, id))
    config_obj = DictWrapper(config_dict)
    form = ClientConfigurationForm(obj=config_obj)
    if not form.validate_on_submit():
        return render_template('configure-client.html', form=form, mode_name='Client', user=current_user)
    else:
        bait_timing_config = {
            'http': {
                'active_range': form.bait_timings__http__active_range.data,
                'sleep_interval': form.bait_timings__http__sleep_interval.data,
                'activation_probability': form.bait_timings__http__activation_probability.data
            },
            'ftp': {
                'active_range': form.bait_timings__ftp__active_range.data,
                'sleep_interval': form.bait_timings__ftp__sleep_interval.data,
                'activation_probability': form.bait_timings__ftp__activation_probability.data
            },
            'https': {
                'active_range': form.bait_timings__https__active_range.data,
                'sleep_interval': form.bait_timings__https__sleep_interval.data,
                'activation_probability': form.bait_timings__https__activation_probability.data
            },
            'pop3': {
                'active_range': form.bait_timings__pop3__active_range.data,
                'sleep_interval': form.bait_timings__pop3__sleep_interval.data,
                'activation_probability': form.bait_timings__pop3__activation_probability.data
            },
            'ssh': {
                'active_range': form.bait_timings__ssh__active_range.data,
                'sleep_interval': form.bait_timings__ssh__sleep_interval.data,
                'activation_probability': form.bait_timings__ssh__activation_probability.data
            },
            'pop3s': {
                'active_range': form.bait_timings__pop3s__active_range.data,
                'sleep_interval': form.bait_timings__pop3s__sleep_interval.data,
                'activation_probability': form.bait_timings__pop3s__activation_probability.data
            },
            'smtp': {
                'active_range': form.bait_timings__smtp__active_range.data,
                'sleep_interval': form.bait_timings__smtp__sleep_interval.data,
                'activation_probability': form.bait_timings__smtp__activation_probability.data
            },
            'vnc': {
                'active_range': form.bait_timings__vnc__active_range.data,
                'sleep_interval': form.bait_timings__vnc__sleep_interval.data,
                'activation_probability': form.bait_timings__vnc__activation_probability.data
            },
            'telnet': {
                'active_range': form.bait_timings__telnet__active_range.data,
                'sleep_interval': form.bait_timings__telnet__sleep_interval.data,
                'activation_probability': form.bait_timings__telnet__activation_probability.data
            }
        }

        drone.bait_timings = json.dumps(bait_timing_config)
        db_session.add(drone)
        db_session.commit()

        send_config_request('{0} {1}'.format(Messages.DRONE_CONFIG_CHANGED, drone.id))
        return render_template('finish-config-client.html', drone_id=drone.id, user=current_user)
示例#4
0
def configure_client(id):
    db_session = database_setup.get_session()
    drone = db_session.query(Drone).filter(Drone.id == id).one()
    if drone.discriminator != 'client' or drone is None:
        abort(404, 'Drone with id {0} not found or invalid.'.format(id))
    config_dict = send_config_request('{0} {1}'.format(Messages.DRONE_CONFIG,
                                                       id))
    config_obj = DictWrapper(config_dict)
    form = ClientConfigurationForm(obj=config_obj)
    if not form.validate_on_submit():
        return render_template('configure-client.html',
                               form=form,
                               mode_name='Client',
                               user=current_user)
    else:
        bait_timing_config = {
            'http': {
                'active_range':
                form.bait_timings__http__active_range.data,
                'sleep_interval':
                form.bait_timings__http__sleep_interval.data,
                'activation_probability':
                form.bait_timings__http__activation_probability.data
            },
            'ftp': {
                'active_range':
                form.bait_timings__ftp__active_range.data,
                'sleep_interval':
                form.bait_timings__ftp__sleep_interval.data,
                'activation_probability':
                form.bait_timings__ftp__activation_probability.data
            },
            'https': {
                'active_range':
                form.bait_timings__https__active_range.data,
                'sleep_interval':
                form.bait_timings__https__sleep_interval.data,
                'activation_probability':
                form.bait_timings__https__activation_probability.data
            },
            'pop3': {
                'active_range':
                form.bait_timings__pop3__active_range.data,
                'sleep_interval':
                form.bait_timings__pop3__sleep_interval.data,
                'activation_probability':
                form.bait_timings__pop3__activation_probability.data
            },
            'ssh': {
                'active_range':
                form.bait_timings__ssh__active_range.data,
                'sleep_interval':
                form.bait_timings__ssh__sleep_interval.data,
                'activation_probability':
                form.bait_timings__ssh__activation_probability.data
            },
            'pop3s': {
                'active_range':
                form.bait_timings__pop3s__active_range.data,
                'sleep_interval':
                form.bait_timings__pop3s__sleep_interval.data,
                'activation_probability':
                form.bait_timings__pop3s__activation_probability.data
            },
            'smtp': {
                'active_range':
                form.bait_timings__smtp__active_range.data,
                'sleep_interval':
                form.bait_timings__smtp__sleep_interval.data,
                'activation_probability':
                form.bait_timings__smtp__activation_probability.data
            },
            'vnc': {
                'active_range':
                form.bait_timings__vnc__active_range.data,
                'sleep_interval':
                form.bait_timings__vnc__sleep_interval.data,
                'activation_probability':
                form.bait_timings__vnc__activation_probability.data
            },
            'telnet': {
                'active_range':
                form.bait_timings__telnet__active_range.data,
                'sleep_interval':
                form.bait_timings__telnet__sleep_interval.data,
                'activation_probability':
                form.bait_timings__telnet__activation_probability.data
            }
        }

        drone.bait_timings = json.dumps(bait_timing_config)
        db_session.add(drone)
        db_session.commit()

        send_config_request('{0} {1}'.format(Messages.DRONE_CONFIG_CHANGED,
                                             drone.id))
        return render_template('finish-config-client.html',
                               drone_id=drone.id,
                               user=current_user)