コード例 #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
コード例 #2
0
ファイル: main.py プロジェクト: saularraffi/Net-Enum
# ============================== 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':
        httpPorts.append(port)

    serviceVersion = services[port]['version']
    state = services[port]['state']
    print('  ' + str(port) + '/tcp: ' + '   ' + state + '     ' +
          serviceName.rstrip(',') + ', ' + serviceProduct + ', ' +
          serviceVersion)

# ============================== os scan ==============================

printHeader('Operating System Scan')