mirror of
https://github.com/nmap/nmap.git
synced 2026-01-20 13:19:01 +00:00
Warn about deprecated option names with -v
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# Nmap Changelog ($Id$); -*-text-*-
|
||||
|
||||
o Output a warning when deprecated options are used, and suggest the preferred
|
||||
option. Currently deprecated: -i -o -m -sP -P0 -PN -oM -sR. The warning is
|
||||
only visible with -v. [Daniel Miller]
|
||||
|
||||
o [NSE] Added script http-ls. Parses web server directory index pages with
|
||||
optional recursion. [Pierre Lalet]
|
||||
|
||||
|
||||
38
nmap.cc
38
nmap.cc
@@ -180,6 +180,10 @@
|
||||
#endif
|
||||
#define DNET_VERSION VERSION
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
/* global options */
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
@@ -514,6 +518,14 @@ public:
|
||||
char *exclude_spec, *exclude_file;
|
||||
char *spoofSource;
|
||||
const char *spoofmac;
|
||||
std::vector<std::string> verbose_out;
|
||||
|
||||
void warn_deprecated (const char *given, const char *replacement) {
|
||||
std::ostringstream os;
|
||||
os << "Warning: The -" << given << " option is deprecated. Please use -" << replacement;
|
||||
this->verbose_out.push_back(os.str());
|
||||
}
|
||||
|
||||
} delayed_options;
|
||||
|
||||
struct tm *local_time;
|
||||
@@ -906,6 +918,8 @@ void parse_options(int argc, char **argv) {
|
||||
|| strcmp(long_options[option_index].name, "oM") == 0) {
|
||||
test_file_name(optarg, long_options[option_index].name);
|
||||
delayed_options.machinefilename = logfilename(optarg, local_time);
|
||||
if (long_options[option_index].name[1] == 'M')
|
||||
delayed_options.warn_deprecated("oM", "oG");
|
||||
} else if (strcmp(long_options[option_index].name, "oS") == 0) {
|
||||
test_file_name(optarg, long_options[option_index].name);
|
||||
delayed_options.kiddiefilename = logfilename(optarg, local_time);
|
||||
@@ -1115,6 +1129,7 @@ void parse_options(int argc, char **argv) {
|
||||
break;
|
||||
// o.identscan++; break;
|
||||
case 'i':
|
||||
delayed_options.warn_deprecated("i", "iL");
|
||||
if (o.inputfd) {
|
||||
fatal("Only one input filename allowed");
|
||||
}
|
||||
@@ -1135,6 +1150,7 @@ void parse_options(int argc, char **argv) {
|
||||
error("Warning: Your max-parallelism (-M) option is extraordinarily high, which can hurt reliability");
|
||||
break;
|
||||
case 'm':
|
||||
delayed_options.warn_deprecated("m", "oG");
|
||||
test_file_name(optarg, "oG");
|
||||
delayed_options.machinefilename = logfilename(optarg, local_time);
|
||||
break;
|
||||
@@ -1150,7 +1166,8 @@ void parse_options(int argc, char **argv) {
|
||||
fatal("Unknown argument to -O.");
|
||||
break;
|
||||
case 'o':
|
||||
test_file_name(optarg, "oN");
|
||||
delayed_options.warn_deprecated("o", "oN");
|
||||
test_file_name(optarg, "o");
|
||||
delayed_options.normalfilename = logfilename(optarg, local_time);
|
||||
break;
|
||||
case 'P':
|
||||
@@ -1160,8 +1177,14 @@ void parse_options(int argc, char **argv) {
|
||||
o.pingtype |= PINGTYPE_ICMP_MASK;
|
||||
else if (*optarg == 'P')
|
||||
o.pingtype |= PINGTYPE_ICMP_TS;
|
||||
else if (*optarg == 'n' || *optarg == '0' || *optarg == 'N' || *optarg == 'D')
|
||||
else if (*optarg == 'n' || *optarg == '0' || *optarg == 'N' || *optarg == 'D') {
|
||||
if (*optarg != 'n') {
|
||||
char buf[4];
|
||||
Snprintf(buf, 3, "P%c", *optarg);
|
||||
delayed_options.warn_deprecated(buf, "Pn");
|
||||
}
|
||||
o.pingtype |= PINGTYPE_NONE;
|
||||
}
|
||||
else if (*optarg == 'R')
|
||||
o.pingtype |= PINGTYPE_ARP;
|
||||
else if (*optarg == 'S') {
|
||||
@@ -1267,8 +1290,9 @@ void parse_options(int argc, char **argv) {
|
||||
p = optarg;
|
||||
while (*p) {
|
||||
switch (*p) {
|
||||
case 'n':
|
||||
case 'P':
|
||||
delayed_options.warn_deprecated("sP", "sn");
|
||||
case 'n':
|
||||
o.noportscan = 1;
|
||||
break;
|
||||
case 'A':
|
||||
@@ -1302,6 +1326,7 @@ void parse_options(int argc, char **argv) {
|
||||
/* Alias for -sV since March 2011. */
|
||||
case 'R':
|
||||
o.servicescan = 1;
|
||||
delayed_options.warn_deprecated("sR", "sV");
|
||||
error("WARNING: -sR is now an alias for -sV and activates version detection as well as RPC scan.");
|
||||
break;
|
||||
case 'S':
|
||||
@@ -1400,6 +1425,13 @@ void apply_delayed_options() {
|
||||
struct sockaddr_storage ss;
|
||||
size_t sslen;
|
||||
|
||||
if (o.verbose > 0) {
|
||||
for (std::vector<std::string>::iterator it = delayed_options.verbose_out.begin(); it != delayed_options.verbose_out.end(); ++it) {
|
||||
error("%s", it->c_str());
|
||||
}
|
||||
}
|
||||
delayed_options.verbose_out.clear();
|
||||
|
||||
if (o.spoofsource) {
|
||||
int rc = resolve(delayed_options.spoofSource, 0, &ss, &sslen, o.af());
|
||||
if (rc != 0) {
|
||||
|
||||
Reference in New Issue
Block a user