0

What I'am trying to do

I made a keylogger by reading the event file, but it needs root permission to work.I want to make a keylogger that can work without root permission.

My device

  • ubuntu16.04 using X11
  • ubuntu21.04 using Wayland

My thoughts

I understand that it is feasible on windows, and it can also be implemented through Xlib on some linux using X11.

But my project needs to run on X11 and Wayland, so it's obviously not possible to use Xlib.

Question

Is there any other way that I can get key logged without root permission?

Yatogami
  • 49
  • 5
  • 2
    Geez, I really hope not! – Jeremy Friesner Aug 09 '21 at 06:06
  • You describe your goal. Can you elaborate on what makes you think that it is possible? I ask because it seems to be a feature that it is not possible. – Yunnosch Aug 09 '21 at 06:51
  • @Yunnosch [python-keylooger](https://stackoverflow.com/questions/365110/cross-platform-keylogger) Th pykeylogger using xlib to get key logged , xlib don't need root permission, bu xlib can't work on wayland, so I'm wondering that is there a way to do the same thing on wayland. – Yatogami Aug 09 '21 at 07:13

1 Answers1

2

It may be possible, but any non root solution will depend on the keyboard virtualization tool. Let us look how (modern) OS work:

  • the hardware is under the exclusive control of the kernel and its drivers. It is possible to implement a keylogger at that level that would only be kernel dependent but it requires admin privileges.
  • if you have a multiple windows capable system (X11, XWindow) the OS passes low level events to the window manager which in turn will passes them to the client program. In Windows that part is include in the kernel for historical reasons. Here again it is possible to implement a (still low level) keylogger, but if the window manager has been started as root, interacting with it as a whole still requires admin privileges. At least the X11 server can be started as a non admin user process and in that use case, the keylogger can also run under the same user.
  • at the end, the window manager passes events to the client application. On some (windowing) sytems, it is possible to implement hooks but they will be restricted to the same process or process group or at least the same user. Whether it is possible or not, and the way to implement it if possible will be anyway window manager dependant.

That means that it may be possible to implement a user level keylogger, but it will depend on the windowing system and not only on the kernel. Said differently, you will have to search for a Wayland specific way and a X11 specific way if you want to support both of them.

Serge Ballesta
  • 136,215
  • 10
  • 111
  • 230