@app.route('/start', methods=['POST'])
def start():
    '''
    Take the victim's IP, the hostname of the endpoint that is being
    attacked, the device interface and the source port of the endpoint
    and set a sniffer on all TLS connections between them.

    Arguments:
    source_ip -- the local network IP of the victim, e.g. 192.168.1.66
    destination_host -- the hostname of the attacked endpoint, e.g. dimkarakostas.com
    interface -- the device interface to use sniff on, e.g. wlan0
    destination_port -- the port of the endpoint e.g. 443

    Status code for the request:
            409: a sniffer on the same source_ip and destination host already exists
            400: parameters were not properly set
            201: a new sniffer for those arguments has been created
    '''
    data = request.get_json()
    source_ip = data['source_ip']
    destination_host = data['destination_host']
    interface = data['interface']
    destination_port = data['destination_port']

    # Check if a same sniffer already exists
    if (source_ip, destination_host) in sniffers:
        err = '409 - Sniffer (source_ip: {}, destination_host: {}) already exists.'.format(source_ip, destination_host)
        logger.warning(err)
        return str(err), 409

    params = {'source_ip': source_ip,
              'destination_host': destination_host,
              'interface': interface,
              'destination_port': destination_port}

    # Check if parameters are invalid
    try:
        sniffer = Sniffer(params)
    except AssertionError, err:
        logger.warning(err)
        return str(err), 400

    sniffers[(source_ip, destination_host)] = sniffer

    # Start the new sniffer thread and block until it has come to life
    sniffer.start()
    while not sniffer.is_alive():
        sleep(0.01)
    msg = 'Sniffer (source_ip: {}, destination_host: {}) is alive.'.format(source_ip, destination_host)
    logger.debug(msg)

    return msg, 201
dataset/ETHPy150Open dionyziz/rupture/sniffer/sniff.py/start/original