ports = [31, 1170, 1234, 1243, 1981, 2001, 2023, 2140, 2989,445, 3024, 3150, 3700, 4950, 6346, 6400, 6667, 6670, 12345, 12346, 16660, 20034, 20432, 20433, 27374, 27444, 27665, 30100, 31335, 31337, 33270,33567, 33568, 40421, 60008, 65000]

import socket
import sys

def alert(arg):
    sys.stderr.write("%d%d%d" % (arg, arg, arg))

count = 0
    
for port in ports:
    print port
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    result = s.connect_ex(('127.0.0.1', port))

    if result == 0:
        print str(port) + " port is open"
        count += 1
    s.close()

if count >= 1:
    alert(1)
else:
    alert(0)
