diff --git a/CHANGELOG b/CHANGELOG index c1539f77c..b8be22ead 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # 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 and reports the listening services and port information (like rpcinfo -p does). The script was written by Sven Klemm. Fyodor diff --git a/idle_scan.cc b/idle_scan.cc index 9def9fb8d..67d970bb2 100644 --- a/idle_scan.cc +++ b/idle_scan.cc @@ -855,7 +855,7 @@ static int idle_treescan(struct idle_proxy_info *proxy, Target *target, 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("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, target->to.rttvar); } diff --git a/nmap.cc b/nmap.cc index 4a403dc63..53b40e19a 100644 --- a/nmap.cc +++ b/nmap.cc @@ -2787,7 +2787,7 @@ int nmap_fetchfile(char *filename_returned, int bufferlen, char *file) { } if (foundsomething && o.debugging > 1) - error("Fetchfile found %s\n", filename_returned); + error("Fetchfile found %s", filename_returned); return foundsomething; diff --git a/nse_init.cc b/nse_init.cc index d92d06757..dda021fd5 100644 --- a/nse_init.cc +++ b/nse_init.cc @@ -77,12 +77,12 @@ int init_setlualibpath(lua_State* l){ /* set the path lua searches for modules*/ if(nmap_fetchfile(path, MAX_FILENAME_LEN, SCRIPT_ENGINE_LIB_DIR)!=2){ /*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; } 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; } @@ -159,7 +159,7 @@ int init_parseargs(lua_State* l){ lua_pushstring(l,"[{}]"); SCRIPT_ENGINE_TRY(lua_pcall(l,2,1,0)); if(!lua_isnil(l,-1)){ - error("unbalanced brackets inside script-options!!\n"); + error("unbalanced brackets inside script-options!!"); return SCRIPT_ENGINE_ERROR; } lua_settop(l,1); //clear stack @@ -334,7 +334,7 @@ int init_updatedb(lua_State* l) { char* c_iter; 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; } diff --git a/nse_main.cc b/nse_main.cc index 288c62888..962148c75 100644 --- a/nse_main.cc +++ b/nse_main.cc @@ -225,7 +225,7 @@ finishup: current_hosts.clear(); torun_scripts.clear(); if(status != SCRIPT_ENGINE_SUCCESS) { - error("%s: Aborting script scan.\n", SCRIPT_ENGINE); + error("%s: Aborting script scan.", SCRIPT_ENGINE); return SCRIPT_ENGINE_ERROR; } else { 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)) { ssr->id = strdup(lua_tostring (l, -1)); } 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); l_dumpValue(l, -1); return SCRIPT_ENGINE_ERROR; diff --git a/osscan.cc b/osscan.cc index b10c00a54..41bedd18b 100644 --- a/osscan.cc +++ b/osscan.cc @@ -248,7 +248,7 @@ static int AVal_match(struct AVal *reference, struct AVal *fprint, struct AVal * *q1 = '\0'; number = strtol(p, NULL, 16); number1 = strtol(q1 + 1, NULL, 16); 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); if (val < number || val > number1 || *endptr) { if (andexp) { testfailed=1; break; } } diff --git a/osscan2.cc b/osscan2.cc index 400a8004a..e38de1999 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -2033,8 +2033,9 @@ bool HostOsScan::processTSeqResp(HostOsScanStats *hss, struct ip *ip, int replyN if (seq_response_num != replyNo) { /* BzzT! Value out of range */ if (o.debugging) { - error("Unable to associate os scan response with sent packet for %s.\nReceived ack: %lX; sequence sent: %lX. Packet:", - hss->target->targetipstr(), + error("Unable to associate os scan response with sent packet for %s.", + hss->target->targetipstr()); + error("Received ack: %lX; sequence sent: %lX. Packet:", (unsigned long) ntohl(tcp->th_ack), (unsigned long) tcpSeqBase); readtcppacket((unsigned char *)ip,ntohs(ip->ip_len)); diff --git a/portlist.cc b/portlist.cc index f6682d9c5..8ddcfebbf 100644 --- a/portlist.cc +++ b/portlist.cc @@ -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 if a complete duplicate */ 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]--; } else { diff --git a/scan_engine.cc b/scan_engine.cc index 33ce4e5cf..c1352f059 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -2581,7 +2581,7 @@ static UltraProbe *sendArpScanProbe(UltraScanInfo *USI, HostScanStats *hss, hss->lastprobe_sent = probe->sent = USI->now; if ((rc = eth_send(USI->ethsd, frame, sizeof(frame))) != sizeof(frame)) { 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); probe->tryno = tryno; @@ -3584,7 +3584,7 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) { } else newstate = PORT_CLOSED; } else { 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; } } @@ -3611,7 +3611,7 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) { 8 xtra bytes */ if (bytes < requiredbytes) { if (o.debugging) - error("Received short ICMP packet (%d bytes)\n", bytes); + error("Received short ICMP packet (%d bytes)", bytes); 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) { if (bytes < ip->ip_hl * 4 + 28U) { 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; } @@ -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 */ if (bytes < ip->ip_hl * 4 + 8U + ip2->ip_hl * 4 + 8U && !USI->ptech.rawprotoscan) { 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; } @@ -4063,7 +4063,7 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) { goodseq = tcp_trynum_pingseq_decode(USI, tcp, &trynum, &pingseq); if (!goodseq) { 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; } @@ -4203,7 +4203,7 @@ static int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) { continue; } 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; } struct tcp_hdr *tcp = (struct tcp_hdr *) (((u8 *) ip) + 4 * ip->ip_hl); diff --git a/service_scan.cc b/service_scan.cc index 4445dc3a5..089a3c654 100644 --- a/service_scan.cc +++ b/service_scan.cc @@ -2083,7 +2083,7 @@ static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *myd if (status == NSE_STATUS_ERROR) { 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 @@ -2131,7 +2131,7 @@ static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *myda // WOO HOO!!!!!! MATCHED! But might be soft if (MD->isSoft && svc->probe_matched) { 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 // example, if we read more data for the same probe response // it will probably still match. diff --git a/services.cc b/services.cc index 599e08bf0..524cc7f7e 100644 --- a/services.cc +++ b/services.cc @@ -140,7 +140,7 @@ static int nmap_services_init() { else len = GetWindowsDirectory(filename, 480); // be safe if(!len) - error("Get%sDirectory failed (%d) @#!#@\n", + error("Get%sDirectory failed (%d) @#!#@", wnt ? "System" : "Windows", GetLastError()); else { diff --git a/tcpip.cc b/tcpip.cc index 4adf69ec7..ca73082ae 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -1979,7 +1979,7 @@ if (!pd) fatal("NULL packet device passed to %s", __func__); if (head.caplen > 100000) { 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); exit(1); } @@ -2109,7 +2109,7 @@ void pcap_print_stats(int logt, pcap_t *pd) { assert(pd != NULL); if (pcap_stats(pd, &stat) < 0) { - error("%s: %s\n", __func__, pcap_geterr(pd)); + error("%s: %s", __func__, pcap_geterr(pd)); 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 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 - 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 -1 or exits if ther is an error. */ 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 */ rc = eth_send(ethsd, frame, 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); 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); 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 ) fatal("Failed to set the pcap filter: %s\n", pcap_geterr(pd)); pcap_freecode(&fcode); @@ -2590,7 +2590,7 @@ static int collect_dnet_routes(const struct route_entry *entry, void *arg) { } } 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; } dcrn->numroutes++; @@ -2951,7 +2951,7 @@ struct sys_route *getsysroutes(int *howmany) { endptr = NULL; routes[numroutes].gw.s_addr = strtoul(p, &endptr, 16); 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++) { p = strtok(NULL, " \t\n");