Exemplo n.º 1
0
def fingerprint_generic(ajax_request, provide_additional_info=False):
    # detect server whorls, merge with client whorls
    server_whorls = FingerprintAgent(request).detect_server_whorls()
    whorls = server_whorls.copy()
    if ajax_request:
        for i in request.form.keys():
            whorls[i] = request.form.get(i)

    # record the fingerprint we've crafted
    FingerprintRecorder.record_fingerprint(
        whorls, session['long_cookie'], request.remote_addr, key)

    # calculate the values we'll need to display to the user
    counts, total, matching, bits, group, uniqueness = EntropyHelper.calculate_values(
        whorls)

    markup = render_template('ajax_fingerprint.html',
                             counts=counts,
                             total=total,
                             total_formatted=number_format(total),
                             sample_string=EntropyHelper.size_words(total),
                             matching=matching,
                             bits=bits,
                             group=group,
                             labels=FingerprintHelper.whorl_names,
                             whorls=whorls,
                             uniqueness=uniqueness)

    if ajax_request:
        return jsonify({'matching': matching, 'markup': markup})
    elif provide_additional_info:
        return matching, markup
    else:
        return markup
Exemplo n.º 2
0
def fingerprint_generic(ajax_request, provide_additional_info=False):
    # detect server whorls, merge with client whorls
    server_whorls = FingerprintAgent(request).detect_server_whorls()
    whorls = server_whorls.copy()
    if ajax_request:
        for i in request.form.keys():
            whorls[i] = request.form.get(i)

    # record the fingerprint we've crafted
    FingerprintRecorder.record_fingerprint(whorls, session['long_cookie'],
                                           request.remote_addr, key)

    # calculate the values we'll need to display to the user
    counts, total, matching, bits, group, uniqueness = EntropyHelper.calculate_values(
        whorls)

    markup = render_template('ajax_fingerprint.html',
                             counts=counts,
                             total=total,
                             total_formatted=number_format(total),
                             sample_string=EntropyHelper.size_words(total),
                             matching=matching,
                             bits=bits,
                             group=group,
                             labels=FingerprintHelper.whorl_names,
                             whorls=whorls,
                             uniqueness=uniqueness)

    if ajax_request:
        return jsonify({'matching': matching, 'markup': markup})
    elif provide_additional_info:
        return matching, markup
    else:
        return markup
Exemplo n.º 3
0
def api_v1_ua_uniqueness():
    whorl = json.loads(request.data)
    return jsonify(
        EntropyHelper.single_whorl_uniqueness(whorl['name'], whorl['value']))
Exemplo n.º 4
0
def api_v1_ua_uniqueness():
    whorl = json.loads(request.data)
    return jsonify(EntropyHelper.single_whorl_uniqueness(whorl['name'], whorl['value']))