'If I have a way of telling if a port is open or not, for example
using PHP\'s include() error messages, then I can perform a portscan
by doing something similar to:
for port in port_list:
open = self.shell.is_open_port( host, port )
if open:
report_open( port )'

def api_is_open_port(self, target, ports):

    ip_address_list = []
    if (target != 'auto'):
        ip_address_list = [target]
    else:
        tcp_result = self.exec_payload('tcp')
        udp_result = self.exec_payload('udp')
        for key in tcp_result:
            connected_to = tcp_result[key]['rem_address']
            if is_private_site(connected_to):
                ip_address_list.append(connected_to)
        for key in udp_result:
            connected_to = tcp_result[key]['rem_address']
            if is_private_site(connected_to):
                ip_address_list.append(connected_to)
    if (ports == 'default'):
        port_list = self.DEFAULT_PORTS
    else:
        port_list = ''.join(ports)
        port_list = port_list.split(',')
        port_list = [port.strip() for port in port_list]
        if (not all((port.isdigit() for port in port_list))):
            ValueError('Target    ports    need    to    be    integers')
    result = {}
    for ip_address in ip_address_list:
        result[ip_address] = []
    for ip_address in ip_address_list:
        for port in port_list:
            is_open = self.shell.is_open_port(ip_address, port)
            if is_open:
                result[ip_address].append(port)
    return result
