gitanat / keystroke_dynamics

a keystroke dynamics algorithm in python (recognizes a person by the way s/he types)
32 stars 22 forks source link

Does it work on MS Windows? #3

Closed amsr9 closed 7 years ago

amsr9 commented 7 years ago

Hi When I try to run the example.py I got the following error message: File "C:\Anaconda\lib\site-packages\Xlib\support\unix_connect.py", line 29, in <module> import fcntl ImportError: No module named fcntl

Any suggestions?

gitanat commented 7 years ago

Hi amsr9, As the readme mentions

It needs the X windowing system with the RECORD extension enabled

Windows doesn't come with X, so the short answer is no, it doesn't work in windows. There might be a way to get a X server under windows and get this running somehow, but I have a hunch it's going to be much much easier to just run linux, on a VM or otherwise.

On the other hand, the core algorithm should be completely cross platform - it's only the live key capture that needs OS support. There might be a easy way around X. What task are you trying to do?

amsr9 commented 7 years ago

Thanks for your reply. I'm trying to perform a continuous and transparent authentication for the user. So in order to make it works o Windows, which file I need to replace/modify to live key capture? Please have a look here: https://pypi.python.org/pypi/keyboard

I guess we don't have to write the windows keyboard hook code from scratch.

gitanat commented 7 years ago

keyboard looks pretty cool, it would be great if we can make it work. The only file that would need to be replaced is capture_keys.py. The public interface is just start(), which takes a callback

amsr9 commented 7 years ago

I just tried it on Ubuntu and it works great! I'm trying to follow how the features are computed by reading the features.py file, as far as I understood is that each key has its own dwelling and flight time. I'm not fully aware how it is computed so Please can give a brief description on how the feature are computed?

gitanat commented 7 years ago

You might want to see this wikipedia article: https://en.wikipedia.org/wiki/Keystroke_dynamics

quoting from there:

Dwell time (the time a key pressed) and Flight time (the time between "key up" and the next "key down").

Both of these can be computed from the key up/down event timing, it's just a matter of filtering it in a smart way (ignore too long flight times, for example, that happen when the user is not typing anymore)

The current code then takes these timings and models each key dwell/flight time as a normal distribution. The mean and standard deviation of that distribution is then used as a feature.

It's a very simple model. It performs ok, but you can probably do a lot better by using a RNN. I never got around to doing that

amsr9 commented 7 years ago

Very helpful. The code is well written and really appreciate your effort.

gitanat commented 7 years ago

Closing this, as you seemed to get it to work under Ubuntu