Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update readme #70

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
cc2e0c3
Merge remote-tracking branch 'vmonaco/master'
adrelanos Aug 16, 2023
537dec7
bumped changelog version
adrelanos Aug 16, 2023
f49d6b8
Merge remote-tracking branch 'vmonaco/master'
adrelanos Sep 18, 2023
ca5cf50
bumped changelog version
adrelanos Sep 18, 2023
c107815
Merge remote-tracking branch 'vmonaco/master'
adrelanos Sep 19, 2023
61c0b09
bumped changelog version
adrelanos Sep 24, 2023
196343c
Merge remote-tracking branch 'vmonaco/master'
adrelanos Sep 25, 2023
f10707f
bumped changelog version
adrelanos Sep 25, 2023
daafc67
CodeQL
adrelanos Nov 10, 2023
cfd1708
CodeQL
adrelanos Nov 10, 2023
1526784
copyright
adrelanos Nov 11, 2023
49bb0ac
bumped changelog version
adrelanos Nov 11, 2023
d48c864
update readme
adrelanos Jan 11, 2024
a8f0e5f
bumped changelog version
adrelanos Jan 11, 2024
9b19632
usrmerge
adrelanos Jan 22, 2024
ade162a
bumped changelog version
adrelanos Jan 22, 2024
de06819
usrmerge debhelper systemd Debian package maintainer scripts fix
adrelanos Feb 2, 2024
e937174
bumped changelog version
adrelanos Feb 2, 2024
36385d7
Use monotonic time for delay tracking
ArrayBolt3 Sep 23, 2024
c9c5a98
Add compiler hardening flags, fix all GCC warnings
ArrayBolt3 Sep 23, 2024
dd255ad
Use strtcpy rather than strncpy
ArrayBolt3 Sep 23, 2024
b0f0c92
Add a header file to make future development easier (adapted from htt…
ArrayBolt3 Sep 23, 2024
7f9bc1b
Harden code based on advice from ChatGPT3 (adapted from https://githu…
ArrayBolt3 Sep 23, 2024
0d91a09
Add support for new devices attached after kloak starts (adapted from…
ArrayBolt3 Sep 23, 2024
e9284ab
Fix build failure, adjust number of supported devices to account for …
ArrayBolt3 Sep 23, 2024
5beda6d
Add address and undefined behavior sanitization
ArrayBolt3 Sep 23, 2024
d7f386d
Enable use on non-Intel architectures, fix syscall whitelist
ArrayBolt3 Sep 23, 2024
7fa9500
Add some missing syscalls for x86_64
ArrayBolt3 Sep 23, 2024
ba5df25
Do resource cleanup on panic
ArrayBolt3 Sep 23, 2024
bb4a714
Add a useful change from https://github.com/vmonaco/kloak/pull/65 tha…
ArrayBolt3 Sep 23, 2024
e1e03d7
Merge pull request #1 from ArrayBolt3/arraybolt3
adrelanos Sep 24, 2024
81a5ef1
Merge remote-tracking branch 'github-whonix/master'
adrelanos Sep 24, 2024
98febd4
bumped changelog version
adrelanos Sep 24, 2024
0f3ae73
fork of kloak from upstream
adrelanos Sep 24, 2024
b085979
bumped changelog version
adrelanos Sep 24, 2024
ac9d1fc
Add -p option for disabling rescue key sequence
ArrayBolt3 Sep 24, 2024
a290f5f
Fix minor bug in makefile, add check for pkg-config
ArrayBolt3 Sep 24, 2024
47e67ba
Merge remote-tracking branch 'ArrayBolt3/master'
adrelanos Sep 25, 2024
fb6cff1
bumped changelog version
adrelanos Sep 25, 2024
aad35c7
add readlink syscall (required in VirtualBox)
adrelanos Sep 25, 2024
b783111
bumped changelog version
adrelanos Sep 25, 2024
cec549d
add open syscall (required in VirtualBox)
adrelanos Sep 25, 2024
db54b34
apparmor
adrelanos Sep 25, 2024
3cbe8b2
bumped changelog version
adrelanos Sep 25, 2024
3860446
Don't set the output device name under Qubes OS, it causes a scary no…
ArrayBolt3 Sep 25, 2024
c3500fc
Don't use AddressSanitizer, incompatible with Whonix's vm.mmap_rnd_bi…
ArrayBolt3 Sep 25, 2024
4bbdf38
Update README.md
ArrayBolt3 Sep 25, 2024
9b96a23
Merge remote-tracking branch 'ArrayBolt3/master'
adrelanos Sep 26, 2024
f5ee77e
bumped changelog version
adrelanos Sep 26, 2024
29477f9
Generate debugging info
ArrayBolt3 Sep 26, 2024
222994e
Merge remote-tracking branch 'ArrayBolt3/master'
adrelanos Sep 27, 2024
62a657e
bumped changelog version
adrelanos Sep 27, 2024
d4e7b4c
Change emulated device names to keep GTK from treating a cloaked Virt…
ArrayBolt3 Oct 6, 2024
cbfd81c
Merge remote-tracking branch 'ArrayBolt3/master'
adrelanos Oct 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

Files: *
Copyright: Copyright (c) 2016, Vinnie Monaco
License: BSD-3-clause
Copyright (c) 2016, Vinnie Monaco
All rights reserved.
.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 changes: 36 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
#!/usr/bin/make -f

TARGETARCH=$(shell gcc -dumpmachine)

# https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
#
# Omitted the following flags:
# -D_GLIBCXX_ASSERTIONS # application is not written in C++
# -fstrict-flex-arrays=3 # not supported in Debian Bookworm's GCC version (12)
# -fPIC -shared # not a shared library
# -fexceptions # not multithreaded
# -fhardened # not supported in Debian Bookworm's GCC version (12)
#
# Added the following flags:
# -fsanitize=address,undefined # enable ASan/UBSan
CFLAGS = -O2 -Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough \
-Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 \
-fstack-clash-protection \
-fstack-protector-strong -Wl,-z,nodlopen -Wl,-z,noexecstack -Wl,-z,relro \
-Wl,-z,now -Wl,--as-needed -Wl,--no-copy-dt-needed-entries -Wtrampolines \
-Wbidi-chars=any -fPIE -pie -Werror=implicit \
-Werror=incompatible-pointer-types -Werror=int-conversion \
-fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing \
-fsanitize=undefined

ifeq ($(TARGETARCH), x86_64-linux-gnu)
CFLAGS += -fcf-protection=full # only supported on x86_64
endif
ifeq ($(TARGETARCH), aarch64-linux-gnu)
CFLAGS += -mbranch-protection=standard # only supported on aarch64
endif

ifeq (, $(shell which pkg-config))
$(error pkg-config not installed!)
endif

all : kloak eventcap

kloak : src/main.c src/keycodes.c src/keycodes.h
gcc src/main.c src/keycodes.c -o kloak -lm $(shell pkg-config --cflags --libs libevdev) $(shell pkg-config --cflags --libs libsodium) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
gcc -g src/main.c src/keycodes.c -o kloak -lm $(shell pkg-config --cflags --libs libevdev) $(shell pkg-config --cflags --libs libsodium) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)

eventcap : src/eventcap.c
gcc src/eventcap.c -o eventcap $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
gcc -g src/eventcap.c -o eventcap $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)

clean :
rm -f kloak eventcap
70 changes: 13 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# anti keystroke deanonymization tool #
# anti keystroke deanonymization tool

kloak: *Keystroke-level online anonymization kernel*

Expand All @@ -23,8 +23,7 @@ Fedora:

Debian:

$ sudo apt install devscripts
$ sudo mk-build-deps --remove --install
$ sudo apt install make pkg-config libsodium-dev libevdev-dev

First, compile `kloak` and the event capture tool `eventcap`:

Expand Down Expand Up @@ -60,24 +59,24 @@ Notice that the lower bound on the random delay has to be raised when keys are p

How to install `kloak` using apt-get

1\. Download [Whonix's Signing Key]().
1\. Download the APT Signing Key.

```
wget https://www.whonix.org/patrick.asc
wget https://www.whonix.org/keys/derivative.asc
```

Users can [check Whonix Signing Key](https://www.whonix.org/wiki/Whonix_Signing_Key) for better security.
Users can [check the Signing Key](https://www.whonix.org/wiki/Signing_Key) for better security.

2\. Add Whonix's signing key.
2\. Add the APT Signing Key.

```
sudo apt-key --keyring /etc/apt/trusted.gpg.d/whonix.gpg add ~/patrick.asc
sudo cp ~/derivative.asc /usr/share/keyrings/derivative.asc
```

3\. Add Whonix's APT repository.
3\. Add the derivative repository.

```
echo "deb https://deb.whonix.org bullseye main contrib non-free" | sudo tee /etc/apt/sources.list.d/whonix.list
echo "deb [signed-by=/usr/share/keyrings/derivative.asc] https://deb.whonix.org bookworm main contrib non-free" | sudo tee /etc/apt/sources.list.d/derivative.list
```

4\. Update your package lists.
Expand All @@ -94,7 +93,7 @@ sudo apt-get install kloak

### How to build deb package

Replace `apparmor-profile-torbrowser` with the actual name of this package with `kloak` and see [instructions](https://www.whonix.org/wiki/Dev/Build_Documentation/apparmor-profile-torbrowser).
See the [Whonix package build documentation](https://www.whonix.org/wiki/Dev/Build_Documentation/security-misc). Replace the sample package name `security-misc` with `kloak` to download, build, and install kloak.

### Whonix contact and support

Expand All @@ -105,30 +104,8 @@ Replace `apparmor-profile-torbrowser` with the actual name of this package with

`kloak` requires [donations](https://www.whonix.org/wiki/Donate) to stay alive!


### Troubleshooting

#### Can't open input/output device

`kloak` will attempt to find your keyboard device to read events from and the location of `uinput` to write events to. If `kloak` cannot find either the input device or output device, these must be specified with the `-r` and `-w` options, respectively.

To find the keyboard device for reading events: determine which device file corresponds to the physical keyboard. Use `eventcap` (or some other event capture tool) and look for the device that generates events when keys are pressed. This will typically be one of `/dev/input/event[0-7]`. In this example, it's `/dev/input/event4`:

$ sudo ./eventcap /dev/input/event4
Reading From : /dev/input/event4 (AT Translated Set 2 keyboard)
Type: 4 Code: 4 Value: 15
Type: 1 Code: 15 Value: 0
Type: 0 Code: 0 Value: 0
Type: 4 Code: 4 Value: 56
Type: 1 Code: 56 Value: 0
Type: 0 Code: 0 Value: 0

`uinput` is the [kernel module](http://thiemonge.org/getting-started-with-uinput) that allows user-land applications to create input devices. This is typically located at either `/dev/uinput` or `/dev/input/uinput`.

Start `kloak` by specifying the input and output device files:

$ sudo ./kloak -r /dev/input/event4 -w /dev/uinput

#### My keyboard seems very slow

`kloak` works by introducing a random delay to each key press and release event. This requires temporarily buffering the event before it reaches the application (e.g., a text editor).
Expand All @@ -150,38 +127,17 @@ The full usage and options are:
-s startup_timeout: time to wait (milliseconds) before startup. Default 100.
-k csv_string: csv list of rescue key names to exit kloak in case the
keyboard becomes unresponsive. Default is 'KEY_LEFTSHIFT,KEY_RIGHTSHIFT,KEY_ESC'.
-p: persistent mode (disable rescue key sequence)
-v: verbose mode

## Try it out

Consider these three different scenarios:
* Train normal, test normal
* Train normal, test kloak
* Train `kloak`, test `kloak`

*Train normal* means to train with normal typing behavior, i.e., without `kloak` running. At the enrollment page on the KeyTrac demo (demo no longer available), enter a username and password without `kloak` running, and then on the authenticate page, try authenticating. For example, the train normal/test normal result is:

<div align="center">
<img src="figures/train-normal_test-normal.png"><br><br>
</div>

Start `kloak` and then try authenticating again. These results were obtained using a maximum delay of 200 ms (`-d 200`). The train normal/test `kloak` result is:

<div align="center">
<img src="figures/train-normal_test-kloak.png"><br><br>
</div>

Enroll With `kloak` running and then try authenticating with `kloak` still running. Again, this is with a 200 ms maximum delay. The train `kloak`/test `kloak` result is:

<div align="center">
<img src="figures/train-kloak_test-kloak.png"><br><br>
</div>

Your results may differ, especially in the train `kloak`/test `kloak` scenario. The train `kloak`/test `kloak` scenario is more difficult to anonymize than the train normal/test `kloak` scenario. This is because *kloak obfuscates your typing behavior, but does not make your typing behavior similar to other users*. This dilemma relates to the problem of user cooperation. It's easy to make your typing behavior look like something that it's not, but what should that be? If it's too unique, then the change does more harm then good, allowing you to be easily identified. Without the cooperation of other users, it's difficult to choose a behavior that's hard to distinguish.
See the [kloak defense testing](https://www.whonix.org/wiki/Keystroke_Deanonymization#Kloak) instructions.

## Background

`kloak` has two goals in mind:

* Make it difficult for an adversary to identify a user
* Make it difficult for an adversary to replicate a user's typing behavior

Expand Down
11 changes: 11 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

## For CodeQL autobuild

set -x
set -e

sudo --non-interactive apt-get update --error-on=any
sudo --non-interactive apt-get install --yes libevdev2 libevdev-dev libsodium23 libsodium-dev pkg-config

make
Loading