1. 29
  1.  

  2. 12

    Glossing over why sudo would mysteriously not work, this writes a bunch of noise out to the monitor:

    > sudo cat /dev/urandom > /dev/fb0
    -bash: /dev/fb0: Permission denied
    

    That command does not work because the redirection is performed by the shell which does not have the permission to write to /dev/fb0. The redirection of the output is not performed by sudo.

    How to do it here

    1. 7

      You can use tee as well:

      cat /dev/urandom | sudo tee /dev/fb0
      

      It’s quite funny that person who don’t know how shell and sudo (nb: use doas or su instead) tells us a lengthy story about writing to framebuffers in Linux

      1. 11

        The frame buffer is arguably a lot simpler than a *nix shell

        1. 7

          nb: use […] su instead

          You better don’t, it’s vulnerable to the ages-old TIOCSTI trick::

          #include <sys/ioctl.h>
          int main() {
              char* c = "exit\nid\n";
              for (; *c; ++c)
                  ioctl(0,TIOCSTI,*c);
              return 0;
          }
          

          (in .bashrc or so)

          This can be deterred by using su -P, but it’s marked as experimental (according to the manpage), and I haven’t seen anyone using it.

          1. 3

            TIOCSTI

            more info here, as I haven’t heard of it previously https://ruderich.org/simon/notes/su-sudo-from-root-tty-hijacking

        2. 1

          This probably works for the author if they’re in the video group:

          $ ll /dev/fb0
          crw-rw---- 1 root video 29, 0  5 apr 15:37 /dev/fb0
          

          EDIT: I’m stupid, didn’t see that part of the article.

          1. 1

            Forgot to read your write-up when you posted it originally. Thanks for the reminder, it’s great stuff.