#!/usr/bin/perl5.8.4
#  This software was derived from SATAN 1.1.1 by Dan Farmer and Wietse Venema
#  (http://www.porcupine.org/satan).
#
#
#  Query the target's X display and report whether or not it is vulnerable
# to simple X attacks (keystroke grabbing, etc.)
#
# Updated to reduce false positives on X server detection 12 July 2000 by todd
# 
require 'config/paths.pl';
require 'perl/misc.pl';
require 'perllib/getopts.pl';

$usage = "Usage: $0 [-d display] [-v] target";
&Getopts("d:v") || die $usage;
($#ARGV <=  1) || die $usage;

# used in final output
$target = $ARGV[0];
$display = defined($opt_d) ? $opt_d : "$target:0";
$service = "x11";
$status = "a";

# the actual program that does the work

$printed = 0;
$command = "DISPLAY=$display $XHOST 2>&1";
print "$command\n" if $opt_v;
open (XHOST, "$command|") || die "cannot run $XHOST";
$xhost = <XHOST>;
print $xhost if $opt_v;
if ($xhost =~ /disabled/i) {
	$severity = "us";
	$trustee = "USER\@$target";
	$trusted = "ANY\@ANY";
	$service_output = "unrestricted X server access";
	$text = "No X server access control";
        $printed = 1;
} elsif ($xhost =~ /authorize/i) {
	$severity = "g";
	$trustee = "";
	$trusted = "";
	$service_output = "";
	$text = "X server isn't vulnerable";
        $printed = 1;
}

&sara_print() if $printed == 1;

# that's it...
