1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00

Look out, world, here comes the Nmap massping migration!

This is the merging of the code that was previously in
/nmap-exp/david/nmap-massping-migration. These are all the big changes
that get rid of massping in favor of doing host discovery using
ultra_scan.

For now, there is a toggle that turns these new changes off. Undefine
NEW_MASSPING in targets.cc to go back to the old code. All of that will
be deleted eventually.

There are likely a few more changes that will be made to this system in
the near future. Those will be made in
/nmap-exp/david/nmap-massping-migration and merged back.

Don't release this just yet, because I'm going to make a few more
commits real quick to remove some debugging stuff.

(Note to self: this merge back was from r5693 in
/nmap-exp/david/nmap-massping-migration.)
This commit is contained in:
david
2007-08-27 23:58:23 +00:00
parent 04428edd29
commit 302547375b
9 changed files with 1438 additions and 356 deletions

27
nmap.cc
View File

@@ -470,7 +470,7 @@ int nmap_main(int argc, char *argv[]) {
short quashargv = 0;
char **host_exp_group;
char *idleProxy = NULL; /* The idle host used to "Proxy" an Idlescan */
int num_host_exp_groups = 0;
int num_host_exp_groups;
char *machinefilename = NULL, *kiddiefilename = NULL,
*normalfilename = NULL, *xmlfilename = NULL;
HostGroupState *hstate = NULL;
@@ -1480,10 +1480,6 @@ int nmap_main(int argc, char *argv[]) {
if (ports->prot_count)
shortfry(ports->prots, ports->prot_count);
}
/* Time to create a hostgroup state object filled with all the requested
machines */
host_exp_group = (char **) safe_malloc(o.ping_group_sz * sizeof(char *));
/* lets load our exclude list */
if ((NULL != excludefd) || (NULL != exclude_spec)) {
@@ -1498,17 +1494,6 @@ int nmap_main(int argc, char *argv[]) {
free(exclude_spec);
}
while(num_host_exp_groups < o.ping_group_sz &&
(host_spec = grab_next_host_spec(inputfd, argc, fakeargv))) {
host_exp_group[num_host_exp_groups++] = strdup(host_spec);
// For purposes of random scan
if (o.max_ips_to_scan && o.max_ips_to_scan <= o.numhosts_scanned + num_host_exp_groups)
break;
}
// if (num_host_exp_groups == 0)
// fatal("No target machines/networks specified!");
#ifndef NOLUA
if(o.scriptupdatedb) {
script_updatedb();
@@ -1516,6 +1501,12 @@ int nmap_main(int argc, char *argv[]) {
o.max_ips_to_scan = o.numhosts_scanned;
}
#endif
/* Time to create a hostgroup state object filled with all the requested
machines. The list is initially empty. It is refilled inside the loop
whenever it is empty. */
host_exp_group = (char **) safe_malloc(o.ping_group_sz * sizeof(char *));
num_host_exp_groups = 0;
hstate = new HostGroupState(o.ping_group_sz, o.randomize_hosts,
host_exp_group, num_host_exp_groups);
@@ -1524,7 +1515,7 @@ int nmap_main(int argc, char *argv[]) {
ideal_scan_group_sz = determineScanGroupSize(o.numhosts_scanned, ports);
while(Targets.size() < ideal_scan_group_sz) {
o.current_scantype = HOST_DISCOVERY;
currenths = nexthost(hstate, exclude_group, ports, &(o.pingtype));
currenths = nexthost(hstate, exclude_group, ports, o.pingtype);
if (!currenths) {
/* Try to refill with any remaining expressions */
/* First free the old ones */
@@ -1545,7 +1536,7 @@ int nmap_main(int argc, char *argv[]) {
host_exp_group, num_host_exp_groups);
/* Try one last time -- with new expressions */
currenths = nexthost(hstate, exclude_group, ports, &(o.pingtype));
currenths = nexthost(hstate, exclude_group, ports, o.pingtype);
if (!currenths)
break;
}