|
|
62a8fc |
diff -up nmap-5.51/nmap_dns.cc.tcpdns nmap-5.51/nmap_dns.cc
|
|
|
62a8fc |
--- a/nmap_dns.cc 2011-01-21 01:04:16.000000000 +0100
|
|
|
62a8fc |
+++ b/nmap_dns.cc 2016-10-26 11:04:49.057723356 +0200
|
|
|
62a8fc |
@@ -677,9 +677,9 @@ static void read_evt_handler(nsock_pool
|
|
|
62a8fc |
|
|
|
62a8fc |
packet_id = buf[1] + (buf[0] << 8);
|
|
|
62a8fc |
|
|
|
62a8fc |
- // Check that this is a response, standard query, and that no truncation was performed
|
|
|
62a8fc |
+ // Check that this is a response, standard query
|
|
|
62a8fc |
// 0xFA == 11111010 (we're not concerned with AA or RD bits)
|
|
|
62a8fc |
- if ((buf[2] & 0xFA) != 0x80) return;
|
|
|
62a8fc |
+ if ((buf[2] & 0xF8) != 0x80) return;
|
|
|
62a8fc |
|
|
|
62a8fc |
// Check that the zero field is all zeros and there is no error condition.
|
|
|
62a8fc |
// We don't care if recursion is available or not since we might be querying
|
|
|
62a8fc |
@@ -715,7 +715,8 @@ static void read_evt_handler(nsock_pool
|
|
|
62a8fc |
return;
|
|
|
62a8fc |
}
|
|
|
62a8fc |
|
|
|
62a8fc |
- if (queries <= 0 || answers <= 0) return;
|
|
|
62a8fc |
+ bool processing_successful = false;
|
|
|
62a8fc |
+// if (queries <= 0 || answers <= 0) return;
|
|
|
62a8fc |
|
|
|
62a8fc |
curbuf = 12;
|
|
|
62a8fc |
|
|
|
62a8fc |
@@ -732,7 +733,7 @@ static void read_evt_handler(nsock_pool
|
|
|
62a8fc |
|
|
|
62a8fc |
// We're now at the ANSWER section
|
|
|
62a8fc |
|
|
|
62a8fc |
- for (i=0; i
|
|
|
62a8fc |
+ for (i=0; i
|
|
|
62a8fc |
curbuf = advance_past_dns_name(buf, buflen, curbuf, &nameloc);
|
|
|
62a8fc |
if (curbuf == -1) return;
|
|
|
62a8fc |
|
|
|
62a8fc |
@@ -758,7 +759,7 @@ static void read_evt_handler(nsock_pool
|
|
|
62a8fc |
|
|
|
62a8fc |
if (encoded_name_to_normal(buf+nameloc, outbuf, sizeof(outbuf)) == -1) return;
|
|
|
62a8fc |
|
|
|
62a8fc |
- if (process_result(ia.s_addr, outbuf, ACTION_FINISHED, packet_id)) {
|
|
|
62a8fc |
+ if ((processing_successful = process_result(ia.s_addr, outbuf, ACTION_FINISHED, packet_id))) {
|
|
|
62a8fc |
if (o.debugging >= TRACE_DEBUG_LEVEL) log_write(LOG_STDOUT, "mass_rdns: OK MATCHED <%s> to <%s>\n", inet_ntoa(ia), outbuf);
|
|
|
62a8fc |
output_summary();
|
|
|
62a8fc |
stat_ok++;
|
|
|
62a8fc |
@@ -771,15 +772,26 @@ static void read_evt_handler(nsock_pool
|
|
|
62a8fc |
if (ia.s_addr == 0) return;
|
|
|
62a8fc |
|
|
|
62a8fc |
if (o.debugging >= TRACE_DEBUG_LEVEL) log_write(LOG_STDOUT, "mass_rdns: CNAME found for <%s>\n", inet_ntoa(ia));
|
|
|
62a8fc |
- process_result(ia.s_addr, NULL, ACTION_CNAME_LIST, packet_id);
|
|
|
62a8fc |
+ processing_successful = process_result(ia.s_addr, NULL, ACTION_SYSTEM_RESOLVE, packet_id);
|
|
|
62a8fc |
} else {
|
|
|
62a8fc |
if (rdlen < 0 || rdlen + curbuf >= buflen) return;
|
|
|
62a8fc |
curbuf += rdlen;
|
|
|
62a8fc |
}
|
|
|
62a8fc |
|
|
|
62a8fc |
- if (curbuf >= buflen) return;
|
|
|
62a8fc |
+ if (curbuf >= buflen) break;//return;
|
|
|
62a8fc |
}
|
|
|
62a8fc |
|
|
|
62a8fc |
+ if (!processing_successful) {
|
|
|
62a8fc |
+ if ((buf[2] & 0x02)) { //truncated
|
|
|
62a8fc |
+ u32 discard = 0;
|
|
|
62a8fc |
+ process_result(discard, NULL, ACTION_SYSTEM_RESOLVE, packet_id);
|
|
|
62a8fc |
+ }
|
|
|
62a8fc |
+ else {
|
|
|
62a8fc |
+ if (o.debugging >= TRACE_DEBUG_LEVEL) {
|
|
|
62a8fc |
+ log_write(LOG_STDOUT, "mass_rdns: Unable to process the response\n");
|
|
|
62a8fc |
+ }
|
|
|
62a8fc |
+ }
|
|
|
62a8fc |
+ }
|
|
|
62a8fc |
}
|
|
|
62a8fc |
|
|
|
62a8fc |
|
|
|
62a8fc |
@@ -1225,20 +1237,20 @@ static void nmap_mass_rdns_core(Target *
|
|
|
62a8fc |
|
|
|
62a8fc |
nsp_delete(dnspool);
|
|
|
62a8fc |
|
|
|
62a8fc |
- if (cname_reqs.size() && o.debugging)
|
|
|
62a8fc |
- log_write(LOG_STDOUT, "Performing system-dns for %d domain names that use CNAMEs\n", (int) cname_reqs.size());
|
|
|
62a8fc |
+ if (deferred_reqs.size() && o.debugging)
|
|
|
62a8fc |
+ log_write(LOG_STDOUT, "Performing system-dns for %d domain names that were deferred\n", (int) deferred_reqs.size());
|
|
|
62a8fc |
|
|
|
62a8fc |
- if (cname_reqs.size()) {
|
|
|
62a8fc |
- Snprintf(spmobuf, sizeof(spmobuf), "System CNAME DNS resolution of %u host%s.", (unsigned) cname_reqs.size(), cname_reqs.size()-1 ? "s" : "");
|
|
|
62a8fc |
+ if (deferred_reqs.size()) {
|
|
|
62a8fc |
+ Snprintf(spmobuf, sizeof(spmobuf), "System DNS resolution of %u host%s.", (unsigned) deferred_reqs.size(), deferred_reqs.size()-1 ? "s" : "");
|
|
|
62a8fc |
SPM = new ScanProgressMeter(spmobuf);
|
|
|
62a8fc |
|
|
|
62a8fc |
- for(i=0, reqI = cname_reqs.begin(); reqI != cname_reqs.end(); reqI++, i++) {
|
|
|
62a8fc |
+ for(i=0, reqI = deferred_reqs.begin(); reqI != deferred_reqs.end(); reqI++, i++) {
|
|
|
62a8fc |
struct sockaddr_storage ss;
|
|
|
62a8fc |
size_t sslen;
|
|
|
62a8fc |
char hostname[MAXHOSTNAMELEN + 1] = "";
|
|
|
62a8fc |
|
|
|
62a8fc |
if (keyWasPressed())
|
|
|
62a8fc |
- SPM->printStats((double) i / cname_reqs.size(), NULL);
|
|
|
62a8fc |
+ SPM->printStats((double) i / deferred_reqs.size(), NULL);
|
|
|
62a8fc |
|
|
|
62a8fc |
tpreq = *reqI;
|
|
|
62a8fc |
|
|
|
62a8fc |
diff --git a/nmap_dns.cc b/nmap_dns.cc
|
|
|
62a8fc |
index 9a72336..e01230c 100644
|
|
|
62a8fc |
--- a/nmap_dns.cc
|
|
|
62a8fc |
+++ b/nmap_dns.cc
|
|
|
62a8fc |
@@ -309,7 +309,7 @@ struct host_elem {
|
|
|
62a8fc |
|
|
|
62a8fc |
static std::list<dns_server> servs;
|
|
|
62a8fc |
static std::list<request *> new_reqs;
|
|
|
62a8fc |
-static std::list<request *> cname_reqs;
|
|
|
62a8fc |
+static std::list<request *> deferred_reqs;
|
|
|
62a8fc |
static int total_reqs;
|
|
|
62a8fc |
static nsock_pool dnspool=NULL;
|
|
|
62a8fc |
|
|
|
62a8fc |
diff --git a/nmap_dns.cc b/nmap_dns.cc
|
|
|
62a8fc |
index e01230c..540d39d 100644
|
|
|
62a8fc |
--- a/nmap_dns.cc
|
|
|
62a8fc |
+++ b/nmap_dns.cc
|
|
|
62a8fc |
@@ -327,12 +327,13 @@ static ScanProgressMeter *SPM;
|
|
|
62a8fc |
|
|
|
62a8fc |
//------------------- Prototypes and macros ---------------------
|
|
|
62a8fc |
|
|
|
62a8fc |
+static void read_evt_handler(nsock_pool, nsock_event, void *);
|
|
|
62a8fc |
static void put_dns_packet_on_wire(request *req);
|
|
|
62a8fc |
static const char *lookup_etchosts(u32 ip);
|
|
|
62a8fc |
static void addto_etchosts(u32 ip, const char *hname);
|
|
|
62a8fc |
|
|
|
62a8fc |
#define ACTION_FINISHED 0
|
|
|
62a8fc |
-#define ACTION_CNAME_LIST 1
|
|
|
62a8fc |
+#define ACTION_SYSTEM_RESOLVE 1
|
|
|
62a8fc |
#define ACTION_TIMEOUT 2
|
|
|
62a8fc |
|
|
|
62a8fc |
//------------------- Misc code ---------------------
|
|
|
62a8fc |
diff --git a/nmap_dns.cc b/nmap_dns.cc
|
|
|
62a8fc |
index 540d39d..e0c6f6c 100644
|
|
|
62a8fc |
--- a/nmap_dns.cc
|
|
|
62a8fc |
+++ b/nmap_dns.cc
|
|
|
62a8fc |
@@ -1240,7 +1240,7 @@ static void nmap_mass_rdns_core(Target **targets, int num_targets) {
|
|
|
62a8fc |
|
|
|
62a8fc |
connect_dns_servers();
|
|
|
62a8fc |
|
|
|
62a8fc |
- cname_reqs.clear();
|
|
|
62a8fc |
+ deferred_reqs.clear();
|
|
|
62a8fc |
|
|
|
62a8fc |
read_timeout_index = MIN(sizeof(read_timeouts)/sizeof(read_timeouts[0]), servs.size()) - 1;
|
|
|
62a8fc |
|
|
|
62a8fc |
diff --git a/nmap_dns.cc b/nmap_dns.cc
|
|
|
62a8fc |
index 9363614..815b3a4 100644
|
|
|
62a8fc |
--- a/nmap_dns.cc
|
|
|
62a8fc |
+++ b/nmap_dns.cc
|
|
|
62a8fc |
@@ -558,7 +558,7 @@ static int process_result(u32 ia, char *result, int action, u16 id) {
|
|
|
62a8fc |
if (ia != 0 && tpreq->targ->v4host().s_addr != ia)
|
|
|
62a8fc |
continue;
|
|
|
62a8fc |
|
|
|
62a8fc |
- if (action == ACTION_CNAME_LIST || action == ACTION_FINISHED) {
|
|
|
62a8fc |
+ if (action == ACTION_SYSTEM_RESOLVE || action == ACTION_FINISHED) {
|
|
|
62a8fc |
servI->capacity += CAPACITY_UP_STEP;
|
|
|
62a8fc |
check_capacities(&*servI);
|
|
|
62a8fc |
|
|
|
62a8fc |
@@ -572,7 +572,7 @@ static int process_result(u32 ia, char *result, int action, u16 id) {
|
|
|
62a8fc |
|
|
|
62a8fc |
total_reqs--;
|
|
|
62a8fc |
|
|
|
62a8fc |
- if (action == ACTION_CNAME_LIST) cname_reqs.push_back(tpreq);
|
|
|
62a8fc |
+ if (action == ACTION_SYSTEM_RESOLVE) deferred_reqs.push_back(tpreq);
|
|
|
62a8fc |
if (action == ACTION_FINISHED) delete tpreq;
|
|
|
62a8fc |
} else {
|
|
|
62a8fc |
memcpy(&tpreq->timeout, nsock_gettimeofday(), sizeof(struct timeval));
|
|
|
62a8fc |
diff --git a/nmap_dns.cc b/nmap_dns.cc
|
|
|
62a8fc |
index 815b3a4..f00ac18 100644
|
|
|
62a8fc |
--- a/nmap_dns.cc
|
|
|
62a8fc |
+++ b/nmap_dns.cc
|
|
|
62a8fc |
@@ -1302,7 +1302,7 @@ static void nmap_mass_rdns_core(Target **targets, int num_targets) {
|
|
|
62a8fc |
delete SPM;
|
|
|
62a8fc |
}
|
|
|
62a8fc |
|
|
|
62a8fc |
- cname_reqs.clear();
|
|
|
62a8fc |
+ deferred_reqs.clear();
|
|
|
62a8fc |
|
|
|
62a8fc |
}
|
|
|
62a8fc |
|