Esempio n. 1
0
def initialNmapScan(ip, ports='1-1024'):
    nmap = Nmap(ip, ports)
    serviceScan = nmap.tcpVersionScan()
    openPorts = {'tcp': nmap.getOpenTcpPorts()}
    os = nmap.getOs()

    services = {}
    ports = []

    for port in openPorts['tcp']:
        ports.append(port)
        serviceName = serviceScan[port]['name']
        serviceProduct = serviceScan[port]['product']
        serviceVersion = serviceScan[port]['version']
        state = serviceScan[port]['state']

        services[port] = {
            'name': serviceName,
            'product': serviceProduct,
            'version': serviceVersion,
            'state': state
        }

    scanResults = {'ports': ports, 'services': services, 'os': os}
    return scanResults
Esempio n. 2
0
                    help='specify the target IP address',
                    required=True)
parser.add_argument('-p', '--ports', type=str, help='specify port range')

args = parser.parse_args()
target = args.target
portRange = args.ports if args.ports != None else '1-1024'

print('Target: ' + target)
print('Ports: ' + portRange)

# ============================== setup nmap ==============================

nmap = Nmap(target, portRange)

services = nmap.tcpVersionScan()

# ============================== service scan ==============================

printHeader('Service Scan')

httpPorts = []

print('  Port       State    Service, Product, Version')
print('  ------------------------------------')

for port in nmap.getOpenTcpPorts():
    serviceName = services[port]['name']
    serviceProduct = services[port]['product']

    if serviceName == 'http':