: Added Files:
[hdw-repos/packages.git] / demian / nmap / nmap-3.10ALPHA.patch
1 this will allow the deep use of the -e option and some other
2 nice features
3     demian
4
5
6 diff -r -u nmap-3.10ALPHA3/NmapOps.h nmap-3.10ALPHA3IX/NmapOps.h
7 --- nmap-3.10ALPHA3/NmapOps.h   2002-09-16 04:54:43.000000000 +0200
8 +++ nmap-3.10ALPHA3IX/NmapOps.h 2002-11-10 11:24:26.000000000 +0100
9 @@ -80,6 +80,7 @@
10    // setPacketTrace(false) has been called
11    void setPacketTrace(bool pt) { pTrace = pt;  }
12    int verbose;
13 +  int count;
14    int randomize_hosts;
15    int spoofsource; /* -S used */
16    char device[64];
17 diff -r -u nmap-3.10ALPHA3/nmap.cc nmap-3.10ALPHA3IX/nmap.cc
18 --- nmap-3.10ALPHA3/nmap.cc     2002-09-16 05:00:21.000000000 +0200
19 +++ nmap-3.10ALPHA3IX/nmap.cc   2002-11-10 10:07:53.000000000 +0100
20 @@ -172,6 +172,7 @@
21    {
22      {"version", no_argument, 0, 'V'},
23      {"verbose", no_argument, 0, 'v'},
24 +    {"count", no_argument, 0, 'c'},
25      {"debug", optional_argument, 0, 'd'},
26      {"help", no_argument, 0, 'h'},
27      {"max_parallelism", required_argument, 0, 'M'},
28 @@ -571,6 +572,7 @@
29        exit(0);
30        break;
31      case 'v': o.verbose++; break;
32 +    case 'c': o.count=1; break;
33      }
34    }
35  
36 @@ -1208,6 +1210,7 @@
37          "  -p <range> ports to scan.  Example range: '1-1024,1080,6666,31337'\n"
38          "  -F Only scans ports listed in nmap-services\n"
39          "  -v Verbose. Its use is recommended.  Use twice for greater effect.\n"
40 +        "  -c Counting stats\n"
41          "  -P0 Don't ping hosts (needed to scan www.microsoft.com and others)\n"
42          "* -Ddecoy_host1,decoy2[,...] Hide scan using many decoys\n"
43           "  -6 scans via IPv6 rather than IPv4\n"
44 diff -r -u nmap-3.10ALPHA3/scan_engine.cc nmap-3.10ALPHA3IX/scan_engine.cc
45 --- nmap-3.10ALPHA3/scan_engine.cc      2002-09-16 06:39:58.000000000 +0200
46 +++ nmap-3.10ALPHA3IX/scan_engine.cc    2002-11-10 15:31:11.000000000 +0100
47 @@ -536,6 +536,8 @@
48    struct scanstats ss;
49    int rawsd = -1;
50    int scanflags = 0;
51 +  int itimes = 0;
52 +  int iresends = 0;
53    int victim;
54    int senddelay = 0;
55    pcap_t *pd = NULL;
56 @@ -545,6 +547,7 @@
57    int  res;
58    int connecterror = 0;
59    int starttime;
60 +  int lastcheckedtime;
61    struct sockaddr_storage sock;
62    struct sockaddr_in *sin = (struct sockaddr_in *) &sock;
63  #if HAVE_IPV6
64 @@ -700,6 +703,7 @@
65    }
66  
67    starttime = time(NULL);
68 +  lastcheckedtime = 0;
69  
70    if (scantype != SYN_SCAN)
71      ack_number = get_random_uint();
72 @@ -912,6 +916,15 @@
73             current->state = PORT_TESTING;
74             current->trynum = 0;
75             /*  if (!testinglist) testinglist = current; */
76 +            if (o.count) {
77 +              itimes++;
78 +              if ( time(NULL) != lastcheckedtime ) {
79 +                lastcheckedtime = time(NULL);
80 +                log_write(LOG_STDOUT, "Tried: %5d (%d resends)      \nP/S: %8.2f ETS: %7.0f \e[28D\e[A", itimes , iresends ,  (double) ( itimes ) / ( 1 + lastcheckedtime - starttime ) , (double) ( numports - itimes + iresends ) / ( (double) itimes / ( 1 + lastcheckedtime - starttime ) ) );
81 +                log_flush(LOG_STDOUT);
82 +              }
83 +            }
84 +
85             ss.numqueries_outstanding++;
86             gettimeofday(&current->sent[0], NULL);
87             if ((scantype == SYN_SCAN) || (scantype == WINDOW_SCAN) || 
88 @@ -1049,6 +1062,7 @@
89           current->state = PORT_FRESH;
90           current->trynum = 0;
91           current->sd[0] = current->sd[1] = current->sd[2] = -1;
92 +          iresends++;
93           if (o.debugging) { 
94             log_write(LOG_STDOUT, "Preparing for retry, nonresponsive port %lu noted\n", current->portno); 
95           }
96 @@ -1245,6 +1259,9 @@
97    int tries = 0;
98    int tmp = 0;
99    int starttime;
100 +  int lastcheckedtime;
101 +  int itimes = 0;
102 +  int iresends = 0;
103    u16 newport;
104    int newstate = 999; /* This ought to break something if used illegally */
105    struct portinfo *scan, *openlist, *current, *testinglist, *next;
106 @@ -1334,6 +1351,7 @@
107      fatal("Unknown scan type for super_scan"); }
108  
109    starttime = time(NULL);
110 +  lastcheckedtime = 0;
111  
112    if (o.debugging || o.verbose)
113      log_write(LOG_STDOUT, "Initiating %s against %s\n", scantype2str(scantype), target->NameIP(hostname, sizeof(hostname)));
114 @@ -1416,6 +1434,14 @@
115             /* lets send a packet! */
116             current->state = PORT_TESTING;
117             /*  if (!testinglist) testinglist = current; */
118 +            if (o.count) {
119 +              itimes++;
120 +              if ( time(NULL) != lastcheckedtime ) {
121 +                lastcheckedtime = time(NULL);
122 +                log_write(LOG_STDOUT, "Tried: %5d (%d resends)      \nP/S: %8.2f ETS: %7.0f \e[28D\e[A", itimes , iresends ,  (double) itimes / ( 1 + lastcheckedtime - starttime ) , (double) ( numports - itimes + iresends ) / ( (double) ( itimes + iresends ) / ( 1 + lastcheckedtime - starttime ) ) );
123 +                log_flush(LOG_STDOUT);
124 +              }
125 +            }
126             numqueries_outstanding++;
127             gettimeofday(&current->sent[0], NULL);
128             if (o.fragscan)
129 @@ -1637,6 +1663,7 @@
130      for(current = openlist; current; current = (current->next >= 0)? &scan[current->next] : NULL) {
131        current->state = PORT_FRESH;
132        current->trynum = 0;
133 +      iresends++;
134        if (o.debugging) { 
135         log_write(LOG_STDOUT, "Preparing for retry, open port %lu noted\n", current->portno); 
136        }