#nmap-mp-scanner is multiprocess scanner, which achieve parallelism efficiently. With 40 processes, all ports -p- scan with -sV was completed in less the 24 hours for 800 hosts using digitalOcean VPS.
# Multiprocessing > Multithreading

import urllib3
import multiprocessing.pool
import time
import os

number_of_processes=30
nmap_directory_name="nmap"

def runScan(target):
    print("Target scanning: "+target)
    result = os.popen('nmap -Pn -T4 -sV -p- -oX '+nmap_directory_name+'/nmap-' + target + ".xml "+target).read().splitlines()


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

if __name__ == "__main__":
    print(" ***** nmap multiprocess Scanner Started ***** ")
    if not os.path.exists(nmap_directory_name):
        os.makedirs(nmap_directory_name)

    input_file = open("input.txt", "r")
    targets = input_file.readlines()
    input_file.close()
    targets = [x.strip() for x in targets]

    if len(targets) < number_of_processes:
        number_of_processes = len(targets)

    index = 0
    processes = []
    for i in range(number_of_processes):
        processes.append(multiprocessing.Process(target=runScan,args=(targets[index],)))
        index+=1

    for p in processes:
        p.start()

    more_loop = True
    while more_loop:
        time.sleep(5)

        for i in range(0,number_of_processes) :
            if processes[i].is_alive():
                processes[i].join(1)
                #print("jobs is not finished")
            else:
                if index >= len(targets):
                    for p in processes:
                        p.join()
                    more_loop = False
                    break
                processes[i] = multiprocessing.Process(target=runScan,args=(targets[index],))
                processes[i].start()
                index+=1

    print("Pool completed execution!!!")
    print("Exiting main thread.")
    exit(0)

bbc10474f03cc1f7c22352bfdfdac4c8216e239e
<mask token>


def runScan(target):
    print('Target scanning: ' + target)
    result = os.popen('nmap -Pn -T4 -sV -p- -oX ' + nmap_directory_name +
        '/nmap-' + target + '.xml ' + target).read().splitlines()


<mask token>

<mask token>


def runScan(target):
    print('Target scanning: ' + target)
    result = os.popen('nmap -Pn -T4 -sV -p- -oX ' + nmap_directory_name +
        '/nmap-' + target + '.xml ' + target).read().splitlines()


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if __name__ == '__main__':
    print(' ***** nmap multiprocess Scanner Started ***** ')
    if not os.path.exists(nmap_directory_name):
        os.makedirs(nmap_directory_name)
    input_file = open('input.txt', 'r')
    targets = input_file.readlines()
    input_file.close()
    targets = [x.strip() for x in targets]
    if len(targets) < number_of_processes:
        number_of_processes = len(targets)
    index = 0
    processes = []
    for i in range(number_of_processes):
        processes.append(multiprocessing.Process(target=runScan, args=(
            targets[index],)))
        index += 1
    for p in processes:
        p.start()
    more_loop = True
    while more_loop:
        time.sleep(5)
        for i in range(0, number_of_processes):
            if processes[i].is_alive():
                processes[i].join(1)
            else:
                if index >= len(targets):
                    for p in processes:
                        p.join()
                    more_loop = False
                    break
                processes[i] = multiprocessing.Process(target=runScan, args
                    =(targets[index],))
                processes[i].start()
                index += 1
    print('Pool completed execution!!!')
    print('Exiting main thread.')
    exit(0)

<mask token>
number_of_processes = 30
nmap_directory_name = 'nmap'


def runScan(target):
    print('Target scanning: ' + target)
    result = os.popen('nmap -Pn -T4 -sV -p- -oX ' + nmap_directory_name +
        '/nmap-' + target + '.xml ' + target).read().splitlines()


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if __name__ == '__main__':
    print(' ***** nmap multiprocess Scanner Started ***** ')
    if not os.path.exists(nmap_directory_name):
        os.makedirs(nmap_directory_name)
    input_file = open('input.txt', 'r')
    targets = input_file.readlines()
    input_file.close()
    targets = [x.strip() for x in targets]
    if len(targets) < number_of_processes:
        number_of_processes = len(targets)
    index = 0
    processes = []
    for i in range(number_of_processes):
        processes.append(multiprocessing.Process(target=runScan, args=(
            targets[index],)))
        index += 1
    for p in processes:
        p.start()
    more_loop = True
    while more_loop:
        time.sleep(5)
        for i in range(0, number_of_processes):
            if processes[i].is_alive():
                processes[i].join(1)
            else:
                if index >= len(targets):
                    for p in processes:
                        p.join()
                    more_loop = False
                    break
                processes[i] = multiprocessing.Process(target=runScan, args
                    =(targets[index],))
                processes[i].start()
                index += 1
    print('Pool completed execution!!!')
    print('Exiting main thread.')
    exit(0)

import urllib3
import multiprocessing.pool
import time
import os
number_of_processes = 30
nmap_directory_name = 'nmap'


def runScan(target):
    print('Target scanning: ' + target)
    result = os.popen('nmap -Pn -T4 -sV -p- -oX ' + nmap_directory_name +
        '/nmap-' + target + '.xml ' + target).read().splitlines()


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
if __name__ == '__main__':
    print(' ***** nmap multiprocess Scanner Started ***** ')
    if not os.path.exists(nmap_directory_name):
        os.makedirs(nmap_directory_name)
    input_file = open('input.txt', 'r')
    targets = input_file.readlines()
    input_file.close()
    targets = [x.strip() for x in targets]
    if len(targets) < number_of_processes:
        number_of_processes = len(targets)
    index = 0
    processes = []
    for i in range(number_of_processes):
        processes.append(multiprocessing.Process(target=runScan, args=(
            targets[index],)))
        index += 1
    for p in processes:
        p.start()
    more_loop = True
    while more_loop:
        time.sleep(5)
        for i in range(0, number_of_processes):
            if processes[i].is_alive():
                processes[i].join(1)
            else:
                if index >= len(targets):
                    for p in processes:
                        p.join()
                    more_loop = False
                    break
                processes[i] = multiprocessing.Process(target=runScan, args
                    =(targets[index],))
                processes[i].start()
                index += 1
    print('Pool completed execution!!!')
    print('Exiting main thread.')
    exit(0)

#nmap-mp-scanner is multiprocess scanner, which achieve parallelism efficiently. With 40 processes, all ports -p- scan with -sV was completed in less the 24 hours for 800 hosts using digitalOcean VPS.
# Multiprocessing > Multithreading

import urllib3
import multiprocessing.pool
import time
import os

number_of_processes=30
nmap_directory_name="nmap"

def runScan(target):
    print("Target scanning: "+target)
    result = os.popen('nmap -Pn -T4 -sV -p- -oX '+nmap_directory_name+'/nmap-' + target + ".xml "+target).read().splitlines()


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

if __name__ == "__main__":
    print(" ***** nmap multiprocess Scanner Started ***** ")
    if not os.path.exists(nmap_directory_name):
        os.makedirs(nmap_directory_name)

    input_file = open("input.txt", "r")
    targets = input_file.readlines()
    input_file.close()
    targets = [x.strip() for x in targets]

    if len(targets) < number_of_processes:
        number_of_processes = len(targets)

    index = 0
    processes = []
    for i in range(number_of_processes):
        processes.append(multiprocessing.Process(target=runScan,args=(targets[index],)))
        index+=1

    for p in processes:
        p.start()

    more_loop = True
    while more_loop:
        time.sleep(5)

        for i in range(0,number_of_processes) :
            if processes[i].is_alive():
                processes[i].join(1)
                #print("jobs is not finished")
            else:
                if index >= len(targets):
                    for p in processes:
                        p.join()
                    more_loop = False
                    break
                processes[i] = multiprocessing.Process(target=runScan,args=(targets[index],))
                processes[i].start()
                index+=1

    print("Pool completed execution!!!")
    print("Exiting main thread.")
    exit(0)
