The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-31-2008
sysgate's Avatar
sysgate sysgate is offline
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,213
I got this little script from Ghostdog74 from our forum, modified it a bit to suit my needs :
Code:
#!/usr/bin/python

import socket
import sys

if ( len(sys.argv) != 2 ):
    print "Usage: " + sys.argv[0] + " you must enter IP or FQDN as argument"
    sys.exit(1)

remote_host = sys.argv[1]

for remote_port in [21,22,23,80,139,139,389,443,445,3128,3306,3389]:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(20)
        try:
                sock.connect((remote_host, remote_port))
        except Exception,e:
                print "%d closed " % remote_port
        else:
                print "%d open" % remote_port
        sock.close()
- change the ports as you wish.
Implementing nmap for ports monitoring is also good idea.
Reply With Quote