This is simple example of new attack that using X11. Program to detect when linux user opens terminal with root and inject intrusive commands in terminal with X11 lib.
Video of Proof of concept
The proposal of this video is use the tool rootstealer to spy all gui windows interactions and inject commands only in root terminal. This approach is util when attacker need to send a malicious program to prove that user is vulnerable to social engineering. Force root command in terminal with lib X11 is a exotic way to show the diversity of weak points.
Edit file rootstealer/cmd.cfg and write your command to inject.
# apt-get install libX11-dev libxtst-dev
# cd rootstealer/sendkeys;
Now you can take that following:
Run the python script to spy all windows gui and search window with "root@" string in title.
# make; cd .. #to back to path rootstealer/
# pip intall gi
# pip install gir
Note: If you prefers uses full C code... to use simple binary purposes... you can uses rootstealer.c
$ python rootstealer.py &
Done, look the video demo, rootstealer force commands only on root terminal...
$ sudo apt-get install libwnck-dev
$ gcc -o rootstealer rootstealer.c `pkg-config --cflags --libs libwnck-1.0` -DWNCK_I_KNOW_THIS_IS_UNSTABLE -DWNCK_COMPILATION
$ ./rootstealer &
Don't trust in anyone. https://www.esecurityplanet.com/views/article.php/3908881/9-Best-Defenses-Against-Social-Engineering-Attacks.htm
Always when you enter by root user, change window title:
This simple action can prevent this attack.
# gnome-terminal --title="SOME TITLE HERE"
Tested on Xubuntu 16.04