Novell ZENWORKS NETWORK ACCESS CONTROL 5.0 - 09-22-2008 User Manual page 354

Table of Contents

Advertisement

self.session.host()
_____________________________________________________________________________
_____________________________________________________________________________
restricted Python socket
_____________________________________________________________________________
354 Novell ZENworks Network Access Control Users Guide
print "Checking ports " + str(ports) + " on host " +
#
# Do your test here. Modify the returnHash accordingly.
#
portsOpen = ""
#
# Use a Python socket to connect directly to the target host
#
import socket
for p in ports:
hp = self.session.host()+":"+str(p)
s = None
try:
if debug:
print "Connecting to " + hp
#
# Try to open the port. Throws an exception if connection
# is refused or times out (set timeout to 5 seconds).
#
# Note that Novell ZENworks Network Access Control uses a
# library that doesn't allow connections to arbitrary
# hosts.
Normally, the first element of the tuple passed
# to socket.connect() is the IP or hostname; in SA, you
# must pass the Session object form which the socket
# object will get the target host IP/name.
#
s = socket.socket()
s.settimeout(5)
s.connect((self.session, int(p)))
# Uh oh, no exception. The port was open
s.close()
if debug:
print "Connected to "+hp+". Port open!"
#
# Add the port to our list of open ports for use later
#
portsOpen += str(p) + ","

Advertisement

Table of Contents
loading

This manual is also suitable for:

Zenworks network access control 5.0

Table of Contents