Gregglogger

A few weeks back I felt bored and somewhat nihilistic, so naturally I went where people go to when they want to scream into the void. This time the void didn't gaze back at me, but served me this:

Programmers have a Pavlovian Engineering Response, so 20 minutes later with a bit of prompting I made Gregglogger, excuse: me Gregglogger✨.

What is Gregglogger

Gregglogger records every time you copy, cut or paste things on Mac. It also plays a recording of peeling scotch tape when you do that.

Let me demonstrate this by helping three little ducklings cross the river and reunite with their mom:

Open™ and Kind™

Following the File over app philosophy, all data is stored in a proprietary but easy to parse Greggfile (Wikipedia) , located by default under ~/how-many-times-did-I-press-CMD-C-or-V.gregg .

I'm tired of walled gardens. I believe that all keyloggers should have easy and equal access to the same data (and I am not alone). So please if you're building one — go ahead and use my our Greggfile!

My body temperature has increased. Where do I get the Gregglogger?

You sound like a warm lead. Let me introduce you to this link: <a>link</a>.

Alternatively:

$ git clone git@github.com:paprikka/gregglogger.git && cd gregglogger
$ pip install -r requirements.txt
$ python gregglogger.py

What I've learned

(Let's be serious for a moment.)

There's something I don't think about very often: writing simple keyloggers is surprisingly easy.

  1. This code is as boilerplate as it gets. Anyone with basic software engineering experience could write it in a few minutes.
  2. Running this script in a terminal requires no additional user input, including permission requests.

This, coupled with the fact that MacOS comes with pre-installed python, means that with relative ease anyone could add this to their NPM packages, effectively covering everyone's computers with virtual scotch tape:

{
  "name": "padleft",
  "version": "1.0.0",
  "description": "Pad left (or right, but never both)",
  "main": "index.js",
  "scripts": {
	// 👇🏼
    "postinstall": "pip install && python gregglogger.py"
	// 👆
  },
  "keywords": [
    "padleft",
    "padright",
    "pad",
    "padaria",
    "pastelaria"
  ]
}

To be clear, none of these issues is purely Python or Node specific. These are just the languages I happened to used on that day and it was a rough day, so I'm going to pick on them.

Limitations

This code will detect keyboard events at the OS level, but not when using protected inputs. Here's what happens when I update Gregglogger to record any keypress, but open a password input:

As soon as the focus switches to a password input, we can intercept only the modifier keys. To my knowledge, this can be fixed by requesting the OS-level accessibility permissions, which would require a separate user interaction.

Next steps

Anyway, I pressed CMD+C/V a bit more than 70 times writing this note. This is a little bit surprising given that I use Vim bindings in my text editor.

Thanks for reading!


P.S. And thanks, Greg, for giving me a reason to build something so beautifully useless and half-baked purely for fun! Think twice before you tweet next time.

Want to receive my work as I publish it? Subscribe here.

a giant foot-shaped snail with a house on its back. the house is still in construction, with a big crane towering above it The image is a stylized black-and-white illustration. In the lower left corner, there is a small, cozy-looking house with smoke rising from its chimney. The smoke, however, does not dissipate into the air but instead forms a dark, looming cloud. Within the cloud, the silhouette of a large, menacing face is visible, with its eyes and nose peeking through the darkness. The creature, perhaps a cat, appears to be watching over the house ominously, creating a sense of foreboding or unease.