Below is the file 'plugins/x11.py' from this revision. You can also download the file.

#!/usr/bin/python

import socket
import httplib
import os
import scan
from goatpy.utility import run_command

export = {
	"name" : "x11",
	"version" : "0.1",
	"description" : "Check for open X11 servers",
	"type" : "scanner",
	"tcp_ports" : [6000, 6001, 6002, 6003, 6004, 6005, 6006, 6007],
	"udp_ports" : None
}

def host_callback(library, host, tcp_ports, udp_ports):
	rv = []
	ip_addresses = filter(lambda x: x[1] == "ipv4", host.addresses)
	if len(ip_addresses) == 0: return rv
	address, protocol = ip_addresses[0]
	for port in tcp_ports:
		if port >= 6000: display_id = port - 6000
		else: display_id = 0
		display = "%s:%s" % (address, display_id)
		result = run_command("%s/x11/x11 %s >/dev/null 2>&1" % (library.config.plugin_path, display), library.config.socket_timeout)
		if result['timeout']: return rv
		if result['exitcode'] == 0:
			response = scan.ScannerResponse()
			response.address = (address, protocol)
			response.urgency = scan.urgency_critical
			response.plugin_name = export['name']
			response.short_mesg = "Open X server: %s" % (display)
			rv.append(response)
	return rv