source code: http://git.zx2c4.com/evdev-keylogger/tree/
zx2c4@Thinkpad ~ $ git clone http://git.zx2c4.com/evdev-keylogger/
Cloning into 'evdev-keylogger'...
zx2c4@Thinkpad ~ $ cd evdev-keylogger/
zx2c4@Thinkpad ~/evdev-keylogger $ make
cc -O3 -march=native -fomit-frame-pointer -pipe logger.c keymap.c keymap.h evdev.c evdev.h process.c process.h -o logger
zx2c4@Thinkpad ~/evdev-keylogger $ ./logger -h
Evdev Keylogger by zx2c4
Usage: ./logger [OPTION]...
-d, --daemonize run as a background daemon
-f, --foreground run in the foreground (default)
-u, --force-us-keymap instead of auto-detection, force usage of built-in US keymap
-e DEVICE, --event-device=DEVICE use event device DEVICE (default=auto-detect)
-l FILE, --log-file=FILE write key log to FILE (default=stdout)
-p FILE, --pid-file=FILE write the pid of the process to FILE
-n NAME, --process-name=NAME change process name in ps and top to NAME
-h, --help display this message
It has the ability to daemonize, log to a file, and mask itself in the process table. Far from what a real kernel rootkit logger could do, but instead it's clean and reliable.I used to actually have this in my git repository with a little thing in there that would connect back to my server when run, and then I had a README and notices all over in the source code and makefile and everywhere that you should remove this part of the code before compiling, under all circumstances. Anybody reasonable would have seen the notices and removed the code. The idea was that this way I'd know how many script kiddies were abusing it, and if maybe it was a bad idea to keep it up there. Well, in fact I did get a lot of connections, and it was kind of horrible to see. Then I forgot about it, until seeing this post. So I figured, either I take it down, because script kiddies, not people who are merely curious to see how a key logger works, are using it, or I keep it up there. In the end, I decided to stop being a dick, remove the connection thinger, and now the HN crowd will hopefully find something interesting to learn in it. A failed experiment at dealing with the script kiddie situation, oh well. At least, now, my code is untainted.
Anyway feel free to email me or leave a comment here if you find any bugs or have patches, or whatever. The code should be pretty basic to understand.
So when would you want to use LD_PRELOAD?
The classic LD_PRELOAD trick is to replace malloc and free with your own functions that contain some kind of instrumentation for debugging/profiling purposes.
Tinkering with LD_PRELOAD (and LD_LIBRARY_PATH) may have unintended consequences, so it's not a good idea to use them in your environment permanently.
I'd agree with the people who warn against using it when not absolutely necessary.
People don't seem to think twice about failing a password auth.
Because the exploit in the article exists, on a system that uses su, having access to a non-root administrative account (that accesses root regularly through su) is equivalent to having root access. But it's not as obvious that this is the case.
This means the sudo setup is more secure (with respect to this exploit), because it doesn't pretend to have a level of security it doesn't actually have.
What's up with that? It's as though we're happy that we can be infiltrated at any time. It's not like people don't put weeks and months into "me-too" websites ... but there's never been any major motion in the direction of making the existence of surreptitious mods available at a key-click?
Such apps may exist, but I've never run across one for any platform explicitly designed to help anyone root out what's been installed without their knowledge. It CAN'T be that hard. Link it up to an open online knowledge-base that will nix false flags ...
Apparently nowadays debugfs is owner-only rw, so you have to change it or start it as root.
https://github.com/przemoc/kaos
Look for the top-right corner to see the effect while you're typing or clicking something.
P.S. Funny thing is that I don't know why I wrote >>Kprobe dependency can be easily removed by writing own input handler and it will be done in future<< back then, because when I evaluated this statement year or so ago, it didn't look that easy, and there would be more code in the end, I suppose.
So basically you had to go first to a virtual console (in text mode) and then issue the Magic SYSRQ shortcut.
That would kill all processes running on that console and you'd be sure to have a stock prompt without any kind of software keylogger.
I don't know if Magic SYSRQ still exists or not for 64-bit Linuxes, it's been a while I haven't used it.