mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
merge soc07 r4871:4884 and r4888 - renaming __FUNCTION__ to __func__ and changing hardcoded func names to __func__
This commit is contained in:
@@ -224,7 +224,7 @@ static struct MAC_entry *findMACEntry(int prefix) {
|
|||||||
const char *MACPrefix2Corp(const u8 *prefix) {
|
const char *MACPrefix2Corp(const u8 *prefix) {
|
||||||
struct MAC_entry *ent;
|
struct MAC_entry *ent;
|
||||||
|
|
||||||
if (!prefix) fatal("MACPrefix2Corp called with a NULL prefix");
|
if (!prefix) fatal("%s called with a NULL prefix", __func__);
|
||||||
mac_prefix_init();
|
mac_prefix_init();
|
||||||
|
|
||||||
ent = findMACEntry(MacCharPrefix2Key(prefix));
|
ent = findMACEntry(MacCharPrefix2Key(prefix));
|
||||||
@@ -238,8 +238,8 @@ const char *MACPrefix2Corp(const u8 *prefix) {
|
|||||||
is not particularly efficient and so should be rewriteen if it is
|
is not particularly efficient and so should be rewriteen if it is
|
||||||
called often */
|
called often */
|
||||||
bool MACCorp2Prefix(const char *vendorstr, u8 *mac_data) {
|
bool MACCorp2Prefix(const char *vendorstr, u8 *mac_data) {
|
||||||
if (!vendorstr) fatal("%s: vendorstr is NULL", __FUNCTION__);
|
if (!vendorstr) fatal("%s: vendorstr is NULL", __func__);
|
||||||
if (!mac_data) fatal("%s: mac_data is NULL", __FUNCTION__);
|
if (!mac_data) fatal("%s: mac_data is NULL", __func__);
|
||||||
mac_prefix_init();
|
mac_prefix_init();
|
||||||
|
|
||||||
for(int i = 0; i < MacTable.table_capacity; i++ ) {
|
for(int i = 0; i < MacTable.table_capacity; i++ ) {
|
||||||
|
|||||||
10
NmapOps.cc
10
NmapOps.cc
@@ -486,13 +486,13 @@ void NmapOps::ValidateOptions() {
|
|||||||
|
|
||||||
void NmapOps::setMaxOSTries(int mot) {
|
void NmapOps::setMaxOSTries(int mot) {
|
||||||
if (mot <= 0)
|
if (mot <= 0)
|
||||||
fatal("NmapOps::setMaxOSTries(): value must be at least 1");
|
fatal("%s: value must be at least 1", __func__);
|
||||||
max_os_tries = mot;
|
max_os_tries = mot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NmapOps::setMaxRttTimeout(int rtt)
|
void NmapOps::setMaxRttTimeout(int rtt)
|
||||||
{
|
{
|
||||||
if (rtt <= 0) fatal("NmapOps::setMaxRttTimeout(): maximum round trip time must be greater than 0");
|
if (rtt <= 0) fatal("%s: maximum round trip time must be greater than 0", __func__);
|
||||||
max_rtt_timeout = rtt;
|
max_rtt_timeout = rtt;
|
||||||
if (rtt < min_rtt_timeout) min_rtt_timeout = rtt;
|
if (rtt < min_rtt_timeout) min_rtt_timeout = rtt;
|
||||||
if (rtt < initial_rtt_timeout) initial_rtt_timeout = rtt;
|
if (rtt < initial_rtt_timeout) initial_rtt_timeout = rtt;
|
||||||
@@ -500,7 +500,7 @@ void NmapOps::setMaxRttTimeout(int rtt)
|
|||||||
|
|
||||||
void NmapOps::setMinRttTimeout(int rtt)
|
void NmapOps::setMinRttTimeout(int rtt)
|
||||||
{
|
{
|
||||||
if (rtt < 0) fatal("NmapOps::setMinRttTimeout(): minimum round trip time must be at least 0");
|
if (rtt < 0) fatal("%s: minimum round trip time must be at least 0", __func__);
|
||||||
min_rtt_timeout = rtt;
|
min_rtt_timeout = rtt;
|
||||||
if (rtt > max_rtt_timeout) max_rtt_timeout = rtt;
|
if (rtt > max_rtt_timeout) max_rtt_timeout = rtt;
|
||||||
if (rtt > initial_rtt_timeout) initial_rtt_timeout = rtt;
|
if (rtt > initial_rtt_timeout) initial_rtt_timeout = rtt;
|
||||||
@@ -508,7 +508,7 @@ void NmapOps::setMinRttTimeout(int rtt)
|
|||||||
|
|
||||||
void NmapOps::setInitialRttTimeout(int rtt)
|
void NmapOps::setInitialRttTimeout(int rtt)
|
||||||
{
|
{
|
||||||
if (rtt <= 0) fatal("NmapOps::setInitialRttTimeout(): initial round trip time must be greater than 0");
|
if (rtt <= 0) fatal("%s: initial round trip time must be greater than 0", __func__);
|
||||||
initial_rtt_timeout = rtt;
|
initial_rtt_timeout = rtt;
|
||||||
if (rtt > max_rtt_timeout) max_rtt_timeout = rtt;
|
if (rtt > max_rtt_timeout) max_rtt_timeout = rtt;
|
||||||
if (rtt < min_rtt_timeout) min_rtt_timeout = rtt;
|
if (rtt < min_rtt_timeout) min_rtt_timeout = rtt;
|
||||||
@@ -517,7 +517,7 @@ void NmapOps::setInitialRttTimeout(int rtt)
|
|||||||
void NmapOps::setMaxRetransmissions(int max_retransmit)
|
void NmapOps::setMaxRetransmissions(int max_retransmit)
|
||||||
{
|
{
|
||||||
if (max_retransmit < 0)
|
if (max_retransmit < 0)
|
||||||
fatal("NmapOps::setMaxRetransmissions(): must be positive");
|
fatal("%s: must be positive", __func__);
|
||||||
max_retransmissions = max_retransmit;
|
max_retransmissions = max_retransmit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ void NmapOutputTable::addItemFormatted(unsigned int row,
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (res > sizeof(buf))
|
if (res > sizeof(buf))
|
||||||
fatal("NmapOutputTable only supports adding up to 4096 to a cell via addItemFormatString.");
|
fatal("NmapOutputTable only supports adding up to 4096 to a cell via %s.", __func__);
|
||||||
|
|
||||||
addItem(row, column, fullrow, true, buf, res);
|
addItem(row, column, fullrow, true, buf, res);
|
||||||
|
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ int TargetGroup::get_next_host(struct sockaddr_storage *ss, size_t *sslen) {
|
|||||||
if (currentaddr.s_addr <= endaddr.s_addr) {
|
if (currentaddr.s_addr <= endaddr.s_addr) {
|
||||||
sin->sin_addr.s_addr = htonl(currentaddr.s_addr++);
|
sin->sin_addr.s_addr = htonl(currentaddr.s_addr++);
|
||||||
} else {
|
} else {
|
||||||
error("Bogus target structure passed to TargetGroup::get_next_host");
|
error("Bogus target structure passed to %s", __func__);
|
||||||
ipsleft = 0;
|
ipsleft = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
23
configure.ac
23
configure.ac
@@ -85,6 +85,29 @@ if test "$nmap_gcc_major_version" -ge 4; then
|
|||||||
CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
|
CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for __func__)
|
||||||
|
AC_TRY_COMPILE([
|
||||||
|
#include <stdio.h>
|
||||||
|
],[printf ("%s", __func__);],
|
||||||
|
have_func=yes, have_func=no)
|
||||||
|
if test "x$have_func" = "xyes"; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
AC_MSG_CHECKING(for __FUNCTION__)
|
||||||
|
AC_TRY_COMPILE([
|
||||||
|
#include <stdio.h>
|
||||||
|
],[printf ("%s", __FUNCTION__);],
|
||||||
|
have_function=yes, have_function=no)
|
||||||
|
if test "x$have_function" = "xyes"; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(__func__, __FUNCTION__)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
AC_DEFINE(__func__, __FILE__)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
dnl AC_PROG_INSTALL
|
dnl AC_PROG_INSTALL
|
||||||
dnl AC_PATH_PROG(MAKEDEPEND, makedepend)
|
dnl AC_PATH_PROG(MAKEDEPEND, makedepend)
|
||||||
|
|
||||||
|
|||||||
32
idle_scan.cc
32
idle_scan.cc
@@ -371,17 +371,17 @@ static void initialize_idleproxy(struct idle_proxy_info *proxy, char *proxyName,
|
|||||||
if ((o.sendpref & PACKET_SEND_ETH) && proxy->host.ifType() == devt_ethernet) {
|
if ((o.sendpref & PACKET_SEND_ETH) && proxy->host.ifType() == devt_ethernet) {
|
||||||
if (!setTargetNextHopMAC(&proxy->host))
|
if (!setTargetNextHopMAC(&proxy->host))
|
||||||
fatal("%s: Failed to determine dst MAC address for Idle proxy",
|
fatal("%s: Failed to determine dst MAC address for Idle proxy",
|
||||||
__FUNCTION__);
|
__func__);
|
||||||
memcpy(proxy->eth.srcmac, proxy->host.SrcMACAddress(), 6);
|
memcpy(proxy->eth.srcmac, proxy->host.SrcMACAddress(), 6);
|
||||||
memcpy(proxy->eth.dstmac, proxy->host.NextHopMACAddress(), 6);
|
memcpy(proxy->eth.dstmac, proxy->host.NextHopMACAddress(), 6);
|
||||||
proxy->eth.ethsd = eth_open_cached(proxy->host.deviceName());
|
proxy->eth.ethsd = eth_open_cached(proxy->host.deviceName());
|
||||||
if (proxy->eth.ethsd == NULL)
|
if (proxy->eth.ethsd == NULL)
|
||||||
fatal("%s: Failed to open ethernet device (%s)", __FUNCTION__, proxy->host.deviceName());
|
fatal("%s: Failed to open ethernet device (%s)", __func__, proxy->host.deviceName());
|
||||||
proxy->rawsd = -1;
|
proxy->rawsd = -1;
|
||||||
proxy->ethptr = &proxy->eth;
|
proxy->ethptr = &proxy->eth;
|
||||||
} else {
|
} else {
|
||||||
if ((proxy->rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
if ((proxy->rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
||||||
pfatal("socket troubles in %s", __FUNCTION__);
|
pfatal("socket troubles in %s", __func__);
|
||||||
unblock_socket(proxy->rawsd);
|
unblock_socket(proxy->rawsd);
|
||||||
broadcast_socket(proxy->rawsd);
|
broadcast_socket(proxy->rawsd);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@@ -577,10 +577,10 @@ static void adjust_idle_timing(struct idle_proxy_info *proxy,
|
|||||||
|
|
||||||
if (o.debugging > 1)
|
if (o.debugging > 1)
|
||||||
log_write(LOG_STDOUT,
|
log_write(LOG_STDOUT,
|
||||||
"adjust_idle_timing: tested/true %d/%d -- old grpsz/delay: %f/%d ",
|
"%s: tested/true %d/%d -- old grpsz/delay: %f/%d ",
|
||||||
testcount, realcount, proxy->current_groupsz, proxy->senddelay);
|
__func__, testcount, realcount, proxy->current_groupsz, proxy->senddelay);
|
||||||
else if (o.debugging && testcount != realcount) {
|
else if (o.debugging && testcount != realcount) {
|
||||||
error("adjust_idle_timing: testcount: %d realcount: %d -- old grpsz/delay: %f/%d", testcount, realcount, proxy->current_groupsz, proxy->senddelay);
|
error("%s: testcount: %d realcount: %d -- old grpsz/delay: %f/%d", __func__, testcount, realcount, proxy->current_groupsz, proxy->senddelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testcount < realcount) {
|
if (testcount < realcount) {
|
||||||
@@ -672,12 +672,12 @@ static int idlescan_countopen2(struct idle_proxy_info *proxy,
|
|||||||
if (proxy->rawsd < 0) {
|
if (proxy->rawsd < 0) {
|
||||||
if (!setTargetNextHopMAC(target))
|
if (!setTargetNextHopMAC(target))
|
||||||
fatal("%s: Failed to determine dst MAC address for Idle proxy",
|
fatal("%s: Failed to determine dst MAC address for Idle proxy",
|
||||||
__FUNCTION__);
|
__func__);
|
||||||
memcpy(eth.srcmac, target->SrcMACAddress(), 6);
|
memcpy(eth.srcmac, target->SrcMACAddress(), 6);
|
||||||
memcpy(eth.dstmac, target->NextHopMACAddress(), 6);
|
memcpy(eth.dstmac, target->NextHopMACAddress(), 6);
|
||||||
eth.ethsd = eth_open_cached(target->deviceName());
|
eth.ethsd = eth_open_cached(target->deviceName());
|
||||||
if (eth.ethsd == NULL)
|
if (eth.ethsd == NULL)
|
||||||
fatal("%s: Failed to open ethernet device (%s)", __FUNCTION__, target->deviceName());
|
fatal("%s: Failed to open ethernet device (%s)", __func__, target->deviceName());
|
||||||
} else eth.ethsd = NULL;
|
} else eth.ethsd = NULL;
|
||||||
|
|
||||||
/* I start by sending out the SYN pr0bez */
|
/* I start by sending out the SYN pr0bez */
|
||||||
@@ -736,7 +736,7 @@ static int idlescan_countopen2(struct idle_proxy_info *proxy,
|
|||||||
rather have a negative number in that case */
|
rather have a negative number in that case */
|
||||||
if (ipid_dist < proxyprobes_sent) {
|
if (ipid_dist < proxyprobes_sent) {
|
||||||
if (o.debugging)
|
if (o.debugging)
|
||||||
error("idlescan_countopen2: Must have lost a sent packet because ipid_dist is %d while proxyprobes_sent is %d.", ipid_dist, proxyprobes_sent);
|
error("%s: Must have lost a sent packet because ipid_dist is %d while proxyprobes_sent is %d.", __func__, ipid_dist, proxyprobes_sent);
|
||||||
/* I no longer whack timing here ... done at bottom */
|
/* I no longer whack timing here ... done at bottom */
|
||||||
}
|
}
|
||||||
ipid_dist -= proxyprobes_sent;
|
ipid_dist -= proxyprobes_sent;
|
||||||
@@ -746,7 +746,7 @@ static int idlescan_countopen2(struct idle_proxy_info *proxy,
|
|||||||
} else if (ipid_dist < openports && ipid_dist >= 0) {
|
} else if (ipid_dist < openports && ipid_dist >= 0) {
|
||||||
/* Uh-oh. Perhaps I dropped a packet this time */
|
/* Uh-oh. Perhaps I dropped a packet this time */
|
||||||
if (o.debugging > 1) {
|
if (o.debugging > 1) {
|
||||||
error("idlescan_countopen2: Counted %d open ports in try #%d, but counted %d earlier ... probably a proxy_probe problem", ipid_dist, tries, openports);
|
error("%s: Counted %d open ports in try #%d, but counted %d earlier ... probably a proxy_probe problem", __func__, ipid_dist, tries, openports);
|
||||||
}
|
}
|
||||||
/* I no longer whack timing here ... done at bottom */
|
/* I no longer whack timing here ... done at bottom */
|
||||||
}
|
}
|
||||||
@@ -759,7 +759,7 @@ static int idlescan_countopen2(struct idle_proxy_info *proxy,
|
|||||||
if (proxyprobes_sent > proxyprobes_rcvd) {
|
if (proxyprobes_sent > proxyprobes_rcvd) {
|
||||||
/* Uh-oh. It looks like we lost at least one proxy probe packet */
|
/* Uh-oh. It looks like we lost at least one proxy probe packet */
|
||||||
if (o.debugging) {
|
if (o.debugging) {
|
||||||
error("idlescan_countopen2: Sent %d probes; only %d responses. Slowing scan.", proxyprobes_sent, proxyprobes_rcvd);
|
error("%s: Sent %d probes; only %d responses. Slowing scan.", __func__, proxyprobes_sent, proxyprobes_rcvd);
|
||||||
}
|
}
|
||||||
proxy->senddelay += 5000;
|
proxy->senddelay += 5000;
|
||||||
proxy->senddelay = MIN(proxy->max_senddelay, proxy->senddelay);
|
proxy->senddelay = MIN(proxy->max_senddelay, proxy->senddelay);
|
||||||
@@ -775,7 +775,7 @@ static int idlescan_countopen2(struct idle_proxy_info *proxy,
|
|||||||
|
|
||||||
if ((openports > 0) && (openports <= numports)) {
|
if ((openports > 0) && (openports <= numports)) {
|
||||||
/* Yeah, we found open ports... lets adjust the timing ... */
|
/* Yeah, we found open ports... lets adjust the timing ... */
|
||||||
if (o.debugging > 2) error("idlescan_countopen2: found %d open ports (out of %d) in %lu usecs", openports, numports, (unsigned long) TIMEVAL_SUBTRACT(latestchange, start));
|
if (o.debugging > 2) error("%s: found %d open ports (out of %d) in %lu usecs", __func__, openports, numports, (unsigned long) TIMEVAL_SUBTRACT(latestchange, start));
|
||||||
if (sent_time) *sent_time = start;
|
if (sent_time) *sent_time = start;
|
||||||
if (rcv_time) *rcv_time = latestchange;
|
if (rcv_time) *rcv_time = latestchange;
|
||||||
}
|
}
|
||||||
@@ -803,7 +803,7 @@ static int idlescan_countopen(struct idle_proxy_info *proxy,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (o.debugging) {
|
if (o.debugging) {
|
||||||
error("idlescan_countopen: In try #%d, counted %d open ports out of %d. Retrying", tries, openports, numports);
|
error("%s: In try #%d, counted %d open ports out of %d. Retrying", __func__, tries, openports, numports);
|
||||||
}
|
}
|
||||||
/* Sleep for a little while -- maybe proxy host had brief birst of
|
/* Sleep for a little while -- maybe proxy host had brief birst of
|
||||||
traffic or similar problem */
|
traffic or similar problem */
|
||||||
@@ -822,7 +822,7 @@ static int idlescan_countopen(struct idle_proxy_info *proxy,
|
|||||||
proxy->host.targetipstr());
|
proxy->host.targetipstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o.debugging > 2) error("idlescan_countopen: %d ports found open out of %d, starting with %hu", openports, numports, ports[0]);
|
if (o.debugging > 2) error("%s: %d ports found open out of %d, starting with %hu", __func__, openports, numports, ports[0]);
|
||||||
|
|
||||||
return openports;
|
return openports;
|
||||||
}
|
}
|
||||||
@@ -843,7 +843,7 @@ static int idle_treescan(struct idle_proxy_info *proxy, Target *target,
|
|||||||
/* Scan the first half of the range */
|
/* Scan the first half of the range */
|
||||||
|
|
||||||
if (o.debugging > 1) {
|
if (o.debugging > 1) {
|
||||||
error("idle_treescan: Called against %s with %d ports, starting with %hu. expectedopen: %d", target->targetipstr(), numports, ports[0], expectedopen);
|
error("%s: Called against %s with %d ports, starting with %hu. expectedopen: %d", __func__, target->targetipstr(), numports, ports[0], expectedopen);
|
||||||
error("IDLESCAN TIMING: grpsz: %.3f delay: %d srtt: %d rttvar: %d\n",
|
error("IDLESCAN TIMING: grpsz: %.3f delay: %d srtt: %d rttvar: %d\n",
|
||||||
proxy->current_groupsz, proxy->senddelay, target->to.srtt,
|
proxy->current_groupsz, proxy->senddelay, target->to.srtt,
|
||||||
target->to.rttvar);
|
target->to.rttvar);
|
||||||
@@ -985,7 +985,7 @@ void idle_scan(Target *target, u16 *portarray, int numports,
|
|||||||
if (!proxyName) fatal("Idlescan requires a proxy host");
|
if (!proxyName) fatal("Idlescan requires a proxy host");
|
||||||
|
|
||||||
if (*lastproxy && strcmp(proxyName, lastproxy))
|
if (*lastproxy && strcmp(proxyName, lastproxy))
|
||||||
fatal("idle_scan(): You are not allowed to change proxies midstream. Sorry");
|
fatal("%s: You are not allowed to change proxies midstream. Sorry", __func__);
|
||||||
assert(target);
|
assert(target);
|
||||||
|
|
||||||
if (target->timedOut(NULL))
|
if (target->timedOut(NULL))
|
||||||
|
|||||||
@@ -669,9 +669,9 @@ static void read_evt_handler(nsock_pool nsp, nsock_event evt, void *nothing) {
|
|||||||
|
|
||||||
if (nse_type(evt) != NSE_TYPE_READ || nse_status(evt) != NSE_STATUS_SUCCESS) {
|
if (nse_type(evt) != NSE_TYPE_READ || nse_status(evt) != NSE_STATUS_SUCCESS) {
|
||||||
if (o.debugging)
|
if (o.debugging)
|
||||||
log_write(LOG_STDOUT, "mass_dns: warning: got a %s:%s in read_evt_handler()\n",
|
log_write(LOG_STDOUT, "mass_dns: warning: got a %s:%s in %s()\n",
|
||||||
nse_type2str(nse_type(evt)),
|
nse_type2str(nse_type(evt)),
|
||||||
nse_status2str(nse_status(evt)));
|
nse_status2str(nse_status(evt)), __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1203,7 +1203,7 @@ static void nmap_mass_rdns_core(Target **targets, int num_targets) {
|
|||||||
// And finally, do it!
|
// And finally, do it!
|
||||||
|
|
||||||
if ((dnspool = nsp_new(NULL)) == NULL)
|
if ((dnspool = nsp_new(NULL)) == NULL)
|
||||||
fatal("Unable to create nsock pool in nmap_mass_rdns_core()");
|
fatal("Unable to create nsock pool in %s()", __func__);
|
||||||
|
|
||||||
if ((lasttrace = o.packetTrace()))
|
if ((lasttrace = o.packetTrace()))
|
||||||
nsp_settrace(dnspool, 5, o.getStartTime());
|
nsp_settrace(dnspool, 5, o.getStartTime());
|
||||||
|
|||||||
22
nmap_rpc.cc
22
nmap_rpc.cc
@@ -262,14 +262,14 @@ int send_rpc_query(const struct in_addr *target_host, unsigned short portno,
|
|||||||
|
|
||||||
if (ipproto == IPPROTO_TCP && tcp_rpc_socket == -1) {
|
if (ipproto == IPPROTO_TCP && tcp_rpc_socket == -1) {
|
||||||
if ((tcp_rpc_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
|
if ((tcp_rpc_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
|
||||||
pfatal("Socket troubles in send_rpc_query");
|
pfatal("Socket troubles in %s", __func__);
|
||||||
/* I should unblock the socket here and timeout the connect() */
|
/* I should unblock the socket here and timeout the connect() */
|
||||||
res = connect(tcp_rpc_socket, (struct sockaddr *) &sock,
|
res = connect(tcp_rpc_socket, (struct sockaddr *) &sock,
|
||||||
sizeof(struct sockaddr_in));
|
sizeof(struct sockaddr_in));
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
if (o.debugging) {
|
if (o.debugging) {
|
||||||
gh_perror("Failed to connect to port %d of %s in send_rpc_query",
|
gh_perror("Failed to connect to port %d of %s in %s",
|
||||||
portno, inet_ntoa(*target_host));
|
portno, inet_ntoa(*target_host), __func__);
|
||||||
}
|
}
|
||||||
close(tcp_rpc_socket);
|
close(tcp_rpc_socket);
|
||||||
tcp_rpc_socket = -1;
|
tcp_rpc_socket = -1;
|
||||||
@@ -278,7 +278,7 @@ int send_rpc_query(const struct in_addr *target_host, unsigned short portno,
|
|||||||
unblock_socket(tcp_rpc_socket);
|
unblock_socket(tcp_rpc_socket);
|
||||||
} else if (ipproto == IPPROTO_UDP && udp_rpc_socket == -1) {
|
} else if (ipproto == IPPROTO_UDP && udp_rpc_socket == -1) {
|
||||||
if ((udp_rpc_socket = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
if ((udp_rpc_socket = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
pfatal("UDP socket troubles in send_rpc_query");
|
pfatal("UDP socket troubles in %s", __func__);
|
||||||
unblock_socket(udp_rpc_socket);
|
unblock_socket(udp_rpc_socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ int send_rpc_query(const struct in_addr *target_host, unsigned short portno,
|
|||||||
|
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
if (o.debugging) {
|
if (o.debugging) {
|
||||||
gh_perror("Sendto in send_rpc_query");
|
gh_perror("Sendto in %s", __func__);
|
||||||
close(udp_rpc_socket);
|
close(udp_rpc_socket);
|
||||||
udp_rpc_socket = -1;
|
udp_rpc_socket = -1;
|
||||||
}
|
}
|
||||||
@@ -327,7 +327,7 @@ int send_rpc_query(const struct in_addr *target_host, unsigned short portno,
|
|||||||
res = Send(tcp_rpc_socket, rpch_buf, sizeof(struct rpc_hdr) + sizeof(unsigned long), 0);
|
res = Send(tcp_rpc_socket, rpch_buf, sizeof(struct rpc_hdr) + sizeof(unsigned long), 0);
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
if (o.debugging) {
|
if (o.debugging) {
|
||||||
gh_perror("Write in send_rpc_query");
|
gh_perror("Write in %s", __func__);
|
||||||
}
|
}
|
||||||
close(tcp_rpc_socket);
|
close(tcp_rpc_socket);
|
||||||
tcp_rpc_socket = -1;
|
tcp_rpc_socket = -1;
|
||||||
@@ -411,7 +411,7 @@ static int rpc_are_we_done(char *msg, int msg_len, Target *target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (trynum > current->trynum) {
|
if (trynum > current->trynum) {
|
||||||
error("Bogus trynum %d when we are only up to %d in get_rpc_results", trynum, current->trynum);
|
error("Bogus trynum %d when we are only up to %d in %s", trynum, current->trynum, __func__);
|
||||||
rsi->rpc_status = RPC_STATUS_NOT_RPC;
|
rsi->rpc_status = RPC_STATUS_NOT_RPC;
|
||||||
ss->numqueries_outstanding = 0;
|
ss->numqueries_outstanding = 0;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -511,7 +511,7 @@ unsigned long current_msg_len;
|
|||||||
if (tcp_rpc_socket > max_sd)
|
if (tcp_rpc_socket > max_sd)
|
||||||
max_sd = tcp_rpc_socket;
|
max_sd = tcp_rpc_socket;
|
||||||
} else {
|
} else {
|
||||||
error("Unable to find listening socket in get_rpc_results");
|
error("Unable to find listening socket in %s", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,7 +536,7 @@ unsigned long current_msg_len;
|
|||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
/* Doh! */
|
/* Doh! */
|
||||||
if (o.debugging || o.verbose)
|
if (o.debugging || o.verbose)
|
||||||
gh_perror("recvfrom in get_rpc_results");
|
gh_perror("recvfrom in %s", __func__);
|
||||||
ss->numqueries_outstanding = 0;
|
ss->numqueries_outstanding = 0;
|
||||||
rsi->rpc_status = RPC_STATUS_NOT_RPC;
|
rsi->rpc_status = RPC_STATUS_NOT_RPC;
|
||||||
return;
|
return;
|
||||||
@@ -562,9 +562,9 @@ unsigned long current_msg_len;
|
|||||||
if (res <= 0) {
|
if (res <= 0) {
|
||||||
if (o.debugging) {
|
if (o.debugging) {
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
gh_perror("Failed to read() from tcp rpc socket in get_rpc_results");
|
gh_perror("Failed to read() from tcp rpc socket in %s", __func__);
|
||||||
else {
|
else {
|
||||||
error("Lamer on port %u closed RPC socket on me in get_rpc_results", rsi->rpc_current_port->portno);
|
error("Lamer on port %u closed RPC socket on me in %s", rsi->rpc_current_port->portno, __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ss->numqueries_outstanding = 0;
|
ss->numqueries_outstanding = 0;
|
||||||
|
|||||||
@@ -111,4 +111,7 @@
|
|||||||
#define NMAP_PLATFORM "i686-pc-windows-windows"
|
#define NMAP_PLATFORM "i686-pc-windows-windows"
|
||||||
#define NMAPDATADIR "c:\\nmap" /* FIXME: I really need to make this dynamic */
|
#define NMAPDATADIR "c:\\nmap" /* FIXME: I really need to make this dynamic */
|
||||||
|
|
||||||
|
/* Apparently __func__ isn't yet supported */
|
||||||
|
#define __func__ __FUNCTION__
|
||||||
|
|
||||||
#endif /* NMAP_WINCONFIG_H */
|
#endif /* NMAP_WINCONFIG_H */
|
||||||
|
|||||||
20
osscan.cc
20
osscan.cc
@@ -149,7 +149,7 @@ while(!id) id = get_random_uint();
|
|||||||
|
|
||||||
/* check that required fields are there and not too silly */
|
/* check that required fields are there and not too silly */
|
||||||
if ( !victim || !dport || (!eth && sd < 0)) {
|
if ( !victim || !dport || (!eth && sd < 0)) {
|
||||||
fprintf(stderr, "send_closedudp_probe: One or more of your parameters suck!\n");
|
fprintf(stderr, "%s: One or more of your parameters suck!\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ static struct AVal *fingerprint_portunreach(struct ip *ip, struct udpprobeinfo *
|
|||||||
/* The very first thing we do is make sure this is the correct
|
/* The very first thing we do is make sure this is the correct
|
||||||
response */
|
response */
|
||||||
if (ip->ip_p != IPPROTO_ICMP) {
|
if (ip->ip_p != IPPROTO_ICMP) {
|
||||||
error("fingerprint_portunreach handed a non-ICMP packet!");
|
error("%s handed a non-ICMP packet!", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,14 +531,14 @@ static FingerPrint *get_fingerprint(Target *target, struct seq_info *si) {
|
|||||||
memcpy(eth.dstmac, target->NextHopMACAddress(), 6);
|
memcpy(eth.dstmac, target->NextHopMACAddress(), 6);
|
||||||
eth.ethsd = eth_open_cached(target->deviceName());
|
eth.ethsd = eth_open_cached(target->deviceName());
|
||||||
if (eth.ethsd == NULL)
|
if (eth.ethsd == NULL)
|
||||||
fatal("%s: Failed to open ethernet device (%s)", __FUNCTION__, target->deviceName());
|
fatal("%s: Failed to open ethernet device (%s)", __func__, target->deviceName());
|
||||||
|
|
||||||
rawsd = -1;
|
rawsd = -1;
|
||||||
ethptr = ð
|
ethptr = ð
|
||||||
} else {
|
} else {
|
||||||
/* Init our raw socket */
|
/* Init our raw socket */
|
||||||
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
||||||
pfatal("socket troubles in get_fingerprint");
|
pfatal("socket troubles in %s", __func__);
|
||||||
unblock_socket(rawsd);
|
unblock_socket(rawsd);
|
||||||
broadcast_socket(rawsd);
|
broadcast_socket(rawsd);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@@ -1281,10 +1281,10 @@ static int AVal_match(struct AVal *reference, struct AVal *fprint, struct AVal *
|
|||||||
if (numtrue == 0) testfailed=1;
|
if (numtrue == 0) testfailed=1;
|
||||||
if (points) {
|
if (points) {
|
||||||
current_points = getattrbyname(points, current_ref->attribute);
|
current_points = getattrbyname(points, current_ref->attribute);
|
||||||
if (!current_points) fatal("%s: Failed to find point amount for test %s.%s", __FUNCTION__, testGroupName? testGroupName : "", current_ref->attribute);
|
if (!current_points) fatal("%s: Failed to find point amount for test %s.%s", __func__, testGroupName? testGroupName : "", current_ref->attribute);
|
||||||
pointsThisTest = strtol(current_points->value, &endptr, 10);
|
pointsThisTest = strtol(current_points->value, &endptr, 10);
|
||||||
if (pointsThisTest < 1)
|
if (pointsThisTest < 1)
|
||||||
fatal("%s: Got bogus point amount (%s) for test %s.%s", __FUNCTION__, current_points->value, testGroupName? testGroupName : "", current_ref->attribute);
|
fatal("%s: Got bogus point amount (%s) for test %s.%s", __func__, current_points->value, testGroupName? testGroupName : "", current_ref->attribute);
|
||||||
}
|
}
|
||||||
subtests += pointsThisTest;
|
subtests += pointsThisTest;
|
||||||
if (testfailed) {
|
if (testfailed) {
|
||||||
@@ -1329,7 +1329,7 @@ double compare_fingerprints(FingerPrint *referenceFP, FingerPrint *observedFP,
|
|||||||
if (MatchPoints) {
|
if (MatchPoints) {
|
||||||
currentTestMatchPoints = gettestbyname(MatchPoints, currentReferenceTest->name);
|
currentTestMatchPoints = gettestbyname(MatchPoints, currentReferenceTest->name);
|
||||||
if (!currentTestMatchPoints)
|
if (!currentTestMatchPoints)
|
||||||
fatal("%s: Failed to locate test %s in MatchPoints directive of fingerprint file", __FUNCTION__, currentReferenceTest->name);
|
fatal("%s: Failed to locate test %s in MatchPoints directive of fingerprint file", __func__, currentReferenceTest->name);
|
||||||
} else currentTestMatchPoints = NULL;
|
} else currentTestMatchPoints = NULL;
|
||||||
|
|
||||||
AVal_match(currentReferenceTest->results, currentObservedTest, currentTestMatchPoints,
|
AVal_match(currentReferenceTest->results, currentObservedTest, currentTestMatchPoints,
|
||||||
@@ -1641,7 +1641,7 @@ if (numFPs > 32) return "(Too many)";
|
|||||||
memset(str, 0, sizeof(str));
|
memset(str, 0, sizeof(str));
|
||||||
for(i=0; i < numFPs; i++) {
|
for(i=0; i < numFPs; i++) {
|
||||||
if (FPs[i] == NULL) {
|
if (FPs[i] == NULL) {
|
||||||
fatal("mergeFPs was handed a pointer to null fingerprint");
|
fatal("%s was handed a pointer to null fingerprint", __func__);
|
||||||
}
|
}
|
||||||
currentFPs[i] = FPs[i];
|
currentFPs[i] = FPs[i];
|
||||||
}
|
}
|
||||||
@@ -1769,7 +1769,7 @@ static void parse_classline(FingerPrint *FP, char *thisline, int lineno,
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
if (!thisline || strncmp(thisline, "Class ", 6) == 1) {
|
if (!thisline || strncmp(thisline, "Class ", 6) == 1) {
|
||||||
fatal("Bogus line #%d (%s) passed to parse_classline()", lineno, thisline);
|
fatal("Bogus line #%d (%s) passed to %s()", lineno, thisline, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*classno >= MAX_OS_CLASSIFICATIONS_PER_FP)
|
if (*classno >= MAX_OS_CLASSIFICATIONS_PER_FP)
|
||||||
@@ -2034,7 +2034,7 @@ int classno = 0; /* Number of Class lines dealt with so far */
|
|||||||
|
|
||||||
char *p, *q; /* OH YEAH!!!! */
|
char *p, *q; /* OH YEAH!!!! */
|
||||||
|
|
||||||
if (!DB) fatal("non-allocated DB passed to %s", __FUNCTION__);
|
if (!DB) fatal("non-allocated DB passed to %s", __func__);
|
||||||
|
|
||||||
DB->prints = (FingerPrint **) safe_zalloc(sizeof(FingerPrint *) * max_records);
|
DB->prints = (FingerPrint **) safe_zalloc(sizeof(FingerPrint *) * max_records);
|
||||||
|
|
||||||
|
|||||||
@@ -926,13 +926,13 @@ HostOsScan::HostOsScan(Target *t) {
|
|||||||
memcpy(eth.srcmac, t->SrcMACAddress(), 6);
|
memcpy(eth.srcmac, t->SrcMACAddress(), 6);
|
||||||
memcpy(eth.dstmac, t->NextHopMACAddress(), 6);
|
memcpy(eth.dstmac, t->NextHopMACAddress(), 6);
|
||||||
if ((eth.ethsd = eth_open_cached(t->deviceName())) == NULL)
|
if ((eth.ethsd = eth_open_cached(t->deviceName())) == NULL)
|
||||||
fatal("%s: Failed to open ethernet device (%s)", __FUNCTION__, t->deviceName());
|
fatal("%s: Failed to open ethernet device (%s)", __func__, t->deviceName());
|
||||||
rawsd = -1;
|
rawsd = -1;
|
||||||
ethptr = ð
|
ethptr = ð
|
||||||
} else {
|
} else {
|
||||||
/* Init our raw socket */
|
/* Init our raw socket */
|
||||||
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
||||||
pfatal("socket troubles in get_fingerprint");
|
pfatal("socket troubles in %s", __func__);
|
||||||
unblock_socket(rawsd);
|
unblock_socket(rawsd);
|
||||||
broadcast_socket(rawsd);
|
broadcast_socket(rawsd);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@@ -2927,7 +2927,7 @@ HostOsScanInfo *OsScanInfo::findIncompleteHost(struct sockaddr_storage *ss) {
|
|||||||
struct sockaddr_in *sin = (struct sockaddr_in *) ss;
|
struct sockaddr_in *sin = (struct sockaddr_in *) ss;
|
||||||
|
|
||||||
if (sin->sin_family != AF_INET)
|
if (sin->sin_family != AF_INET)
|
||||||
fatal("UltraScanInfo::findIncompleteHost passed a non IPv4 address");
|
fatal("%s passed a non IPv4 address", __func__);
|
||||||
|
|
||||||
for(hostI = incompleteHosts.begin(); hostI != incompleteHosts.end(); hostI++) {
|
for(hostI = incompleteHosts.begin(); hostI != incompleteHosts.end(); hostI++) {
|
||||||
if ((*hostI)->target->v4hostip()->s_addr == sin->sin_addr.s_addr)
|
if ((*hostI)->target->v4hostip()->s_addr == sin->sin_addr.s_addr)
|
||||||
@@ -3049,7 +3049,7 @@ int send_closedudp_probe_2(struct udpprobeinfo &upi, int sd,
|
|||||||
|
|
||||||
/* check that required fields are there and not too silly */
|
/* check that required fields are there and not too silly */
|
||||||
if ( !victim || !sport || !dport || (!eth && sd < 0)) {
|
if ( !victim || !sport || !dport || (!eth && sd < 0)) {
|
||||||
fprintf(stderr, "send_closedudp_probe_2: One or more of your parameters suck!\n");
|
fprintf(stderr, "%s: One or more of your parameters suck!\n", __func__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -881,7 +881,7 @@ void log_vwrite(int logt, const char *fmt, va_list ap) {
|
|||||||
va_end(apcopy);
|
va_end(apcopy);
|
||||||
return;
|
return;
|
||||||
} else if (len < 0) {
|
} else if (len < 0) {
|
||||||
fprintf(stderr, "vsnprintf returned %d in %s -- bizarre. Quitting.\n", len, __FUNCTION__);
|
fprintf(stderr, "vsnprintf returned %d in %s -- bizarre. Quitting.\n", len, __func__);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (len >= writebuflen) {
|
} else if (len >= writebuflen) {
|
||||||
/* Didn't have enough space. Expand writebuf and try again */
|
/* Didn't have enough space. Expand writebuf and try again */
|
||||||
@@ -890,7 +890,7 @@ void log_vwrite(int logt, const char *fmt, va_list ap) {
|
|||||||
writebuf = (char *) safe_malloc(writebuflen);
|
writebuf = (char *) safe_malloc(writebuflen);
|
||||||
len = vsnprintf(writebuf, writebuflen, fmt, apcopy);
|
len = vsnprintf(writebuf, writebuflen, fmt, apcopy);
|
||||||
if (len <= 0 || len >= writebuflen) {
|
if (len <= 0 || len >= writebuflen) {
|
||||||
fprintf(stderr, "%s: vnsprintf failed. Even after increasing bufferlen to %d, vsnprintf returned %d (logt == %d). Please email this message to fyodor@insecure.org. Quitting.\n", __FUNCTION__, writebuflen, len, logt);
|
fprintf(stderr, "%s: vnsprintf failed. Even after increasing bufferlen to %d, vsnprintf returned %d (logt == %d). Please email this message to fyodor@insecure.org. Quitting.\n", __func__, writebuflen, len, logt);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -906,7 +906,7 @@ void log_vwrite(int logt, const char *fmt, va_list ap) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "log_vwrite(): Passed unknown log type (%d). Note that this function, unlike log_write, can only handle one log type at a time (no bitmasks)\n", logt);
|
fprintf(stderr, "%s(): Passed unknown log type (%d). Note that this function, unlike log_write, can only handle one log type at a time (no bitmasks)\n", __func__, logt);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -956,7 +956,7 @@ void log_flush(int logt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (logt & LOG_SKID_NOXLT)
|
if (logt & LOG_SKID_NOXLT)
|
||||||
fatal("You are not allowed to log_flush() with LOG_SKID_NOXLT");
|
fatal("You are not allowed to %s() with LOG_SKID_NOXLT", __func__);
|
||||||
|
|
||||||
if (logt<0 || logt>LOG_FILE_MASK) return;
|
if (logt<0 || logt>LOG_FILE_MASK) return;
|
||||||
|
|
||||||
|
|||||||
12
portlist.cc
12
portlist.cc
@@ -417,7 +417,7 @@ int PortList::addPort(u16 portno, u8 protocol, char *owner, int state) {
|
|||||||
if (state != PORT_OPEN && state != PORT_CLOSED && state != PORT_FILTERED &&
|
if (state != PORT_OPEN && state != PORT_CLOSED && state != PORT_FILTERED &&
|
||||||
state != PORT_UNFILTERED && state != PORT_OPENFILTERED &&
|
state != PORT_UNFILTERED && state != PORT_OPENFILTERED &&
|
||||||
state != PORT_CLOSEDFILTERED)
|
state != PORT_CLOSEDFILTERED)
|
||||||
fatal("addPort: attempt to add port number %d with illegal state %d\n", portno, state);
|
fatal("%s: attempt to add port number %d with illegal state %d\n", __func__, portno, state);
|
||||||
|
|
||||||
assert(protocol!=IPPROTO_IP || portno<256);
|
assert(protocol!=IPPROTO_IP || portno<256);
|
||||||
|
|
||||||
@@ -555,7 +555,7 @@ Port *PortList::getPortEntry(u16 portno, u8 protocol) {
|
|||||||
|
|
||||||
assert(protocol!=IPPROTO_IP || portno<256);
|
assert(protocol!=IPPROTO_IP || portno<256);
|
||||||
if(port_map[proto]==NULL || port_list[proto]==NULL)
|
if(port_map[proto]==NULL || port_list[proto]==NULL)
|
||||||
fatal("getPortEntry(%i,%i): you're trying to access uninitialized protocol", portno, protocol);
|
fatal("%s(%i,%i): you're trying to access uninitialized protocol", __func__, portno, protocol);
|
||||||
mapped_pno = port_map[proto][portno];
|
mapped_pno = port_map[proto][portno];
|
||||||
|
|
||||||
assert(mapped_pno < port_list_count[proto]);
|
assert(mapped_pno < port_list_count[proto]);
|
||||||
@@ -563,7 +563,7 @@ Port *PortList::getPortEntry(u16 portno, u8 protocol) {
|
|||||||
|
|
||||||
/* The ugly hack: we allow only port 0 to be mapped to 0 position */
|
/* The ugly hack: we allow only port 0 to be mapped to 0 position */
|
||||||
if(mapped_pno==0 && portno!=0) {
|
if(mapped_pno==0 && portno!=0) {
|
||||||
error("WARNING: getPortEntry(%i,%i): this port was not mapped", portno, protocol);
|
error("WARNING: %s(%i,%i): this port was not mapped", __func__, portno, protocol);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}else
|
}else
|
||||||
return(port_list[proto][mapped_pno]);
|
return(port_list[proto][mapped_pno]);
|
||||||
@@ -575,7 +575,7 @@ void PortList::setPortEntry(u16 portno, u8 protocol, Port *port) {
|
|||||||
|
|
||||||
assert(protocol!=IPPROTO_IP || portno<256);
|
assert(protocol!=IPPROTO_IP || portno<256);
|
||||||
if(port_map[proto]==NULL || port_list[proto]==NULL)
|
if(port_map[proto]==NULL || port_list[proto]==NULL)
|
||||||
fatal("setPortEntry(%i,%i): you're trying to access uninitialized protocol", portno, protocol);
|
fatal("%s(%i,%i): you're trying to access uninitialized protocol", __func__, portno, protocol);
|
||||||
mapped_pno = port_map[proto][portno];
|
mapped_pno = port_map[proto][portno];
|
||||||
|
|
||||||
assert(mapped_pno < port_list_count[proto]);
|
assert(mapped_pno < port_list_count[proto]);
|
||||||
@@ -583,7 +583,7 @@ void PortList::setPortEntry(u16 portno, u8 protocol, Port *port) {
|
|||||||
|
|
||||||
/* The ugly hack: we allow only port 0 to be mapped to 0 position */
|
/* The ugly hack: we allow only port 0 to be mapped to 0 position */
|
||||||
if(mapped_pno==0 && portno!=0) {
|
if(mapped_pno==0 && portno!=0) {
|
||||||
error("WARNING: setPortEntry(%i,%i): this port was not mapped", portno, protocol);
|
error("WARNING: %s(%i,%i): this port was not mapped", __func__, portno, protocol);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +615,7 @@ void PortList::initializePortMap(int protocol, u16 *ports, int portcount) {
|
|||||||
int proto = INPROTO2PORTLISTPROTO(protocol);
|
int proto = INPROTO2PORTLISTPROTO(protocol);
|
||||||
|
|
||||||
if(port_map[proto]!=NULL)
|
if(port_map[proto]!=NULL)
|
||||||
fatal("initializePortMap: portmap for protocol %i already initialized", protocol);
|
fatal("%s: portmap for protocol %i already initialized", __func__, protocol);
|
||||||
|
|
||||||
assert(port_list_count[proto]==0);
|
assert(port_list_count[proto]==0);
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ int addprotocolsfromservmask(char *mask, u8 *porttbl, struct scan_lists *ports)
|
|||||||
int bucket, t=0;
|
int bucket, t=0;
|
||||||
|
|
||||||
if (!protocols_initialized && nmap_protocols_init() == -1)
|
if (!protocols_initialized && nmap_protocols_init() == -1)
|
||||||
fatal("addprotocolsfromservmask: Couldn't get protocol numbers");
|
fatal("%s: Couldn't get protocol numbers", __func__);
|
||||||
|
|
||||||
for(bucket = 0; bucket < PROTOCOL_TABLE_SIZE; bucket++) {
|
for(bucket = 0; bucket < PROTOCOL_TABLE_SIZE; bucket++) {
|
||||||
for(current = protocol_table[bucket % PROTOCOL_TABLE_SIZE]; current; current = current->next) {
|
for(current = protocol_table[bucket % PROTOCOL_TABLE_SIZE]; current; current = current->next) {
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ static const char *pspectype2ascii(int type) {
|
|||||||
case PS_ARP:
|
case PS_ARP:
|
||||||
return "ARP";
|
return "ARP";
|
||||||
default:
|
default:
|
||||||
fatal("%s: Unknown type: %d", __FUNCTION__, type);
|
fatal("%s: Unknown type: %d", __func__, type);
|
||||||
}
|
}
|
||||||
return ""; // Unreached
|
return ""; // Unreached
|
||||||
}
|
}
|
||||||
@@ -624,7 +624,7 @@ static char *probespec2ascii(probespec *pspec, char *buf, unsigned int bufsz) {
|
|||||||
snprintf(buf, bufsz, "ARP");
|
snprintf(buf, bufsz, "ARP");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatal("Unexpected probespec2ascii type encountered");
|
fatal("Unexpected %s type encountered", __func__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
@@ -675,7 +675,7 @@ void UltraProbe::setIP(u8 *ippacket, u32 iplen, const probespec *pspec) {
|
|||||||
type = UP_IP;
|
type = UP_IP;
|
||||||
if (ipv4->ip_v != 4)
|
if (ipv4->ip_v != 4)
|
||||||
fatal("Bogus packet passed to %s -- only IPv4 packets allowed",
|
fatal("Bogus packet passed to %s -- only IPv4 packets allowed",
|
||||||
__FUNCTION__);
|
__func__);
|
||||||
assert(iplen >= 20);
|
assert(iplen >= 20);
|
||||||
assert(iplen == (u32) ntohs(ipv4->ip_len));
|
assert(iplen == (u32) ntohs(ipv4->ip_len));
|
||||||
probes.IP.ipid = ntohs(ipv4->ip_id);
|
probes.IP.ipid = ntohs(ipv4->ip_id);
|
||||||
@@ -698,7 +698,7 @@ u32 UltraProbe::tcpseq() {
|
|||||||
if (mypspec.proto == IPPROTO_TCP)
|
if (mypspec.proto == IPPROTO_TCP)
|
||||||
return probes.IP.pd.tcp.seq;
|
return probes.IP.pd.tcp.seq;
|
||||||
else
|
else
|
||||||
fatal("Bogus seq number request to %s -- type is %s", __FUNCTION__,
|
fatal("Bogus seq number request to %s -- type is %s", __func__,
|
||||||
pspectype2ascii(mypspec.type));
|
pspectype2ascii(mypspec.type));
|
||||||
|
|
||||||
return 0; // Unreached
|
return 0; // Unreached
|
||||||
@@ -852,7 +852,7 @@ static int scantype_no_response_means(stype scantype) {
|
|||||||
case PING_SCAN_ARP:
|
case PING_SCAN_ARP:
|
||||||
return HOST_DOWN;
|
return HOST_DOWN;
|
||||||
default:
|
default:
|
||||||
fatal("Unexpected scan type found in scantype_no_response_means()");
|
fatal("Unexpected scan type found in %s()", __func__);
|
||||||
}
|
}
|
||||||
return 0; /* Unreached */
|
return 0; /* Unreached */
|
||||||
}
|
}
|
||||||
@@ -1214,7 +1214,7 @@ void UltraScanInfo::Init(vector<Target *> &Targets, struct scan_lists *pts, styp
|
|||||||
} else {
|
} else {
|
||||||
/* Initialize a raw socket */
|
/* Initialize a raw socket */
|
||||||
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
||||||
pfatal("socket troubles in UltraScanInfo::Init");
|
pfatal("socket troubles in %s", __func__);
|
||||||
/* We do not wan't to unblock the socket since we want to wait
|
/* We do not wan't to unblock the socket since we want to wait
|
||||||
if kernel send buffers fill up rather than get ENOBUF, and
|
if kernel send buffers fill up rather than get ENOBUF, and
|
||||||
we won't be receiving on the socket anyway
|
we won't be receiving on the socket anyway
|
||||||
@@ -1293,7 +1293,7 @@ HostScanStats *UltraScanInfo::findIncompleteHost(struct sockaddr_storage *ss) {
|
|||||||
struct sockaddr_in *sin = (struct sockaddr_in *) ss;
|
struct sockaddr_in *sin = (struct sockaddr_in *) ss;
|
||||||
|
|
||||||
if (sin->sin_family != AF_INET)
|
if (sin->sin_family != AF_INET)
|
||||||
fatal("UltraScanInfo::findIncompleteHost passed a non IPv4 address");
|
fatal("%s passed a non IPv4 address", __func__);
|
||||||
|
|
||||||
for(hss = incompleteHosts.begin(); hss != incompleteHosts.end(); hss++) {
|
for(hss = incompleteHosts.begin(); hss != incompleteHosts.end(); hss++) {
|
||||||
if ((*hss)->target->v4hostip()->s_addr == sin->sin_addr.s_addr)
|
if ((*hss)->target->v4hostip()->s_addr == sin->sin_addr.s_addr)
|
||||||
@@ -1987,11 +1987,11 @@ static UltraProbe *sendConnectScanProbe(UltraScanInfo *USI, HostScanStats *hss,
|
|||||||
CP = probe->CP();
|
CP = probe->CP();
|
||||||
/* Initiate the connection */
|
/* Initiate the connection */
|
||||||
CP->sd = socket(o.af(), SOCK_STREAM, IPPROTO_TCP);
|
CP->sd = socket(o.af(), SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (CP->sd == -1) pfatal("Socket creation in sendConnectScanProbe");
|
if (CP->sd == -1) pfatal("Socket creation in %s", __func__);
|
||||||
unblock_socket(CP->sd);
|
unblock_socket(CP->sd);
|
||||||
init_socket(CP->sd);
|
init_socket(CP->sd);
|
||||||
if (hss->target->TargetSockAddr(&sock, &socklen) != 0) {
|
if (hss->target->TargetSockAddr(&sock, &socklen) != 0) {
|
||||||
fatal("Failed to get target socket address in pos_scan");
|
fatal("Failed to get target socket address in %s", __func__);
|
||||||
}
|
}
|
||||||
if (sin->sin_family == AF_INET)
|
if (sin->sin_family == AF_INET)
|
||||||
sin->sin_port = htons(probe->pspec()->pd.tcp.dport);
|
sin->sin_port = htons(probe->pspec()->pd.tcp.dport);
|
||||||
@@ -2234,7 +2234,7 @@ static void sendNextScanProbe(UltraScanInfo *USI, HostScanStats *hss) {
|
|||||||
probespec pspec;
|
probespec pspec;
|
||||||
|
|
||||||
if (get_next_target_probe(USI, hss, &pspec) == -1) {
|
if (get_next_target_probe(USI, hss, &pspec) == -1) {
|
||||||
fatal("sendNextScanProbe: No more probes! Error in Nmap.");
|
fatal("%s: No more probes! Error in Nmap.", __func__);
|
||||||
}
|
}
|
||||||
hss->numprobes_sent++;
|
hss->numprobes_sent++;
|
||||||
USI->gstats->probes_sent++;
|
USI->gstats->probes_sent++;
|
||||||
@@ -2557,7 +2557,7 @@ static bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
|
|||||||
gettimeofday(&USI->now, NULL);
|
gettimeofday(&USI->now, NULL);
|
||||||
|
|
||||||
if (selectres == -1)
|
if (selectres == -1)
|
||||||
pfatal("select failed in do_one_select_round()");
|
pfatal("select failed in %s()", __func__);
|
||||||
|
|
||||||
if (!selectres)
|
if (!selectres)
|
||||||
return false;
|
return false;
|
||||||
@@ -3717,7 +3717,7 @@ void pos_scan(Target *target, u16 *portarray, int numports, stype scantype) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (scantype != RPC_SCAN)
|
if (scantype != RPC_SCAN)
|
||||||
fatal("pos_scan now handles only rpc scan");
|
fatal("%s now handles only rpc scan", __func__);
|
||||||
|
|
||||||
if (target->ports.getStateCounts(PORT_OPEN) == 0 &&
|
if (target->ports.getStateCounts(PORT_OPEN) == 0 &&
|
||||||
(o.servicescan || target->ports.getStateCounts(PORT_OPENFILTERED) == 0))
|
(o.servicescan || target->ports.getStateCounts(PORT_OPENFILTERED) == 0))
|
||||||
|
|||||||
@@ -308,9 +308,9 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
|
|||||||
unsigned int tmpbuflen = 0;
|
unsigned int tmpbuflen = 0;
|
||||||
char **curr_tmp = NULL;
|
char **curr_tmp = NULL;
|
||||||
|
|
||||||
if (isInitialized) fatal("Sorry ... ServiceProbeMatch::InitMatch does not yet support reinitializion");
|
if (isInitialized) fatal("Sorry ... %s does not yet support reinitializion", __func__);
|
||||||
if (!matchtext || !*matchtext)
|
if (!matchtext || !*matchtext)
|
||||||
fatal("ServiceProbeMatch::InitMatch: no matchtext passed in (line %d of nmap-service-probes)", lineno);
|
fatal("%s: no matchtext passed in (line %d of nmap-service-probes)", __func__, lineno);
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
|
|
||||||
deflineno = lineno;
|
deflineno = lineno;
|
||||||
@@ -324,11 +324,11 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
|
|||||||
isSoft = false;
|
isSoft = false;
|
||||||
matchtext += 6;
|
matchtext += 6;
|
||||||
} else
|
} else
|
||||||
fatal("ServiceProbeMatch::InitMatch: parse error on line %d of nmap-service-probes - must begin with \"match\" or \"softmatch\"", lineno);
|
fatal("%s: parse error on line %d of nmap-service-probes - must begin with \"match\" or \"softmatch\"", __func__, lineno);
|
||||||
|
|
||||||
// next comes the service name
|
// next comes the service name
|
||||||
p = strchr(matchtext, ' ');
|
p = strchr(matchtext, ' ');
|
||||||
if (!p) fatal("ServiceProbeMatch::InitMatch: parse error on line %d of nmap-service-probes: could not find service name", lineno);
|
if (!p) fatal("%s: parse error on line %d of nmap-service-probes: could not find service name", __func__, lineno);
|
||||||
|
|
||||||
servicename = (char *) safe_malloc(p - matchtext + 1);
|
servicename = (char *) safe_malloc(p - matchtext + 1);
|
||||||
memcpy(servicename, matchtext, p - matchtext);
|
memcpy(servicename, matchtext, p - matchtext);
|
||||||
@@ -345,13 +345,13 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
|
|||||||
while(isspace(*matchtext)) matchtext++;
|
while(isspace(*matchtext)) matchtext++;
|
||||||
if (*matchtext == 'm') {
|
if (*matchtext == 'm') {
|
||||||
if (!*(matchtext+1))
|
if (!*(matchtext+1))
|
||||||
fatal("ServiceProbeMatch::InitMatch: parse error on line %d of nmap-service-probes: matchtext must begin with 'm'", lineno);
|
fatal("%s: parse error on line %d of nmap-service-probes: matchtext must begin with 'm'", __func__, lineno);
|
||||||
matchtype = SERVICEMATCH_REGEX;
|
matchtype = SERVICEMATCH_REGEX;
|
||||||
delimchar = *(++matchtext);
|
delimchar = *(++matchtext);
|
||||||
++matchtext;
|
++matchtext;
|
||||||
// find the end of the regex
|
// find the end of the regex
|
||||||
p = strchr(matchtext, delimchar);
|
p = strchr(matchtext, delimchar);
|
||||||
if (!p) fatal("ServiceProbeMatch::InitMatch: parse error on line %d of nmap-service-probes: could not find end delimiter for regex", lineno);
|
if (!p) fatal("%s: parse error on line %d of nmap-service-probes: could not find end delimiter for regex", __func__, lineno);
|
||||||
matchstrlen = p - matchtext;
|
matchstrlen = p - matchtext;
|
||||||
matchstr = (char *) safe_malloc(matchstrlen + 1);
|
matchstr = (char *) safe_malloc(matchstrlen + 1);
|
||||||
memcpy(matchstr, matchtext, matchstrlen);
|
memcpy(matchstr, matchtext, matchstrlen);
|
||||||
@@ -364,7 +364,7 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
|
|||||||
matchops_ignorecase = true;
|
matchops_ignorecase = true;
|
||||||
else if (*matchtext == 's')
|
else if (*matchtext == 's')
|
||||||
matchops_dotall = true;
|
matchops_dotall = true;
|
||||||
else fatal("ServiceProbeMatch::InitMatch: illegal regexp option on line %d of nmap-service-probes", lineno);
|
else fatal("%s: illegal regexp option on line %d of nmap-service-probes", __func__, lineno);
|
||||||
matchtext++;
|
matchtext++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,16 +379,16 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
|
|||||||
&pcre_erroffset, NULL);
|
&pcre_erroffset, NULL);
|
||||||
|
|
||||||
if (regex_compiled == NULL)
|
if (regex_compiled == NULL)
|
||||||
fatal("ServiceProbeMatch::InitMatch: illegal regexp on line %d of nmap-service-probes (at regexp offset %d): %s\n", lineno, pcre_erroffset, pcre_errptr);
|
fatal("%s: illegal regexp on line %d of nmap-service-probes (at regexp offset %d): %s\n", __func__, lineno, pcre_erroffset, pcre_errptr);
|
||||||
|
|
||||||
|
|
||||||
// Now study the regexp for greater efficiency
|
// Now study the regexp for greater efficiency
|
||||||
regex_extra = pcre_study(regex_compiled, 0, &pcre_errptr);
|
regex_extra = pcre_study(regex_compiled, 0, &pcre_errptr);
|
||||||
if (pcre_errptr != NULL)
|
if (pcre_errptr != NULL)
|
||||||
fatal("ServiceProbeMatch::InitMatch: failed to pcre_study regexp on line %d of nmap-service-probes: %s\n", lineno, pcre_errptr);
|
fatal("%s: failed to pcre_study regexp on line %d of nmap-service-probes: %s\n", __func__, lineno, pcre_errptr);
|
||||||
} else {
|
} else {
|
||||||
/* Invalid matchtext */
|
/* Invalid matchtext */
|
||||||
fatal("ServiceProbeMatch::InitMatch: parse error on line %d of nmap-service-probes: match string must begin with 'm'", lineno);
|
fatal("%s: parse error on line %d of nmap-service-probes: match string must begin with 'm'", __func__, lineno);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OK! Now we look for any templates of the form ?/.../
|
/* OK! Now we look for any templates of the form ?/.../
|
||||||
@@ -401,12 +401,12 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
|
|||||||
|
|
||||||
modechar = *(matchtext++);
|
modechar = *(matchtext++);
|
||||||
if (*matchtext == 0 || *matchtext == '\r' || *matchtext == '\n')
|
if (*matchtext == 0 || *matchtext == '\r' || *matchtext == '\n')
|
||||||
fatal("ServiceProbeMatch::InitMatch: parse error on line %d of nmap-service-probes", lineno);
|
fatal("%s: parse error on line %d of nmap-service-probes", __func__, lineno);
|
||||||
|
|
||||||
delimchar = *(matchtext++);
|
delimchar = *(matchtext++);
|
||||||
|
|
||||||
p = strchr(matchtext, delimchar);
|
p = strchr(matchtext, delimchar);
|
||||||
if (!p) fatal("ServiceProbeMatch::InitMatch: parse error on line %d of nmap-service-probes", lineno);
|
if (!p) fatal("%s: parse error on line %d of nmap-service-probes", __func__, lineno);
|
||||||
|
|
||||||
tmptemplate = NULL;
|
tmptemplate = NULL;
|
||||||
tmpbuflen = p - matchtext;
|
tmpbuflen = p - matchtext;
|
||||||
@@ -424,7 +424,7 @@ void ServiceProbeMatch::InitMatch(const char *matchtext, int lineno) {
|
|||||||
case 'o': curr_tmp = &ostype_template; break;
|
case 'o': curr_tmp = &ostype_template; break;
|
||||||
case 'd': curr_tmp = &devicetype_template; break;
|
case 'd': curr_tmp = &devicetype_template; break;
|
||||||
default:
|
default:
|
||||||
fatal("ServiceProbeMatch::InitMatch: Unknown template specifier '%c' on line %d of nmap-service-probes", modechar, lineno);
|
fatal("%s: Unknown template specifier '%c' on line %d of nmap-service-probes", __func__, modechar, lineno);
|
||||||
}
|
}
|
||||||
if(*curr_tmp){
|
if(*curr_tmp){
|
||||||
if(o.debugging)
|
if(o.debugging)
|
||||||
@@ -1031,7 +1031,7 @@ void ServiceProbe::setRarity(const char *portstr, int lineno) {
|
|||||||
tp = atoi(portstr);
|
tp = atoi(portstr);
|
||||||
|
|
||||||
if (tp < 1 || tp > 9)
|
if (tp < 1 || tp > 9)
|
||||||
fatal("ServiceProbe::setRarity: Rarity directive on line %d of nmap-service-probes must be between 1 and 9", lineno);
|
fatal("%s: Rarity directive on line %d of nmap-service-probes must be between 1 and 9", __func__, lineno);
|
||||||
|
|
||||||
rarity = tp;
|
rarity = tp;
|
||||||
}
|
}
|
||||||
@@ -1248,7 +1248,7 @@ int AllProbes::isExcluded(unsigned short port, int proto) {
|
|||||||
p = excludedports->udp_ports;
|
p = excludedports->udp_ports;
|
||||||
count = excludedports->udp_count;
|
count = excludedports->udp_count;
|
||||||
} else {
|
} else {
|
||||||
fatal("Bad proto number (%d) specified in AllProbes::isExcluded", proto);
|
fatal("Bad proto number (%d) specified in %s", proto, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<count; i++)
|
for (i=0; i<count; i++)
|
||||||
@@ -1297,13 +1297,13 @@ void AllProbes::compileFallbacks() {
|
|||||||
while (tp != NULL && i<(MAXFALLBACKS-1)) {
|
while (tp != NULL && i<(MAXFALLBACKS-1)) {
|
||||||
(*curr)->fallbacks[i] = getProbeByName(tp, (*curr)->getProbeProtocol());
|
(*curr)->fallbacks[i] = getProbeByName(tp, (*curr)->getProbeProtocol());
|
||||||
if ((*curr)->fallbacks[i] == NULL)
|
if ((*curr)->fallbacks[i] == NULL)
|
||||||
fatal("AllProbes::compileFallbacks: Unknown fallback specified in Probe %s: '%s'", (*curr)->getName(), tp);
|
fatal("%s: Unknown fallback specified in Probe %s: '%s'", __func__, (*curr)->getName(), tp);
|
||||||
i++;
|
i++;
|
||||||
tp = strtok(NULL, ",\r\n\t ");
|
tp = strtok(NULL, ",\r\n\t ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == MAXFALLBACKS-1)
|
if (i == MAXFALLBACKS-1)
|
||||||
fatal("AllProbes::compileFallbacks: MAXFALLBACKS exceeded on probe '%s'", (*curr)->getName());
|
fatal("%s: MAXFALLBACKS exceeded on probe '%s'", __func__, (*curr)->getName());
|
||||||
|
|
||||||
if ((*curr)->getProbeProtocol() == IPPROTO_TCP)
|
if ((*curr)->getProbeProtocol() == IPPROTO_TCP)
|
||||||
(*curr)->fallbacks[i] = nullProbe;
|
(*curr)->fallbacks[i] = nullProbe;
|
||||||
@@ -1357,7 +1357,7 @@ ServiceNFO::~ServiceNFO() {
|
|||||||
void ServiceNFO::addServiceChar(char c, int wrapat) {
|
void ServiceNFO::addServiceChar(char c, int wrapat) {
|
||||||
|
|
||||||
if (servicefpalloc - servicefplen < 6)
|
if (servicefpalloc - servicefplen < 6)
|
||||||
fatal("ServiceNFO::addServiceChar - out of space for servicefp");
|
fatal("%s - out of space for servicefp", __func__);
|
||||||
|
|
||||||
if (servicefplen % (wrapat+1) == wrapat) {
|
if (servicefplen % (wrapat+1) == wrapat) {
|
||||||
// we need to start a new line
|
// we need to start a new line
|
||||||
@@ -1567,7 +1567,7 @@ bool dropdown = false;
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal("ServiceNFO::nextProbe called for probe in state (%d)", (int) probe_state);
|
fatal("%s called for probe in state (%d)", __func__, (int) probe_state);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1763,7 +1763,7 @@ static void startNextProbe(nsock_pool nsp, nsock_iod nsi, ServiceGroup *SG,
|
|||||||
if (svc->proto == IPPROTO_TCP) {
|
if (svc->proto == IPPROTO_TCP) {
|
||||||
nsi_delete(nsi, NSOCK_PENDING_SILENT);
|
nsi_delete(nsi, NSOCK_PENDING_SILENT);
|
||||||
if ((svc->niod = nsi_new(nsp, svc)) == NULL) {
|
if ((svc->niod = nsi_new(nsp, svc)) == NULL) {
|
||||||
fatal("Failed to allocate Nsock I/O descriptor in startNextProbe()");
|
fatal("Failed to allocate Nsock I/O descriptor in %s()", __func__);
|
||||||
}
|
}
|
||||||
svc->target->TargetSockAddr(&ss, &ss_len);
|
svc->target->TargetSockAddr(&ss, &ss_len);
|
||||||
if (svc->tunnel == SERVICE_TUNNEL_NONE) {
|
if (svc->tunnel == SERVICE_TUNNEL_NONE) {
|
||||||
@@ -1958,7 +1958,7 @@ static int launchSomeServiceProbes(nsock_pool nsp, ServiceGroup *SG) {
|
|||||||
|
|
||||||
// We start by requesting a connection to the target
|
// We start by requesting a connection to the target
|
||||||
if ((svc->niod = nsi_new(nsp, svc)) == NULL) {
|
if ((svc->niod = nsi_new(nsp, svc)) == NULL) {
|
||||||
fatal("Failed to allocate Nsock I/O descriptor in launchSomeServiceProbes()");
|
fatal("Failed to allocate Nsock I/O descriptor in %s()", __func__);
|
||||||
}
|
}
|
||||||
if (o.debugging > 1) {
|
if (o.debugging > 1) {
|
||||||
printf("Starting probes against new service: %s:%hi (%s)\n", svc->target->targetipstr(), svc->portno, proto2ascii(svc->proto));
|
printf("Starting probes against new service: %s:%hi (%s)\n", svc->target->targetipstr(), svc->portno, proto2ascii(svc->proto));
|
||||||
@@ -2405,7 +2405,7 @@ int service_scan(vector<Target *> &Targets) {
|
|||||||
// Lets create a nsock pool for managing all the concurrent probes
|
// Lets create a nsock pool for managing all the concurrent probes
|
||||||
// Store the servicegroup in there for availability in callbacks
|
// Store the servicegroup in there for availability in callbacks
|
||||||
if ((nsp = nsp_new(SG)) == NULL) {
|
if ((nsp = nsp_new(SG)) == NULL) {
|
||||||
fatal("service_scan() failed to create new nsock pool.");
|
fatal("%s() failed to create new nsock pool.", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o.versionTrace()) {
|
if (o.versionTrace()) {
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ int addportsfromservmask(char *mask, u8 *porttbl, struct scan_lists *ports, int
|
|||||||
int bucket,t=0;
|
int bucket,t=0;
|
||||||
|
|
||||||
if (!services_initialized && nmap_services_init() == -1)
|
if (!services_initialized && nmap_services_init() == -1)
|
||||||
fatal("addportsfromservmask: Couldn't get port numbers");
|
fatal("%s: Couldn't get port numbers", __func__);
|
||||||
|
|
||||||
for(bucket = 0; bucket < SERVICE_TABLE_SIZE; bucket++) {
|
for(bucket = 0; bucket < SERVICE_TABLE_SIZE; bucket++) {
|
||||||
for(current = service_table[bucket % SERVICE_TABLE_SIZE]; current; current = current->next) {
|
for(current = service_table[bucket % SERVICE_TABLE_SIZE]; current; current = current->next) {
|
||||||
@@ -367,7 +367,7 @@ struct scan_lists *gettoppts(double level, char *portlist) {
|
|||||||
struct service_list *current;
|
struct service_list *current;
|
||||||
|
|
||||||
if (!services_initialized && nmap_services_init() == -1)
|
if (!services_initialized && nmap_services_init() == -1)
|
||||||
fatal("gettoppts: Couldn't get port numbers");
|
fatal("%s: Couldn't get port numbers", __func__);
|
||||||
|
|
||||||
if (ratio_format == 0) {
|
if (ratio_format == 0) {
|
||||||
if (level != -1)
|
if (level != -1)
|
||||||
|
|||||||
28
targets.cc
28
targets.cc
@@ -469,7 +469,7 @@ static int get_ping_results(int sd, pcap_t *pd, Target *hostbatch[],
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (bytes > 0 && bytes <= 20) {
|
if (bytes > 0 && bytes <= 20) {
|
||||||
error("%d byte micro packet received in get_ping_results", bytes);
|
error("%d byte micro packet received in %s", bytes, __func__);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -835,7 +835,7 @@ static int sendconnecttcpquery(Target *hostbatch[], struct tcpqueryinfo *tqi,
|
|||||||
tmpsd = hostnum * pt->max_tries + i;
|
tmpsd = hostnum * pt->max_tries + i;
|
||||||
if (tqi->sockets[probe_port_num][tmpsd] >= 0) {
|
if (tqi->sockets[probe_port_num][tmpsd] >= 0) {
|
||||||
if (o.debugging)
|
if (o.debugging)
|
||||||
log_write(LOG_STDOUT, "sendconnecttcpquery: Scavenging a free socket due to serious shortage\n");
|
log_write(LOG_STDOUT, "%s: Scavenging a free socket due to serious shortage\n", __func__);
|
||||||
close(tqi->sockets[probe_port_num][tmpsd]);
|
close(tqi->sockets[probe_port_num][tmpsd]);
|
||||||
tqi->sockets[probe_port_num][tmpsd] = -1;
|
tqi->sockets[probe_port_num][tmpsd] = -1;
|
||||||
tqi->sockets_out--;
|
tqi->sockets_out--;
|
||||||
@@ -843,21 +843,21 @@ static int sendconnecttcpquery(Target *hostbatch[], struct tcpqueryinfo *tqi,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == trynum)
|
if (i == trynum)
|
||||||
fatal("sendconnecttcpquery: Could not scavenge a free socket!");
|
fatal("%s: Could not scavenge a free socket!", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Since we know we now have a free s0cket, lets take it */
|
/* Since we know we now have a free s0cket, lets take it */
|
||||||
assert(tqi->sockets[probe_port_num][seq] == -1);
|
assert(tqi->sockets[probe_port_num][seq] == -1);
|
||||||
tqi->sockets[probe_port_num][seq] = socket(o.af(), SOCK_STREAM, IPPROTO_TCP);
|
tqi->sockets[probe_port_num][seq] = socket(o.af(), SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (tqi->sockets[probe_port_num][seq] == -1)
|
if (tqi->sockets[probe_port_num][seq] == -1)
|
||||||
fatal("Socket creation in sendconnecttcpquery");
|
fatal("Socket creation in %s", __func__);
|
||||||
tqi->maxsd = MAX(tqi->maxsd, tqi->sockets[probe_port_num][seq]);
|
tqi->maxsd = MAX(tqi->maxsd, tqi->sockets[probe_port_num][seq]);
|
||||||
tqi->sockets_out++;
|
tqi->sockets_out++;
|
||||||
unblock_socket(tqi->sockets[probe_port_num][seq]);
|
unblock_socket(tqi->sockets[probe_port_num][seq]);
|
||||||
init_socket(tqi->sockets[probe_port_num][seq]);
|
init_socket(tqi->sockets[probe_port_num][seq]);
|
||||||
|
|
||||||
if (target->TargetSockAddr(&sock, &socklen) != 0)
|
if (target->TargetSockAddr(&sock, &socklen) != 0)
|
||||||
fatal("Unable to get target sock in sendconnecttcpquery");
|
fatal("Unable to get target sock in %s", __func__);
|
||||||
|
|
||||||
if (sin->sin_family == AF_INET)
|
if (sin->sin_family == AF_INET)
|
||||||
sin->sin_port = htons(o.ping_synprobes[probe_port_num]);
|
sin->sin_port = htons(o.ping_synprobes[probe_port_num]);
|
||||||
@@ -877,7 +877,7 @@ static int sendconnecttcpquery(Target *hostbatch[], struct tcpqueryinfo *tqi,
|
|||||||
}
|
}
|
||||||
else if (sock_err == ENETUNREACH) {
|
else if (sock_err == ENETUNREACH) {
|
||||||
if (o.debugging)
|
if (o.debugging)
|
||||||
error("Got ENETUNREACH from sendconnecttcpquery connect()");
|
error("Got ENETUNREACH from %s connect()", __func__);
|
||||||
hostupdate(hostbatch, target, HOST_DOWN, 1, trynum, to,
|
hostupdate(hostbatch, target, HOST_DOWN, 1, trynum, to,
|
||||||
&time[seq], NULL, pt, tqi, pingstyle_connecttcp);
|
&time[seq], NULL, pt, tqi, pingstyle_connecttcp);
|
||||||
}
|
}
|
||||||
@@ -1050,7 +1050,7 @@ if (ethsd) {
|
|||||||
datalen -= 12;
|
datalen -= 12;
|
||||||
pingpkt.type = 13;
|
pingpkt.type = 13;
|
||||||
}
|
}
|
||||||
else fatal("sendpingquery: unknown pingtype: %d", pingtype);
|
else fatal("%s: unknown pingtype: %d", __func__, pingtype);
|
||||||
|
|
||||||
if (o.extra_payload_length > 0) {
|
if (o.extra_payload_length > 0) {
|
||||||
icmplen += MIN(datalen, o.extra_payload_length);
|
icmplen += MIN(datalen, o.extra_payload_length);
|
||||||
@@ -1095,7 +1095,7 @@ if (ptech.icmpscan) {
|
|||||||
&& sock_err != WSAEADDRNOTAVAIL
|
&& sock_err != WSAEADDRNOTAVAIL
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
fprintf(stderr, "sendto in sendpingquery returned %d (should be 8)!\n", res);
|
fprintf(stderr, "sendto in %s returned %d (should be 8)!\n", __func__, res);
|
||||||
fprintf(stderr, "sendto: %s\n", strerror(sock_err));
|
fprintf(stderr, "sendto: %s\n", strerror(sock_err));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1243,7 +1243,7 @@ while(pt->block_unaccounted) {
|
|||||||
gettimeofday(&end, NULL);
|
gettimeofday(&end, NULL);
|
||||||
tm = TIMEVAL_SUBTRACT(end,start);
|
tm = TIMEVAL_SUBTRACT(end,start);
|
||||||
if (tm > (30 * to->timeout)) {
|
if (tm > (30 * to->timeout)) {
|
||||||
error("WARNING: getconnecttcpscanresults is taking way too long, skipping");
|
error("WARNING: %s is taking way too long, skipping", __func__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (res == 0 && tm > to->timeout) break;
|
if (res == 0 && tm > to->timeout) break;
|
||||||
@@ -1558,7 +1558,7 @@ static void massping(Target *hostbatch[], int num_hosts,
|
|||||||
|
|
||||||
if (ptech.icmpscan) {
|
if (ptech.icmpscan) {
|
||||||
sd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
|
sd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
|
||||||
if (sd < 0) pfatal("Socket trouble in massping");
|
if (sd < 0) pfatal("Socket trouble in %s", __func__);
|
||||||
unblock_socket(sd);
|
unblock_socket(sd);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
sethdrinclude(sd);
|
sethdrinclude(sd);
|
||||||
@@ -1587,14 +1587,14 @@ static void massping(Target *hostbatch[], int num_hosts,
|
|||||||
rawsd = -1; rawpingsd = -1;
|
rawsd = -1; rawpingsd = -1;
|
||||||
} else {
|
} else {
|
||||||
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
||||||
pfatal("socket troubles in massping");
|
pfatal("socket troubles in %s", __func__);
|
||||||
broadcast_socket(rawsd);
|
broadcast_socket(rawsd);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
sethdrinclude(rawsd);
|
sethdrinclude(rawsd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((rawpingsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
if ((rawpingsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
|
||||||
pfatal("socket troubles in massping");
|
pfatal("socket troubles in %s", __func__);
|
||||||
broadcast_socket(rawpingsd);
|
broadcast_socket(rawpingsd);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
sethdrinclude(rawpingsd);
|
sethdrinclude(rawpingsd);
|
||||||
@@ -1766,7 +1766,7 @@ do {
|
|||||||
)) {
|
)) {
|
||||||
hs->hostbatch[hidx]->TargetSockAddr(&ss, &sslen);
|
hs->hostbatch[hidx]->TargetSockAddr(&ss, &sslen);
|
||||||
if (!route_dst(&ss, &rnfo)) {
|
if (!route_dst(&ss, &rnfo)) {
|
||||||
fatal("%s: failed to determine route to %s", __FUNCTION__, hs->hostbatch[hidx]->NameIP());
|
fatal("%s: failed to determine route to %s", __func__, hs->hostbatch[hidx]->NameIP());
|
||||||
}
|
}
|
||||||
if (rnfo.direct_connect) {
|
if (rnfo.direct_connect) {
|
||||||
hs->hostbatch[hidx]->setDirectlyConnected(true);
|
hs->hostbatch[hidx]->setDirectlyConnected(true);
|
||||||
@@ -1845,7 +1845,7 @@ if (hs->randomize) {
|
|||||||
!hs->hostbatch[i]->timedOut(&now))
|
!hs->hostbatch[i]->timedOut(&now))
|
||||||
if (!setTargetNextHopMAC(hs->hostbatch[i]))
|
if (!setTargetNextHopMAC(hs->hostbatch[i]))
|
||||||
fatal("%s: Failed to determine dst MAC address for target %s",
|
fatal("%s: Failed to determine dst MAC address for target %s",
|
||||||
__FUNCTION__, hs->hostbatch[i]->NameIP());
|
__func__, hs->hostbatch[i]->NameIP());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Maybe I should allow real ping scan of directly connected
|
/* TODO: Maybe I should allow real ping scan of directly connected
|
||||||
|
|||||||
74
tcpip.cc
74
tcpip.cc
@@ -202,7 +202,7 @@ char *getFinalPacketStats(char *buf, int buflen) {
|
|||||||
char sendbytesasc[16], recvbytesasc[16];
|
char sendbytesasc[16], recvbytesasc[16];
|
||||||
|
|
||||||
if (buflen <= 10 || !buf)
|
if (buflen <= 10 || !buf)
|
||||||
fatal("getFinalPacketStats called with woefully inadequate parameters");
|
fatal("%s called with woefully inadequate parameters", __func__);
|
||||||
|
|
||||||
snprintf(buf, buflen,
|
snprintf(buf, buflen,
|
||||||
#if WIN32
|
#if WIN32
|
||||||
@@ -785,7 +785,7 @@ const char *inet_socktop(struct sockaddr_storage *ss) {
|
|||||||
(char *) NULL,
|
(char *) NULL,
|
||||||
#endif /* HAVE_IPV6 */
|
#endif /* HAVE_IPV6 */
|
||||||
buf, sizeof(buf)) == NULL) {
|
buf, sizeof(buf)) == NULL) {
|
||||||
fatal("Failed to convert target address to presentation format in inet_socktop!?! Error: %s", strerror(socket_errno()));
|
fatal("Failed to convert target address to presentation format in %s!?! Error: %s", __func__, strerror(socket_errno()));
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@@ -1018,7 +1018,7 @@ int resolve(char *hostname, struct in_addr *ip) {
|
|||||||
struct hostent *h;
|
struct hostent *h;
|
||||||
|
|
||||||
if (!hostname || !*hostname)
|
if (!hostname || !*hostname)
|
||||||
fatal("NULL or zero-length hostname passed to resolve()");
|
fatal("NULL or zero-length hostname passed to %s()", __func__);
|
||||||
|
|
||||||
if (inet_pton(AF_INET, hostname, ip))
|
if (inet_pton(AF_INET, hostname, ip))
|
||||||
return 1; /* damn, that was easy ;) */
|
return 1; /* damn, that was easy ;) */
|
||||||
@@ -1038,8 +1038,8 @@ int resolve(char *hostname, struct in_addr *ip) {
|
|||||||
call eth_close_cached() to close whichever device (if any) is
|
call eth_close_cached() to close whichever device (if any) is
|
||||||
cached. Returns NULL if it fails to open the device. */
|
cached. Returns NULL if it fails to open the device. */
|
||||||
eth_t *eth_open_cached(const char *device) {
|
eth_t *eth_open_cached(const char *device) {
|
||||||
if (!device) fatal("eth_open_cached() called with NULL device name!");
|
if (!device) fatal("%s() called with NULL device name!", __func__);
|
||||||
if (!*device) fatal("eth_open_cached() called with empty device name!");
|
if (!*device) fatal("%s() called with empty device name!", __func__);
|
||||||
|
|
||||||
if (strcmp(device, etht_cache_device_name) == 0) {
|
if (strcmp(device, etht_cache_device_name) == 0) {
|
||||||
/* Yay, we have it cached. */
|
/* Yay, we have it cached. */
|
||||||
@@ -1163,7 +1163,7 @@ assert(source);
|
|||||||
assert(ipoptlen%4==0);
|
assert(ipoptlen%4==0);
|
||||||
|
|
||||||
if (tcpoptlen % 4)
|
if (tcpoptlen % 4)
|
||||||
fatal("build_tcp_raw() called with an option length argument of %d which is illegal because it is not divisible by 4. Just add \\0 padding to the end.", tcpoptlen);
|
fatal("%s() called with an option length argument of %d which is illegal because it is not divisible by 4. Just add \\0 padding to the end.", __func__, tcpoptlen);
|
||||||
|
|
||||||
|
|
||||||
/* Time to live */
|
/* Time to live */
|
||||||
@@ -1319,7 +1319,7 @@ do {
|
|||||||
strerror(err));
|
strerror(err));
|
||||||
error("Offending packet: %s", ippackethdrinfo(packet, len));
|
error("Offending packet: %s", ippackethdrinfo(packet, len));
|
||||||
if (numerrors == 10) {
|
if (numerrors == 10) {
|
||||||
error("Omitting future Sendto error messages now that %d have been shown. Use -d2 if you really want to see them.", numerrors);
|
error("Omitting future %s error messages now that %d have been shown. Use -d2 if you really want to see them.", __func__, numerrors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1368,7 +1368,7 @@ int send_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, unsigned int packetl
|
|||||||
if (!eth->ethsd) {
|
if (!eth->ethsd) {
|
||||||
ethsd = eth_open_cached(eth->devname);
|
ethsd = eth_open_cached(eth->devname);
|
||||||
if (!ethsd)
|
if (!ethsd)
|
||||||
fatal("send_ip_packet: Failed to open ethernet device (%s)", eth->devname);
|
fatal("%s: Failed to open ethernet device (%s)", __func__, eth->devname);
|
||||||
ethsd_opened = true;
|
ethsd_opened = true;
|
||||||
} else ethsd = eth->ethsd;
|
} else ethsd = eth->ethsd;
|
||||||
res = eth_send(ethsd, eth_frame, 14 + packetlen);
|
res = eth_send(ethsd, eth_frame, 14 + packetlen);
|
||||||
@@ -1454,7 +1454,7 @@ char *ping = (char *) &pingpkt;
|
|||||||
*datastart++ = 0;
|
*datastart++ = 0;
|
||||||
//datalen -= 4;
|
//datalen -= 4;
|
||||||
} else
|
} else
|
||||||
fatal("Unknown icmp type/code (%d/%d) in build_icmp_raw", ptype, pcode);
|
fatal("Unknown icmp type/code (%d/%d) in %s", ptype, pcode, __func__);
|
||||||
|
|
||||||
if (datalen > 0) {
|
if (datalen > 0) {
|
||||||
icmplen += MIN(dlen, datalen);
|
icmplen += MIN(dlen, datalen);
|
||||||
@@ -1516,7 +1516,7 @@ u8 *build_igmp_raw(const struct in_addr *source, const struct in_addr *victim,
|
|||||||
} else if (ptype == 0x22) { /* v3 Membership Report */
|
} else if (ptype == 0x22) { /* v3 Membership Report */
|
||||||
igmplen = 8;
|
igmplen = 8;
|
||||||
} else {
|
} else {
|
||||||
fatal("Unknown igmp type (%d) in build_igmp_raw", ptype);
|
fatal("Unknown igmp type (%d) in %s", ptype, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datalen > 0) {
|
if (datalen > 0) {
|
||||||
@@ -1553,7 +1553,7 @@ int i;
|
|||||||
int realfrag = 0;
|
int realfrag = 0;
|
||||||
|
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
fprintf(stderr, "readtcppacket: packet is NULL!\n");
|
fprintf(stderr, "%s: packet is NULL!\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1613,7 +1613,7 @@ int i;
|
|||||||
int realfrag = 0;
|
int realfrag = 0;
|
||||||
|
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
fprintf(stderr, "readudppacket: packet is NULL!\n");
|
fprintf(stderr, "%s: packet is NULL!\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1886,12 +1886,12 @@ static int warning = 0;
|
|||||||
|
|
||||||
if (linknfo) { memset(linknfo, 0, sizeof(*linknfo)); }
|
if (linknfo) { memset(linknfo, 0, sizeof(*linknfo)); }
|
||||||
|
|
||||||
if (!pd) fatal("NULL packet device passed to readip_pcap");
|
if (!pd) fatal("NULL packet device passed to %s", __func__);
|
||||||
|
|
||||||
if (to_usec < 0) {
|
if (to_usec < 0) {
|
||||||
if (!warning) {
|
if (!warning) {
|
||||||
warning = 1;
|
warning = 1;
|
||||||
error("WARNING: Negative timeout value (%lu) passed to readip_pcap() -- using 0", to_usec);
|
error("WARNING: Negative timeout value (%lu) passed to %s() -- using 0", to_usec, __func__);
|
||||||
}
|
}
|
||||||
to_usec = 0;
|
to_usec = 0;
|
||||||
}
|
}
|
||||||
@@ -1959,7 +1959,7 @@ if (!pd) fatal("NULL packet device passed to readip_pcap");
|
|||||||
p = (char *) pcap_next(pd, &head);
|
p = (char *) pcap_next(pd, &head);
|
||||||
}
|
}
|
||||||
if (head.caplen > 100000) {
|
if (head.caplen > 100000) {
|
||||||
fatal("FATAL: readip_pcap: bogus caplen from libpcap (%d) on interface type %d", head.caplen, datalink);
|
fatal("FATAL: %s: bogus caplen from libpcap (%d) on interface type %d", __func__, head.caplen, datalink);
|
||||||
}
|
}
|
||||||
error("FATAL: Unknown datalink type (%d). Caplen: %d; Packet:\n", datalink, head.caplen);
|
error("FATAL: Unknown datalink type (%d). Caplen: %d; Packet:\n", datalink, head.caplen);
|
||||||
lamont_hdump(p, head.caplen);
|
lamont_hdump(p, head.caplen);
|
||||||
@@ -2106,7 +2106,7 @@ static bool NmapArpCache(int command, struct sockaddr_storage *ss, u8 *mac) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (sin->sin_family != AF_INET)
|
if (sin->sin_family != AF_INET)
|
||||||
fatal("NmapArpCache() can only take IPv4 addresses. Sorry");
|
fatal("%s() can only take IPv4 addresses. Sorry", __func__);
|
||||||
|
|
||||||
if (command == ARPCACHE_GET) {
|
if (command == ARPCACHE_GET) {
|
||||||
for(i=0; i < ArpCacheSz; i++) {
|
for(i=0; i < ArpCacheSz; i++) {
|
||||||
@@ -2156,12 +2156,12 @@ int read_arp_reply_pcap(pcap_t *pd, u8 *sendermac, struct in_addr *senderIP,
|
|||||||
int badcounter = 0;
|
int badcounter = 0;
|
||||||
struct timeval tv_start, tv_end;
|
struct timeval tv_start, tv_end;
|
||||||
|
|
||||||
if (!pd) fatal("NULL packet device passed to readarp_reply_pcap");
|
if (!pd) fatal("NULL packet device passed to %s", __func__);
|
||||||
|
|
||||||
if (to_usec < 0) {
|
if (to_usec < 0) {
|
||||||
if (!warning) {
|
if (!warning) {
|
||||||
warning = 1;
|
warning = 1;
|
||||||
error("WARNING: Negative timeout value (%lu) passed to %s() -- using 0", to_usec, __FUNCTION__);
|
error("WARNING: Negative timeout value (%lu) passed to %s() -- using 0", to_usec, __func__);
|
||||||
}
|
}
|
||||||
to_usec = 0;
|
to_usec = 0;
|
||||||
}
|
}
|
||||||
@@ -2171,7 +2171,7 @@ int read_arp_reply_pcap(pcap_t *pd, u8 *sendermac, struct in_addr *senderIP,
|
|||||||
fatal("Cannot obtain datalink information: %s", pcap_geterr(pd));
|
fatal("Cannot obtain datalink information: %s", pcap_geterr(pd));
|
||||||
|
|
||||||
if (datalink != DLT_EN10MB)
|
if (datalink != DLT_EN10MB)
|
||||||
fatal("readarp_reply_pcap called on interfaces that is datatype %d rather than DLT_EN10MB (%d)", datalink, DLT_EN10MB);
|
fatal("%s called on interfaces that is datatype %d rather than DLT_EN10MB (%d)", __func__, datalink, DLT_EN10MB);
|
||||||
|
|
||||||
if (to_usec > 0) {
|
if (to_usec > 0) {
|
||||||
gettimeofday(&tv_start, NULL);
|
gettimeofday(&tv_start, NULL);
|
||||||
@@ -2317,7 +2317,7 @@ static bool doArp(const char *dev, const u8 *srcmac,
|
|||||||
bool foundit = false;
|
bool foundit = false;
|
||||||
|
|
||||||
if (targetsin->sin_family != AF_INET || srcsin->sin_family != AF_INET)
|
if (targetsin->sin_family != AF_INET || srcsin->sin_family != AF_INET)
|
||||||
fatal("%s can only handle IPv4 addresses", __FUNCTION__);
|
fatal("%s can only handle IPv4 addresses", __func__);
|
||||||
|
|
||||||
/* Start listening */
|
/* Start listening */
|
||||||
pd = my_pcap_open_live(dev, 50, 1, 25);
|
pd = my_pcap_open_live(dev, 50, 1, 25);
|
||||||
@@ -2325,7 +2325,7 @@ static bool doArp(const char *dev, const u8 *srcmac,
|
|||||||
|
|
||||||
/* Prepare probe and sending stuff */
|
/* Prepare probe and sending stuff */
|
||||||
ethsd = eth_open_cached(dev);
|
ethsd = eth_open_cached(dev);
|
||||||
if (!ethsd) fatal("%s: failed to open device %s", __FUNCTION__, dev);
|
if (!ethsd) fatal("%s: failed to open device %s", __func__, dev);
|
||||||
eth_pack_hdr(frame, ETH_ADDR_BROADCAST, *srcmac, ETH_TYPE_ARP);
|
eth_pack_hdr(frame, ETH_ADDR_BROADCAST, *srcmac, ETH_TYPE_ARP);
|
||||||
arp_pack_hdr_ethip(frame + ETH_HDR_LEN, ARP_OP_REQUEST, *srcmac,
|
arp_pack_hdr_ethip(frame + ETH_HDR_LEN, ARP_OP_REQUEST, *srcmac,
|
||||||
srcsin->sin_addr, ETH_ADDR_BROADCAST,
|
srcsin->sin_addr, ETH_ADDR_BROADCAST,
|
||||||
@@ -2337,7 +2337,7 @@ static bool doArp(const char *dev, const u8 *srcmac,
|
|||||||
/* Send the sucker */
|
/* Send the sucker */
|
||||||
rc = eth_send(ethsd, frame, sizeof(frame));
|
rc = eth_send(ethsd, frame, sizeof(frame));
|
||||||
if (rc != sizeof(frame)) {
|
if (rc != sizeof(frame)) {
|
||||||
error("WARNING: %s: eth_send of ARP packet returned %u rather than expected %d bytes\n", __FUNCTION__, rc, (int) sizeof(frame));
|
error("WARNING: %s: eth_send of ARP packet returned %u rather than expected %d bytes\n", __func__, rc, (int) sizeof(frame));
|
||||||
}
|
}
|
||||||
PacketTrace::traceArp(PacketTrace::SENT, (u8 *) frame, sizeof(frame), &now);
|
PacketTrace::traceArp(PacketTrace::SENT, (u8 *) frame, sizeof(frame), &now);
|
||||||
num_sends++;
|
num_sends++;
|
||||||
@@ -2354,7 +2354,7 @@ static bool doArp(const char *dev, const u8 *srcmac,
|
|||||||
/* Now listen until we reach our next timeout or get an answer */
|
/* Now listen until we reach our next timeout or get an answer */
|
||||||
rc = read_arp_reply_pcap(pd, targetmac, &rcvdIP, timeleft, &rcvdtime);
|
rc = read_arp_reply_pcap(pd, targetmac, &rcvdIP, timeleft, &rcvdtime);
|
||||||
if (rc == -1) fatal("%s: Received -1 response from readarp_reply_pcap",
|
if (rc == -1) fatal("%s: Received -1 response from readarp_reply_pcap",
|
||||||
__FUNCTION__);
|
__func__);
|
||||||
if (rc == 1) {
|
if (rc == 1) {
|
||||||
/* Yay, I got one! But is it the right one? */
|
/* Yay, I got one! But is it the right one? */
|
||||||
if (rcvdIP.s_addr != targetsin->sin_addr.s_addr)
|
if (rcvdIP.s_addr != targetsin->sin_addr.s_addr)
|
||||||
@@ -2405,7 +2405,7 @@ bool setTargetNextHopMAC(Target *target) {
|
|||||||
target->TargetSockAddr(&targetss, &sslen);
|
target->TargetSockAddr(&targetss, &sslen);
|
||||||
} else {
|
} else {
|
||||||
if (!target->nextHop(&targetss, &sslen))
|
if (!target->nextHop(&targetss, &sslen))
|
||||||
fatal("%s: Failed to determine nextHop to target", __FUNCTION__);
|
fatal("%s: Failed to determine nextHop to target", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First, let us check the Nmap arp cache ... */
|
/* First, let us check the Nmap arp cache ... */
|
||||||
@@ -2458,7 +2458,7 @@ void set_pcap_filter(const char *device,
|
|||||||
|
|
||||||
va_start(ap, bpf);
|
va_start(ap, bpf);
|
||||||
if (vsnprintf(buf, sizeof(buf), bpf, ap) >= (int) sizeof(buf))
|
if (vsnprintf(buf, sizeof(buf), bpf, ap) >= (int) sizeof(buf))
|
||||||
fatal("set_pcap_filter called with too-large filter arg\n");
|
fatal("%s called with too-large filter arg\n", __func__);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
/* Due to apparent bug in libpcap */
|
/* Due to apparent bug in libpcap */
|
||||||
@@ -2663,9 +2663,9 @@ int sd;
|
|||||||
dcrn.ifaces = mydevs;
|
dcrn.ifaces = mydevs;
|
||||||
dcrn.numifaces = 0;
|
dcrn.numifaces = 0;
|
||||||
it = intf_open();
|
it = intf_open();
|
||||||
if (!it) fatal("%s: intf_open() failed", __FUNCTION__);
|
if (!it) fatal("%s: intf_open() failed", __func__);
|
||||||
if (intf_loop(it, collect_dnet_interfaces, &dcrn) != 0)
|
if (intf_loop(it, collect_dnet_interfaces, &dcrn) != 0)
|
||||||
fatal("%s: intf_loop() failed", __FUNCTION__);
|
fatal("%s: intf_loop() failed", __func__);
|
||||||
intf_close(it);
|
intf_close(it);
|
||||||
mydevs = dcrn.ifaces;
|
mydevs = dcrn.ifaces;
|
||||||
numifaces = dcrn.numifaces;
|
numifaces = dcrn.numifaces;
|
||||||
@@ -2673,7 +2673,7 @@ int sd;
|
|||||||
#else // !Win32
|
#else // !Win32
|
||||||
/* Dummy socket for ioctl */
|
/* Dummy socket for ioctl */
|
||||||
sd = socket(AF_INET, SOCK_DGRAM, 0);
|
sd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (sd < 0) pfatal("socket in getinterfaces");
|
if (sd < 0) pfatal("socket in %s", __func__);
|
||||||
bufsz = 20480;
|
bufsz = 20480;
|
||||||
buf = (u8 *) safe_zalloc(bufsz);
|
buf = (u8 *) safe_zalloc(bufsz);
|
||||||
ifc.ifc_len = bufsz;
|
ifc.ifc_len = bufsz;
|
||||||
@@ -2683,7 +2683,7 @@ int sd;
|
|||||||
}
|
}
|
||||||
ifr = (struct ifreq *) buf;
|
ifr = (struct ifreq *) buf;
|
||||||
if (ifc.ifc_len == 0)
|
if (ifc.ifc_len == 0)
|
||||||
fatal("getinterfaces: SIOCGIFCONF claims you have no network interfaces!\n");
|
fatal("%s: SIOCGIFCONF claims you have no network interfaces!\n", __func__);
|
||||||
#if HAVE_SOCKADDR_SA_LEN
|
#if HAVE_SOCKADDR_SA_LEN
|
||||||
/* len = MAX(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);*/
|
/* len = MAX(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);*/
|
||||||
len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
|
len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
|
||||||
@@ -2771,11 +2771,11 @@ int sd;
|
|||||||
eth_addr_t ethaddr;
|
eth_addr_t ethaddr;
|
||||||
|
|
||||||
if (!ethsd)
|
if (!ethsd)
|
||||||
fatal("%s: Failed to open ethernet interface (%s). A possible cause on BSD operating systems is running out of BPF devices (see http://seclists.org/lists/nmap-dev/2006/Jan-Mar/0014.html).", __FUNCTION__,
|
fatal("%s: Failed to open ethernet interface (%s). A possible cause on BSD operating systems is running out of BPF devices (see http://seclists.org/lists/nmap-dev/2006/Jan-Mar/0014.html).", __func__,
|
||||||
mydevs[numifaces].devname);
|
mydevs[numifaces].devname);
|
||||||
if (eth_get(ethsd, ðaddr) != 0)
|
if (eth_get(ethsd, ðaddr) != 0)
|
||||||
fatal("%s: Failed to obtain MAC address for ethernet interface (%s)",
|
fatal("%s: Failed to obtain MAC address for ethernet interface (%s)",
|
||||||
__FUNCTION__, mydevs[numifaces].devname);
|
__func__, mydevs[numifaces].devname);
|
||||||
memcpy(mydevs[numifaces].mac, ethaddr.data, 6);
|
memcpy(mydevs[numifaces].mac, ethaddr.data, 6);
|
||||||
#endif /*SIOCGIFHWADDR*/
|
#endif /*SIOCGIFHWADDR*/
|
||||||
|
|
||||||
@@ -2812,7 +2812,7 @@ struct interface_info *getInterfaceByIP(struct sockaddr_storage *ss) {
|
|||||||
int ifnum;
|
int ifnum;
|
||||||
|
|
||||||
if (sin->sin_family != AF_INET)
|
if (sin->sin_family != AF_INET)
|
||||||
fatal("%s called with non-IPv4 address", __FUNCTION__);
|
fatal("%s called with non-IPv4 address", __func__);
|
||||||
|
|
||||||
ifaces = getinterfaces(&numifaces);
|
ifaces = getinterfaces(&numifaces);
|
||||||
|
|
||||||
@@ -2877,7 +2877,7 @@ struct sys_route *getsysroutes(int *howmany) {
|
|||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
struct interface_info *ii;
|
struct interface_info *ii;
|
||||||
|
|
||||||
if (!howmany) fatal("NULL howmany ptr passed to getsysroutes()");
|
if (!howmany) fatal("NULL howmany ptr passed to %s()", __func__);
|
||||||
|
|
||||||
if (!routes) {
|
if (!routes) {
|
||||||
routes = (struct sys_route *) safe_zalloc(route_capacity * sizeof(struct sys_route));
|
routes = (struct sys_route *) safe_zalloc(route_capacity * sizeof(struct sys_route));
|
||||||
@@ -2974,9 +2974,9 @@ struct sys_route *getsysroutes(int *howmany) {
|
|||||||
dcrn.ifaces = ifaces;
|
dcrn.ifaces = ifaces;
|
||||||
dcrn.numifaces = numifaces;
|
dcrn.numifaces = numifaces;
|
||||||
route_t *dr = route_open();
|
route_t *dr = route_open();
|
||||||
if (!dr) fatal("%s: route_open() failed", __FUNCTION__);
|
if (!dr) fatal("%s: route_open() failed", __func__);
|
||||||
if (route_loop(dr, collect_dnet_routes, &dcrn) != 0) {
|
if (route_loop(dr, collect_dnet_routes, &dcrn) != 0) {
|
||||||
fatal("%s: route_loop() failed", __FUNCTION__);
|
fatal("%s: route_loop() failed", __func__);
|
||||||
}
|
}
|
||||||
route_close(dr);
|
route_close(dr);
|
||||||
/* These values could have changed in the callback */
|
/* These values could have changed in the callback */
|
||||||
@@ -3019,11 +3019,11 @@ bool route_dst(const struct sockaddr_storage *const dst, struct route_nfo *rnfo)
|
|||||||
int i;
|
int i;
|
||||||
u32 mask;
|
u32 mask;
|
||||||
struct sockaddr_in *ifsin, *dstsin;
|
struct sockaddr_in *ifsin, *dstsin;
|
||||||
if (!dst) fatal("route_nfo passed a NULL dst address");
|
if (!dst) fatal("%s passed a NULL dst address", __func__);
|
||||||
dstsin = (struct sockaddr_in *)dst;
|
dstsin = (struct sockaddr_in *)dst;
|
||||||
|
|
||||||
if (dstsin->sin_family != AF_INET)
|
if (dstsin->sin_family != AF_INET)
|
||||||
fatal("Sorry -- route_dst currently only supports IPv4");
|
fatal("Sorry -- %s currently only supports IPv4", __func__);
|
||||||
|
|
||||||
/* First let us deal with the case where a user requested a specific spoofed IP/dev */
|
/* First let us deal with the case where a user requested a specific spoofed IP/dev */
|
||||||
if (o.spoofsource || *o.device) {
|
if (o.spoofsource || *o.device) {
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ void adjust_timeouts2(const struct timeval *sent,
|
|||||||
else {
|
else {
|
||||||
if (delta >= 8000000 || delta < 0) {
|
if (delta >= 8000000 || delta < 0) {
|
||||||
if (o.verbose)
|
if (o.verbose)
|
||||||
error("adjust_timeout: packet supposedly had rtt of %lu microseconds. Ignoring time.", delta);
|
error("%s: packet supposedly had rtt of %lu microseconds. Ignoring time.", __func__, delta);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delta -= to->srtt;
|
delta -= to->srtt;
|
||||||
@@ -225,7 +225,7 @@ void enforce_scan_delay(struct timeval *tv) {
|
|||||||
time_diff = TIMEVAL_MSEC_SUBTRACT(now, lastcall);
|
time_diff = TIMEVAL_MSEC_SUBTRACT(now, lastcall);
|
||||||
if (time_diff < (int) o.scan_delay) {
|
if (time_diff < (int) o.scan_delay) {
|
||||||
if (o.debugging > 1) {
|
if (o.debugging > 1) {
|
||||||
printf("Sleeping for %d milliseconds in enforce_scan_delay()\n", o.scan_delay - time_diff);
|
printf("Sleeping for %d milliseconds in %s()\n", o.scan_delay - time_diff, __func__);
|
||||||
}
|
}
|
||||||
usleep((o.scan_delay - time_diff) * 1000);
|
usleep((o.scan_delay - time_diff) * 1000);
|
||||||
gettimeofday(&lastcall, NULL);
|
gettimeofday(&lastcall, NULL);
|
||||||
|
|||||||
@@ -1445,8 +1445,8 @@ enforce_scan_delay (struct timeval *tv, int scan_delay) {
|
|||||||
time_diff = TIMEVAL_MSEC_SUBTRACT (now, lastcall);
|
time_diff = TIMEVAL_MSEC_SUBTRACT (now, lastcall);
|
||||||
if (time_diff < (int) scan_delay) {
|
if (time_diff < (int) scan_delay) {
|
||||||
if (o.debugging > 2)
|
if (o.debugging > 2)
|
||||||
log_write (LOG_STDOUT, "Sleeping for %d milliseconds in enforce_scan_delay()\n",
|
log_write (LOG_STDOUT, "Sleeping for %d milliseconds in %s()\n",
|
||||||
scan_delay - time_diff);
|
scan_delay - time_diff, __func__);
|
||||||
usleep ((scan_delay - time_diff) * 1000);
|
usleep ((scan_delay - time_diff) * 1000);
|
||||||
gettimeofday (&lastcall, NULL);
|
gettimeofday (&lastcall, NULL);
|
||||||
} else
|
} else
|
||||||
|
|||||||
8
utils.cc
8
utils.cc
@@ -338,7 +338,7 @@ unsigned char *tmp;
|
|||||||
int bpe;
|
int bpe;
|
||||||
|
|
||||||
if (sizeof(unsigned char) != 1)
|
if (sizeof(unsigned char) != 1)
|
||||||
fatal("genfry() requires 1 byte chars");
|
fatal("%s() requires 1 byte chars", __func__);
|
||||||
|
|
||||||
if (num_elem < 2)
|
if (num_elem < 2)
|
||||||
return;
|
return;
|
||||||
@@ -1059,8 +1059,8 @@ char *mmapfile(char *fname, int *length, int openflags)
|
|||||||
CloseHandle (fd);
|
CloseHandle (fd);
|
||||||
|
|
||||||
if (o.debugging > 2)
|
if (o.debugging > 2)
|
||||||
printf ("mmapfile(): fd %08lX, gmap %08lX, fileptr %08lX, length %d\n",
|
printf ("%s(): fd %08lX, gmap %08lX, fileptr %08lX, length %d\n",
|
||||||
(DWORD)fd, (DWORD)gmap, (DWORD)fileptr, *length);
|
__func__, (DWORD)fd, (DWORD)gmap, (DWORD)fileptr, *length);
|
||||||
|
|
||||||
return fileptr;
|
return fileptr;
|
||||||
}
|
}
|
||||||
@@ -1071,7 +1071,7 @@ char *mmapfile(char *fname, int *length, int openflags)
|
|||||||
int win32_munmap(char *filestr, int filelen)
|
int win32_munmap(char *filestr, int filelen)
|
||||||
{
|
{
|
||||||
if (gmap == 0)
|
if (gmap == 0)
|
||||||
fatal("win32_munmap: no current mapping !\n");
|
fatal("%s: no current mapping !\n", __func__);
|
||||||
|
|
||||||
FlushViewOfFile(filestr, filelen);
|
FlushViewOfFile(filestr, filelen);
|
||||||
UnmapViewOfFile(filestr);
|
UnmapViewOfFile(filestr);
|
||||||
|
|||||||
Reference in New Issue
Block a user