Exemplo n.º 1
0
def produceMasterProfileFAR(text, user):
    all_keyHoldTime = []
    all_interkeyTime = []

    filename = 'processedData/text{0}/user{1}.json'.format(text, user)
    with open(filename, 'r') as f:
        data = [json.loads(line) for line in f]

    outliers = getPositionOfOutliers(text, user)
    data = [timings for i, timings in enumerate(data) if not i in outliers]

    for i, timings in enumerate(data):

        ikt = calculateInterkeyTime(timings['keyPressData'],
                                    timings['keyReleaseData'])
        kht = calculateKeyHoldTime(timings['keyPressData'],
                                   timings['keyReleaseData'])

        if len(ikt) > len(kht):
            del ikt[-1]
        elif len(kht) > len(ikt):
            del kht[-1]

        all_interkeyTime.append(ikt)
        all_keyHoldTime.append(kht)

    master_interkeyTime = [
        statistics.mean(time) for time in zip(*all_interkeyTime)
    ]
    master_keyHoldTime = [
        statistics.mean(time) for time in zip(*all_keyHoldTime)
    ]
    return (master_interkeyTime, master_keyHoldTime, all_interkeyTime,
            all_keyHoldTime)
Exemplo n.º 2
0
def profilePlot():
    all_keyHoldTime = []
    all_interkeyTime = []

    for user in range(1, 2):
        for text in range(1, 2):
            filename = 'processedData/text{0}/user{1}.json'.format(text, user)
            with open(filename, 'r') as f:
                data = [json.loads(line) for line in f]

            outliers = getPositionOfOutliers(text, user)
            data = [
                timings for i, timings in enumerate(data) if not i in outliers
            ]

            for i, timings in enumerate(data):
                ikt = calculateInterkeyTime(timings['keyPressData'],
                                            timings['keyReleaseData'])
                kht = calculateKeyHoldTime(timings['keyPressData'],
                                           timings['keyReleaseData'])

                if len(ikt) > len(kht):
                    del ikt[-1]
                elif len(kht) > len(ikt):
                    del kht[-1]

                all_interkeyTime.append(ikt)
                all_keyHoldTime.append(kht)
                fig = int('{}{}'.format(user, text))
                plt.figure(fig)
                plt.plot([i / 10000 for i in kht], [i / 10000 for i in ikt])

            plt.xlabel('Key Hold Time (*10^4)(microseconds)')
            plt.ylabel('Interkey Time (*10^4)(microseconds)')
            plt.savefig('user{}-text{}.png'.format(user, text))
Exemplo n.º 3
0
def authenticateFRR(user, text, comparator):
    master_ikt, master_kht, c, d = produceMasterProfileFRR(text, user)
    count = 0
    allUserCount = 0
    filename = 'processedData/text{0}/user{1}.json'.format(text, user)

    with open(filename, 'r') as f:
        data = [json.loads(line) for line in f]

    outliers = getPositionOfOutliers(text, user)
    data = [timings for i, timings in enumerate(data) if not i in outliers]

    for timings in data[5:]:
        ikt = calculateInterkeyTime(timings['keyPressData'],
                                    timings['keyReleaseData'])
        kht = calculateKeyHoldTime(timings['keyPressData'],
                                   timings['keyReleaseData'])

        if len(ikt) > len(kht):
            del ikt[-1]
        elif len(kht) > len(ikt):
            del kht[-1]

        euclideanDistance = [
            ((x1 - x2)**2 + (y1 - y2)**2)**(1 / 2)
            for x1, y1, x2, y2 in zip(master_ikt, master_kht, ikt, kht)
        ]
        dissimilarity = sum(euclideanDistance)
        authenticationValue = 1 if dissimilarity <= comparator else 0
        user = '******' if authenticationValue == 1 else 'Imposter'
        if user == 'Imposter':
            count += 1
        allUserCount += 1

    return ((count / allUserCount) * 100)
Exemplo n.º 4
0
def produceMasterProfileFRR(text, user):
    all_keyHoldTime = []
    all_interkeyTime = []

    filename = 'processedData/text{0}/user{1}.json'.format(text, user)
    with open(filename, 'r') as f:
        data = [json.loads(line) for line in f]

    outliers = getPositionOfOutliers(text, user)
    data = [timings for i, timings in enumerate(data) if not i in outliers]

    # here only 5 records have been used because after removing outliers around 20 records are only left
    # per user; so only 5 for master profile generation and remaining for authentication
    for timings in data[:5]:

        ikt = calculateInterkeyTime(timings['keyPressData'],
                                    timings['keyReleaseData'])
        kht = calculateKeyHoldTime(timings['keyPressData'],
                                   timings['keyReleaseData'])

        if len(ikt) > len(kht):
            del ikt[-1]
        elif len(kht) > len(ikt):
            del kht[-1]

        all_interkeyTime.append(ikt)
        all_keyHoldTime.append(kht)

    master_interkeyTime = [
        statistics.mean(time) for time in zip(*all_interkeyTime)
    ]
    master_keyHoldTime = [
        statistics.mean(time) for time in zip(*all_keyHoldTime)
    ]
    return (master_interkeyTime, master_keyHoldTime, all_interkeyTime,
            all_keyHoldTime)