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

o Fix a bunch of warning/error messages which contained an extra

newline.  Thanks to Brandon Enright for the patch.
This commit is contained in:
fyodor
2007-12-21 03:38:04 +00:00
parent c0bd7ac21b
commit 09512ff092
12 changed files with 33 additions and 29 deletions

View File

@@ -1,5 +1,8 @@
# Nmap Changelog ($Id$); -*-text-*- # Nmap Changelog ($Id$); -*-text-*-
o Fix a bunch of warning/error messages which contained an extra
newline. Thanks to Brandon Enright for the patch.
o Added rpcinfo.nse script, which contacts a listening RPC portmapper o Added rpcinfo.nse script, which contacts a listening RPC portmapper
and reports the listening services and port information (like and reports the listening services and port information (like
rpcinfo -p does). The script was written by Sven Klemm. Fyodor rpcinfo -p does). The script was written by Sven Klemm. Fyodor

View File

@@ -855,7 +855,7 @@ static int idle_treescan(struct idle_proxy_info *proxy, Target *target,
if (o.debugging > 1) { if (o.debugging > 1) {
error("%s: Called against %s with %d ports, starting with %hu. expectedopen: %d", __func__, 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("IDLE SCAN TIMING: grpsz: %.3f delay: %d srtt: %d rttvar: %d\n", error("IDLE SCAN TIMING: grpsz: %.3f delay: %d srtt: %d rttvar: %d",
proxy->current_groupsz, proxy->senddelay, target->to.srtt, proxy->current_groupsz, proxy->senddelay, target->to.srtt,
target->to.rttvar); target->to.rttvar);
} }

View File

@@ -2787,7 +2787,7 @@ int nmap_fetchfile(char *filename_returned, int bufferlen, char *file) {
} }
if (foundsomething && o.debugging > 1) if (foundsomething && o.debugging > 1)
error("Fetchfile found %s\n", filename_returned); error("Fetchfile found %s", filename_returned);
return foundsomething; return foundsomething;

View File

@@ -77,12 +77,12 @@ int init_setlualibpath(lua_State* l){
/* set the path lua searches for modules*/ /* set the path lua searches for modules*/
if(nmap_fetchfile(path, MAX_FILENAME_LEN, SCRIPT_ENGINE_LIB_DIR)!=2){ if(nmap_fetchfile(path, MAX_FILENAME_LEN, SCRIPT_ENGINE_LIB_DIR)!=2){
/*SCRIPT_ENGINE_LIB_DIR is not a directory - error */ /*SCRIPT_ENGINE_LIB_DIR is not a directory - error */
error("%s: %s not a directory\n", SCRIPT_ENGINE, SCRIPT_ENGINE_LIB_DIR); error("%s: %s not a directory", SCRIPT_ENGINE, SCRIPT_ENGINE_LIB_DIR);
return SCRIPT_ENGINE_ERROR; return SCRIPT_ENGINE_ERROR;
} }
if(nmap_fetchfile(cpath, MAX_FILENAME_LEN, SCRIPT_ENGINE_LIBEXEC_DIR)!=2){ if(nmap_fetchfile(cpath, MAX_FILENAME_LEN, SCRIPT_ENGINE_LIBEXEC_DIR)!=2){
error("%s: %s not a directory\n", SCRIPT_ENGINE, SCRIPT_ENGINE_LIBEXEC_DIR); error("%s: %s not a directory", SCRIPT_ENGINE, SCRIPT_ENGINE_LIBEXEC_DIR);
return SCRIPT_ENGINE_ERROR; return SCRIPT_ENGINE_ERROR;
} }
@@ -159,7 +159,7 @@ int init_parseargs(lua_State* l){
lua_pushstring(l,"[{}]"); lua_pushstring(l,"[{}]");
SCRIPT_ENGINE_TRY(lua_pcall(l,2,1,0)); SCRIPT_ENGINE_TRY(lua_pcall(l,2,1,0));
if(!lua_isnil(l,-1)){ if(!lua_isnil(l,-1)){
error("unbalanced brackets inside script-options!!\n"); error("unbalanced brackets inside script-options!!");
return SCRIPT_ENGINE_ERROR; return SCRIPT_ENGINE_ERROR;
} }
lua_settop(l,1); //clear stack lua_settop(l,1); //clear stack
@@ -334,7 +334,7 @@ int init_updatedb(lua_State* l) {
char* c_iter; char* c_iter;
if(nmap_fetchfile(path, sizeof(path)-sizeof(SCRIPT_ENGINE_DATABASE)-1, SCRIPT_ENGINE_LUA_DIR) == 0) { if(nmap_fetchfile(path, sizeof(path)-sizeof(SCRIPT_ENGINE_DATABASE)-1, SCRIPT_ENGINE_LUA_DIR) == 0) {
error("%s: Couldn't find '%s'\n.", SCRIPT_ENGINE, SCRIPT_ENGINE_LUA_DIR); error("%s: Couldn't find '%s'", SCRIPT_ENGINE, SCRIPT_ENGINE_LUA_DIR);
return SCRIPT_ENGINE_ERROR; return SCRIPT_ENGINE_ERROR;
} }

View File

@@ -225,7 +225,7 @@ finishup:
current_hosts.clear(); current_hosts.clear();
torun_scripts.clear(); torun_scripts.clear();
if(status != SCRIPT_ENGINE_SUCCESS) { if(status != SCRIPT_ENGINE_SUCCESS) {
error("%s: Aborting script scan.\n", SCRIPT_ENGINE); error("%s: Aborting script scan.", SCRIPT_ENGINE);
return SCRIPT_ENGINE_ERROR; return SCRIPT_ENGINE_ERROR;
} else { } else {
return SCRIPT_ENGINE_SUCCESS; return SCRIPT_ENGINE_SUCCESS;
@@ -364,7 +364,7 @@ int process_getScriptId(lua_State* l, struct script_scan_result *ssr) {
} else if(lua_isstring(l, -1)) { } else if(lua_isstring(l, -1)) {
ssr->id = strdup(lua_tostring (l, -1)); ssr->id = strdup(lua_tostring (l, -1));
} else { } else {
error("%s: The script has no 'id' entry, the 'filename' entry was changed to: \n", error("%s: The script has no 'id' entry, the 'filename' entry was changed to:",
SCRIPT_ENGINE); SCRIPT_ENGINE);
l_dumpValue(l, -1); l_dumpValue(l, -1);
return SCRIPT_ENGINE_ERROR; return SCRIPT_ENGINE_ERROR;

View File

@@ -248,7 +248,7 @@ static int AVal_match(struct AVal *reference, struct AVal *fprint, struct AVal *
*q1 = '\0'; number = strtol(p, NULL, 16); *q1 = '\0'; number = strtol(p, NULL, 16);
number1 = strtol(q1 + 1, NULL, 16); number1 = strtol(q1 + 1, NULL, 16);
if(number1 < number && o.debugging) { if(number1 < number && o.debugging) {
error("Range error in reference aval: %s=%s\n", current_ref->attribute, current_ref->value); error("Range error in reference aval: %s=%s", current_ref->attribute, current_ref->value);
} }
val = strtol(current_fp->value, &endptr, 16); val = strtol(current_fp->value, &endptr, 16);
if (val < number || val > number1 || *endptr) { if (andexp) { testfailed=1; break; } } if (val < number || val > number1 || *endptr) { if (andexp) { testfailed=1; break; } }

View File

@@ -2033,8 +2033,9 @@ bool HostOsScan::processTSeqResp(HostOsScanStats *hss, struct ip *ip, int replyN
if (seq_response_num != replyNo) { if (seq_response_num != replyNo) {
/* BzzT! Value out of range */ /* BzzT! Value out of range */
if (o.debugging) { if (o.debugging) {
error("Unable to associate os scan response with sent packet for %s.\nReceived ack: %lX; sequence sent: %lX. Packet:", error("Unable to associate os scan response with sent packet for %s.",
hss->target->targetipstr(), hss->target->targetipstr());
error("Received ack: %lX; sequence sent: %lX. Packet:",
(unsigned long) ntohl(tcp->th_ack), (unsigned long) ntohl(tcp->th_ack),
(unsigned long) tcpSeqBase); (unsigned long) tcpSeqBase);
readtcppacket((unsigned char *)ip,ntohs(ip->ip_len)); readtcppacket((unsigned char *)ip,ntohs(ip->ip_len));

View File

@@ -426,7 +426,7 @@ int PortList::addPort(u16 portno, u8 protocol, char *owner, int state) {
/* We must discount our statistics from the old values. Also warn /* We must discount our statistics from the old values. Also warn
if a complete duplicate */ if a complete duplicate */
if (o.debugging && current->state == state && (!owner || !*owner)) { if (o.debugging && current->state == state && (!owner || !*owner)) {
error("Duplicate port (%hu/%s)\n", portno, proto2ascii(protocol)); error("Duplicate port (%hu/%s)", portno, proto2ascii(protocol));
} }
state_counts_proto[proto][current->state]--; state_counts_proto[proto][current->state]--;
} else { } else {

View File

@@ -2581,7 +2581,7 @@ static UltraProbe *sendArpScanProbe(UltraScanInfo *USI, HostScanStats *hss,
hss->lastprobe_sent = probe->sent = USI->now; hss->lastprobe_sent = probe->sent = USI->now;
if ((rc = eth_send(USI->ethsd, frame, sizeof(frame))) != sizeof(frame)) { if ((rc = eth_send(USI->ethsd, frame, sizeof(frame))) != sizeof(frame)) {
int err = socket_errno(); int err = socket_errno();
error("WARNING: eth_send of ARP packet returned %i rather than expected %d (errno=%i: %s)\n", rc, (int) sizeof(frame), err, strerror(err)); error("WARNING: eth_send of ARP packet returned %i rather than expected %d (errno=%i: %s)", rc, (int) sizeof(frame), err, strerror(err));
} }
PacketTrace::traceArp(PacketTrace::SENT, (u8 *) frame, sizeof(frame), &USI->now); PacketTrace::traceArp(PacketTrace::SENT, (u8 *) frame, sizeof(frame), &USI->now);
probe->tryno = tryno; probe->tryno = tryno;
@@ -3584,7 +3584,7 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
} else newstate = PORT_CLOSED; } else newstate = PORT_CLOSED;
} else { } else {
if (o.debugging) if (o.debugging)
error("Received scan response with unexpected TCP flags: %d\n", tcp->th_flags); error("Received scan response with unexpected TCP flags: %d", tcp->th_flags);
break; break;
} }
} }
@@ -3611,7 +3611,7 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
8 xtra bytes */ 8 xtra bytes */
if (bytes < requiredbytes) { if (bytes < requiredbytes) {
if (o.debugging) if (o.debugging)
error("Received short ICMP packet (%d bytes)\n", bytes); error("Received short ICMP packet (%d bytes)", bytes);
continue; continue;
} }
@@ -3970,7 +3970,7 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
else if (ping->type == 3 || ping->type == 4 || ping->type == 11 || o.debugging) { else if (ping->type == 3 || ping->type == 4 || ping->type == 11 || o.debugging) {
if (bytes < ip->ip_hl * 4 + 28U) { if (bytes < ip->ip_hl * 4 + 28U) {
if (o.debugging) if (o.debugging)
error("ICMP type %d code %d packet is only %d bytes\n", ping->type, ping->code, bytes); error("ICMP type %d code %d packet is only %d bytes", ping->type, ping->code, bytes);
continue; continue;
} }
@@ -3979,7 +3979,7 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
/* IPProto Scan (generally) sends bare IP headers, so no extra payload */ /* IPProto Scan (generally) sends bare IP headers, so no extra payload */
if (bytes < ip->ip_hl * 4 + 8U + ip2->ip_hl * 4 + 8U && !USI->ptech.rawprotoscan) { if (bytes < ip->ip_hl * 4 + 8U + ip2->ip_hl * 4 + 8U && !USI->ptech.rawprotoscan) {
if (o.debugging) if (o.debugging)
error("ICMP (embedded) type %d code %d packet is only %d bytes\n", ping->type, ping->code, bytes); error("ICMP (embedded) type %d code %d packet is only %d bytes", ping->type, ping->code, bytes);
continue; continue;
} }
@@ -4063,7 +4063,7 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
goodseq = tcp_trynum_pingseq_decode(USI, tcp, &trynum, &pingseq); goodseq = tcp_trynum_pingseq_decode(USI, tcp, &trynum, &pingseq);
if (!goodseq) { if (!goodseq) {
if (o.debugging) if (o.debugging)
error("Bogus trynum or sequence number in ICMP error message\n"); error("Bogus trynum or sequence number in ICMP error message");
continue; continue;
} }
@@ -4203,7 +4203,7 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
continue; continue;
} }
if (bytes < 4 * ip->ip_hl + 16U) { if (bytes < 4 * ip->ip_hl + 16U) {
error("TCP packet is only %d bytes, we can't get enough information from it\n", bytes); error("TCP packet is only %d bytes, we can't get enough information from it", bytes);
continue; continue;
} }
struct tcp_hdr *tcp = (struct tcp_hdr *) (((u8 *) ip) + 4 * ip->ip_hl); struct tcp_hdr *tcp = (struct tcp_hdr *) (((u8 *) ip) + 4 * ip->ip_hl);

View File

@@ -2083,7 +2083,7 @@ static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *myd
if (status == NSE_STATUS_ERROR) { if (status == NSE_STATUS_ERROR) {
err = nse_errorcode(nse); err = nse_errorcode(nse);
error("Got nsock WRITE error #%d (%s)\n", err, strerror(err)); error("Got nsock WRITE error #%d (%s)", err, strerror(err));
} }
// Uh-oh. Some sort of write failure ... maybe the connection closed // Uh-oh. Some sort of write failure ... maybe the connection closed
@@ -2131,7 +2131,7 @@ static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *myda
// WOO HOO!!!!!! MATCHED! But might be soft // WOO HOO!!!!!! MATCHED! But might be soft
if (MD->isSoft && svc->probe_matched) { if (MD->isSoft && svc->probe_matched) {
if (strcmp(svc->probe_matched, MD->serviceName) != 0) if (strcmp(svc->probe_matched, MD->serviceName) != 0)
error("WARNING: service %s:%hi had allready soft-matched %s, but now soft-matched %s; ignoring second value\n", svc->target->NameIP(), svc->portno, svc->probe_matched, MD->serviceName); error("WARNING: service %s:%hi had allready soft-matched %s, but now soft-matched %s; ignoring second value", svc->target->NameIP(), svc->portno, svc->probe_matched, MD->serviceName);
// No error if its the same - that happens frequently. For // No error if its the same - that happens frequently. For
// example, if we read more data for the same probe response // example, if we read more data for the same probe response
// it will probably still match. // it will probably still match.

View File

@@ -140,7 +140,7 @@ static int nmap_services_init() {
else else
len = GetWindowsDirectory(filename, 480); // be safe len = GetWindowsDirectory(filename, 480); // be safe
if(!len) if(!len)
error("Get%sDirectory failed (%d) @#!#@\n", error("Get%sDirectory failed (%d) @#!#@",
wnt ? "System" : "Windows", GetLastError()); wnt ? "System" : "Windows", GetLastError());
else else
{ {

View File

@@ -1979,7 +1979,7 @@ if (!pd) fatal("NULL packet device passed to %s", __func__);
if (head.caplen > 100000) { if (head.caplen > 100000) {
fatal("FATAL: %s: bogus caplen from libpcap (%d) on interface type %d", __func__, 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:", datalink, head.caplen);
lamont_hdump(p, head.caplen); lamont_hdump(p, head.caplen);
exit(1); exit(1);
} }
@@ -2109,7 +2109,7 @@ void pcap_print_stats(int logt, pcap_t *pd) {
assert(pd != NULL); assert(pd != NULL);
if (pcap_stats(pd, &stat) < 0) { if (pcap_stats(pd, &stat) < 0) {
error("%s: %s\n", __func__, pcap_geterr(pd)); error("%s: %s", __func__, pcap_geterr(pd));
return; return;
} }
@@ -2175,7 +2175,7 @@ static bool NmapArpCache(int command, struct sockaddr_storage *ss, u8 *mac) {
descriptor pd. If it receives one, fills in sendermac (must pass descriptor pd. If it receives one, fills in sendermac (must pass
in 6 bytes), senderIP, and rcvdtime (can be NULL if you don't care) in 6 bytes), senderIP, and rcvdtime (can be NULL if you don't care)
and returns 1. If it times out and reads no arp requests, returns and returns 1. If it times out and reads no arp requests, returns
0. to_usec is the timeout period in microseconds. Use 0 to avoid 0. to_usec is the timeout periaod in microseconds. Use 0 to avoid
blocking to the extent possible. Returns blocking to the extent possible. Returns
-1 or exits if ther is an error. */ -1 or exits if ther is an error. */
int read_arp_reply_pcap(pcap_t *pd, u8 *sendermac, struct in_addr *senderIP, int read_arp_reply_pcap(pcap_t *pd, u8 *sendermac, struct in_addr *senderIP,
@@ -2369,7 +2369,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", __func__, rc, (int) sizeof(frame)); error("WARNING: %s: eth_send of ARP packet returned %u rather than expected %d bytes", __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++;
@@ -2504,7 +2504,7 @@ void set_pcap_filter(const char *device,
log_write(LOG_STDOUT, "Packet capture filter (device %s): %s\n", device, buf); log_write(LOG_STDOUT, "Packet capture filter (device %s): %s\n", device, buf);
if (pcap_compile(pd, &fcode, buf, 0, netmask) < 0) if (pcap_compile(pd, &fcode, buf, 0, netmask) < 0)
fatal("Error compiling our pcap filter: %s\n", pcap_geterr(pd)); fatal("Error compiling our pcap filter: %s", pcap_geterr(pd));
if (pcap_setfilter(pd, &fcode) < 0 ) if (pcap_setfilter(pd, &fcode) < 0 )
fatal("Failed to set the pcap filter: %s\n", pcap_geterr(pd)); fatal("Failed to set the pcap filter: %s\n", pcap_geterr(pd));
pcap_freecode(&fcode); pcap_freecode(&fcode);
@@ -2590,7 +2590,7 @@ static int collect_dnet_routes(const struct route_entry *entry, void *arg) {
} }
} }
if (i == dcrn->numifaces) { if (i == dcrn->numifaces) {
error("WARNING: Unable to find appropriate interface for system route to %s\n", addr_ntoa(&entry->route_gw)); error("WARNING: Unable to find appropriate interface for system route to %s", addr_ntoa(&entry->route_gw));
return 0; return 0;
} }
dcrn->numroutes++; dcrn->numroutes++;
@@ -2951,7 +2951,7 @@ struct sys_route *getsysroutes(int *howmany) {
endptr = NULL; endptr = NULL;
routes[numroutes].gw.s_addr = strtoul(p, &endptr, 16); routes[numroutes].gw.s_addr = strtoul(p, &endptr, 16);
if (!endptr || *endptr) { if (!endptr || *endptr) {
error("Failed to determine gw for %s from /proc/net/route\n", iface); error("Failed to determine gw for %s from /proc/net/route", iface);
} }
for(i=0; i < 5; i++) { for(i=0; i < 5; i++) {
p = strtok(NULL, " \t\n"); p = strtok(NULL, " \t\n");