osdir.com
mailing list archive

Subject: Re: [PATCH] Make 15 functions static - msg#00113

List: security.nmap.devel

Date: Prev Next Index Thread: Prev Next Index
hello kris,

I need get_initial_ttl_guess() for my imminent traceroute patch

thanks
- eddie

On 25/08/06, Kris Katterjohn <kjak@xxxxxxxxxxx> wrote:
> This patch localizes these 15 symbols:
>
> mac_prefix_init
> connect_dns_servers
> encoded_name_to_normal
> put_dns_packet_on_wire
> get_initial_ttl_guess
> xml_sf_convert
> end_svcprobe
> servicescan_read_handler
> parse_nmap_service_probes
> servicescan_write_handler
> servicescan_connect_handler
> sendrawtcppingquery
> sendrawudppingquery
> sendrawtcpudppingqueries
> get_connecttcpscan_results
>
> .. in their respective files.
>
>
> It's a diff against 4.20ALPHA4.
>
> Thanks,
> Kris Katterjohn
>
>
> --- x/MACLookup.cc 2006-03-05 18:00:03.000000000 -0600
> +++ z/MACLookup.cc 2006-08-25 09:46:34.000000000 -0500
> @@ -128,7 +128,7 @@ static inline int MACTableHash(int prefi
> return prefix % table_capacity;
> }
>
> -void mac_prefix_init() {
> +static void mac_prefix_init() {
> static int initialized = 0;
> if (initialized) return;
> initialized = 1;
>
> --- x/nmap_dns.cc 2006-07-04 17:32:50.000000000 -0500
> +++ z/nmap_dns.cc 2006-08-25 10:03:12.000000000 -0500
> @@ -291,7 +291,7 @@ static ScanProgressMeter *SPM;
>
> //------------------- Prototypes and macros ---------------------
>
> -void put_dns_packet_on_wire(request *req);
> +static void put_dns_packet_on_wire(request *req);
>
> #define ACTION_FINISHED 0
> #define ACTION_CNAME_LIST 1
> @@ -391,7 +391,7 @@ static void write_evt_handler(nsock_pool
> // Takes a DNS request structure and actually puts it on the wire
> // (calls nsock_write()). Does various other tasks like recording
> // the time for the timeout.
> -void put_dns_packet_on_wire(request *req) {
> +static void put_dns_packet_on_wire(request *req) {
> char packet[512];
> int plen=0;
> u32 ip;
> @@ -593,7 +593,7 @@ static u32 parse_inaddr_arpa(unsigned ch
> // Turns a DNS packet encoded name (see the RFC) and turns it into
> // a normal decimal separated hostname.
> // ASSUMES NAME LENGTH/VALIDITY HAS ALREADY BEEN VERIFIED
> -int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){
> +static int encoded_name_to_normal(unsigned char *buf, char *output, int
> outputsize){
> while (buf[0]) {
> if (buf[0] >= outputsize-1) return -1;
> memcpy(output, buf+1, buf[0]);
> @@ -833,7 +833,7 @@ void free_dns_servers() {
>
>
> // Creates a new nsi for each DNS server
> -void connect_dns_servers() {
> +static void connect_dns_servers() {
> std::list<dns_server *>::iterator serverI;
> dns_server *s;
>
>
> --- x/osscan2.cc 2006-06-29 18:36:48.000000000 -0500
> +++ z/osscan2.cc 2006-08-25 09:42:07.000000000 -0500
> @@ -1316,6 +1316,17 @@ bool HostOsScan::processResp(HostOsScanS
> return false;
> }
>
> +static int get_initial_ttl_guess(u8 ttl) {
> + if (ttl <= 32)
> + return 32;
> + else if (ttl <= 64)
> + return 64;
> + else if (ttl <= 128)
> + return 128;
> + else
> + return 255;
> +}
> +
> void HostOsScan::makeFP(HostOsScanStats *hss) {
> assert(hss);
>
> @@ -2795,17 +2806,6 @@ int send_closedudp_probe_2(struct udppro
> return 0;
> }
>
> -int get_initial_ttl_guess(u8 ttl) {
> - if (ttl <= 32)
> - return 32;
> - else if (ttl <= 64)
> - return 64;
> - else if (ttl <= 128)
> - return 128;
> - else
> - return 255;
> -}
> -
> /* New ipid incremental type judging function.
> * Judge by tcp ipid, icmp echo reply ipid, icmp destination unreachable
> ipid.
> */
>
> --- x/osscan2.h 2006-06-24 20:30:48.000000000 -0500
> +++ z/osscan2.h 2006-08-25 09:42:13.000000000 -0500
> @@ -18,7 +18,6 @@ int send_closedudp_probe_2(struct udppro
> int send_icmp_echo_probe(int sd, struct eth_nfo *eth, const struct in_addr
> *victim,
> u8 tos, bool df, u8 pcode, unsigned short id, u16
> seq, u16 datalen);
>
> -int get_initial_ttl_guess(u8 ttl);
> int get_ipid_sequence(struct ipid_info *ipid, int islocalhost);
>
> #endif /*OSSCAN2_H*/
>
> --- x/output.cc 2006-06-28 17:04:17.000000000 -0500
> +++ z/output.cc 2006-08-25 09:58:07.000000000 -0500
> @@ -156,6 +156,37 @@ static void skid_output(char *s)
> }
> }
>
> +/* Remove all "\nSF:" from fingerprints */
> +static char* xml_sf_convert (const char* str) {
> + char *temp = (char *) safe_malloc(strlen(str) + 1);
> + char *dst = temp, *src = (char *)str;
> + char *ampptr = 0;
> + int charcount = 0;
> +
> + while(*src && charcount < 2035) { /* 2048 - 14 */
> + if (strncmp(src, "\nSF:", 4) == 0) {
> + src += 4;
> + continue;
> + }
> + /* Needed so "&something;" is not truncated midway */
> + if (*src == '&') {
> + ampptr = dst;
> + }
> + else if (*src == ';') {
> + ampptr = 0;
> + }
> + *dst++ = *src++;
> + charcount++;
> + }
> + if (ampptr != 0) {
> + *ampptr = '\0';
> + }
> + else {
> + *dst = '\0';
> + }
> + return temp;
> +}
> +
>
> // Creates an XML <service> element for the information given in
> // serviceDeduction. It will be 0-length if none is neccessary.
> @@ -741,37 +772,6 @@ void log_vwrite(int logt, const char *fm
> return;
> }
>
> -/* Remove all "\nSF:" from fingerprints */
> -char* xml_sf_convert (const char* str) {
> - char *temp = (char *) safe_malloc(strlen(str) + 1);
> - char *dst = temp, *src = (char *)str;
> - char *ampptr = 0;
> - int charcount = 0;
> -
> - while(*src && charcount < 2035) { /* 2048 - 14 */
> - if (strncmp(src, "\nSF:", 4) == 0) {
> - src += 4;
> - continue;
> - }
> - /* Needed so "&something;" is not truncated midway */
> - if (*src == '&') {
> - ampptr = dst;
> - }
> - else if (*src == ';') {
> - ampptr = 0;
> - }
> - *dst++ = *src++;
> - charcount++;
> - }
> - if (ampptr != 0) {
> - *ampptr = '\0';
> - }
> - else {
> - *dst = '\0';
> - }
> - return temp;
> -}
> -
> /* Write some information (printf style args) to the given log stream(s).
> Remember to watch out for format string bugs. */
> void log_write(int logt, const char *fmt, ...)
>
> --- x/output.h 2006-04-22 18:03:01.000000000 -0500
> +++ z/output.h 2006-08-25 09:58:12.000000000 -0500
> @@ -203,5 +203,4 @@ void printStatusMessage();
> void printfinaloutput();
>
> char* xml_convert (const char* str);
> -char* xml_sf_convert (const char* str);
> #endif /* OUTPUT_H */
>
> --- x/service_scan.cc 2006-07-04 18:05:03.000000000 -0500
> +++ z/service_scan.cc 2006-08-25 10:28:02.000000000 -0500
> @@ -255,10 +255,10 @@ struct substargs {
> };
>
> /******************** PROTOTYPES *******************/
> -void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata);
> -void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void
> *mydata);
> -void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void
> *mydata);
> -void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state,
> ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi);
> +static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void
> *mydata);
> +static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void
> *mydata);
> +static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse,
> void *mydata);
> +static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state,
> ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi);
>
> ServiceProbeMatch::ServiceProbeMatch() {
> deflineno = -1;
> @@ -1138,7 +1138,7 @@ void parse_nmap_service_probe_file(AllPr
>
> // Parses the nmap-service-probes file, and adds each probe to
> // the already-created 'probes' vector.
> -void parse_nmap_service_probes(AllProbes *AP) {
> +static void parse_nmap_service_probes(AllProbes *AP) {
> char filename[256];
>
> if (nmap_fetchfile(filename, sizeof(filename), "nmap-service-probes") ==
> -1){
> @@ -1893,7 +1893,7 @@ static void handleHostIfDone(ServiceGrou
> // A simple helper function to cancel further work on a service and
> // set it to the given probe_state pass NULL for nsi if you don't want
> // it to be deleted (for example, if you already have done so).
> -void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state,
> ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) {
> +static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state,
> ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) {
> list<ServiceNFO *>::iterator member;
> Target *target = svc->target;
>
> @@ -1982,7 +1982,7 @@ static int launchSomeServiceProbes(nsock
> }
>
>
> -void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void
> *mydata) {
> +static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse,
> void *mydata) {
> nsock_iod nsi = nse_iod(nse);
> enum nse_status status = nse_status(nse);
> enum nse_type type = nse_type(nse);
> @@ -2042,7 +2042,7 @@ void servicescan_connect_handler(nsock_p
> return;
> }
>
> -void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void
> *mydata) {
> +static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void
> *mydata) {
> enum nse_status status = nse_status(nse);
> nsock_iod nsi;
> ServiceNFO *svc = (ServiceNFO *)mydata;
> @@ -2092,7 +2092,7 @@ void servicescan_write_handler(nsock_poo
> return;
> }
>
> -void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata)
> {
> +static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void
> *mydata) {
> nsock_iod nsi = nse_iod(nse);
> enum nse_status status = nse_status(nse);
> enum nse_type type = nse_type(nse);
>
> --- x/targets.cc 2006-07-04 18:05:03.000000000 -0500
> +++ z/targets.cc 2006-08-25 10:06:19.000000000 -0500
> @@ -887,8 +887,8 @@ static int sendconnecttcpqueries(Target
> return 0;
> }
>
> -int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16
> probe_port,
> - u16 seq, struct timeval *time, struct pingtune *pt) {
> +static int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target
> *target, u16 probe_port,
> + u16 seq, struct timeval *time, struct pingtune
> *pt) {
> int trynum = 0;
> unsigned short sportbase;
>
> @@ -906,8 +906,8 @@ else {
> return 0;
> }
>
> -int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int
> pingtype, u16 probe_port,
> - u16 seq, struct timeval *time, struct pingtune *pt) {
> +static int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target
> *target, int pingtype, u16 probe_port,
> + u16 seq, struct timeval *time, struct pingtune
> *pt) {
> int trynum = 0;
> int myseq;
> unsigned short sportbase;
> @@ -934,8 +934,8 @@ else {
> return 0;
> }
>
> -int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int
> pingtype, u16 seq,
> - struct timeval *time, struct pingtune *pt) {
> +static int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target,
> int pingtype, u16 seq,
> + struct timeval *time, struct pingtune
> *pt) {
> int i;
> struct eth_nfo eth;
> struct eth_nfo *ethptr = NULL;
> @@ -1096,10 +1096,10 @@ static int sendpingqueries(int sd, int r
> }
>
>
> -int get_connecttcpscan_results(struct tcpqueryinfo *tqi,
> - Target *hostbatch[],
> - struct timeval *time, struct pingtune *pt,
> - struct timeout_info *to) {
> +static int get_connecttcpscan_results(struct tcpqueryinfo *tqi,
> + Target *hostbatch[],
> + struct timeval *time, struct pingtune
> *pt,
> + struct timeout_info *to) {
>
> int res, res2;
> int tm;
>
>
>
> _______________________________________________
> Sent through the nmap-dev mailing list
> http://cgi.insecure.org/mailman/listinfo/nmap-dev
> Archived at http://SecLists.Org
>
>

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: what did I miss this time?

Unfortunately I don't have immediate access to a linux or a BSD system now. But I am working on that so that i can test from that too. And upon getting your reply, I tried the -PE/-sP options on some other hosts. It works for all other hosts which I tried, except this one host ! On 8/25/06, Kris Katterjohn <kjak@xxxxxxxxxxx> wrote: > R M wrote: > > hi ! > > > > here's something which has been bugging me for sometime now. > > > > There is an IP address (public) which I can ping successfully. But > > when I do an 'nmap -PE' for the same IP, it says 'host seems down'. As > > expected, a packet capture shows that the -PE option is just sending > > an echo request (same as what PING is doing). > > > > I am trying this from different XP SP2 machines. Same result. I tried > > nmap 4.11 as well as 4.01. I also tried the -sP option, with the same > > outcome. > > > > Is there anyway the destination host can know that the icmp echo > > request is coming from nmap and not from a regular PING and thus > > blocks the nmap ping?? > > Sorry for these basic questions. > > > > Appreciate any feedback/suggestions you can provide. > > > > thanks, folks. > > > > --Rosh > > > > Have you tried doing this on other platforms like Linux or *BSD? Have > you tried pinging and using the -PE/-sP option on other hosts? > > > Kris Katterjohn > _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org

Next Message by Date: click to view message preview

Transient error with sendto in send_ip_packet

On one of my scanning machines I periodically get sendto in send_ip_packet: sendto(9, packet, 44, 0, w.x.y.z, 16) => Operation not permitted And I have been unable to track down the source of the error. I know strict iptables rules can sometimes not permit certain packets but this error occurs with and without any iptables rules. Any insight into what could be causing the problem would be much appreciated. Here is some information that may be needed: $ nmap --version Nmap version 4.11 ( http://www.insecure.org/nmap/ ) $ uname -a Linux burninator 2.6.17-gentoo-r5 #1 SMP PREEMPT Thu Aug 17 21:06:35 UTC 2006 x86_64 Intel(R) Xeon(TM) CPU 3.40GHz GNU/Linux $ gcc --version gcc (GCC) 3.4.6 (Gentoo Hardened 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9) CFLAGS="-O2 -march=nocona -pipe" Here is an example of a scan that generates these errors. The issue is *not* related to "-P0". # nmap -P0 -A -v -p- -T4 --min-parallelism 96 --min-hostgroup 128 <several thousand ips> Please let me know if there is anything else I can provide. Brandon _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org

Previous Message by Thread: click to view message preview

[PATCH] Make 15 functions static

This patch localizes these 15 symbols: mac_prefix_init connect_dns_servers encoded_name_to_normal put_dns_packet_on_wire get_initial_ttl_guess xml_sf_convert end_svcprobe servicescan_read_handler parse_nmap_service_probes servicescan_write_handler servicescan_connect_handler sendrawtcppingquery sendrawudppingquery sendrawtcpudppingqueries get_connecttcpscan_results .. in their respective files. It's a diff against 4.20ALPHA4. Thanks, Kris Katterjohn --- x/MACLookup.cc 2006-03-05 18:00:03.000000000 -0600 +++ z/MACLookup.cc 2006-08-25 09:46:34.000000000 -0500 @@ -128,7 +128,7 @@ static inline int MACTableHash(int prefi return prefix % table_capacity; } -void mac_prefix_init() { +static void mac_prefix_init() { static int initialized = 0; if (initialized) return; initialized = 1; --- x/nmap_dns.cc 2006-07-04 17:32:50.000000000 -0500 +++ z/nmap_dns.cc 2006-08-25 10:03:12.000000000 -0500 @@ -291,7 +291,7 @@ static ScanProgressMeter *SPM; //------------------- Prototypes and macros --------------------- -void put_dns_packet_on_wire(request *req); +static void put_dns_packet_on_wire(request *req); #define ACTION_FINISHED 0 #define ACTION_CNAME_LIST 1 @@ -391,7 +391,7 @@ static void write_evt_handler(nsock_pool // Takes a DNS request structure and actually puts it on the wire // (calls nsock_write()). Does various other tasks like recording // the time for the timeout. -void put_dns_packet_on_wire(request *req) { +static void put_dns_packet_on_wire(request *req) { char packet[512]; int plen=0; u32 ip; @@ -593,7 +593,7 @@ static u32 parse_inaddr_arpa(unsigned ch // Turns a DNS packet encoded name (see the RFC) and turns it into // a normal decimal separated hostname. // ASSUMES NAME LENGTH/VALIDITY HAS ALREADY BEEN VERIFIED -int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){ +static int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){ while (buf[0]) { if (buf[0] >= outputsize-1) return -1; memcpy(output, buf+1, buf[0]); @@ -833,7 +833,7 @@ void free_dns_servers() { // Creates a new nsi for each DNS server -void connect_dns_servers() { +static void connect_dns_servers() { std::list<dns_server *>::iterator serverI; dns_server *s; --- x/osscan2.cc 2006-06-29 18:36:48.000000000 -0500 +++ z/osscan2.cc 2006-08-25 09:42:07.000000000 -0500 @@ -1316,6 +1316,17 @@ bool HostOsScan::processResp(HostOsScanS return false; } +static int get_initial_ttl_guess(u8 ttl) { + if (ttl <= 32) + return 32; + else if (ttl <= 64) + return 64; + else if (ttl <= 128) + return 128; + else + return 255; +} + void HostOsScan::makeFP(HostOsScanStats *hss) { assert(hss); @@ -2795,17 +2806,6 @@ int send_closedudp_probe_2(struct udppro return 0; } -int get_initial_ttl_guess(u8 ttl) { - if (ttl <= 32) - return 32; - else if (ttl <= 64) - return 64; - else if (ttl <= 128) - return 128; - else - return 255; -} - /* New ipid incremental type judging function. * Judge by tcp ipid, icmp echo reply ipid, icmp destination unreachable ipid. */ --- x/osscan2.h 2006-06-24 20:30:48.000000000 -0500 +++ z/osscan2.h 2006-08-25 09:42:13.000000000 -0500 @@ -18,7 +18,6 @@ int send_closedudp_probe_2(struct udppro int send_icmp_echo_probe(int sd, struct eth_nfo *eth, const struct in_addr *victim, u8 tos, bool df, u8 pcode, unsigned short id, u16 seq, u16 datalen); -int get_initial_ttl_guess(u8 ttl); int get_ipid_sequence(struct ipid_info *ipid, int islocalhost); #endif /*OSSCAN2_H*/ --- x/output.cc 2006-06-28 17:04:17.000000000 -0500 +++ z/output.cc 2006-08-25 09:58:07.000000000 -0500 @@ -156,6 +156,37 @@ static void skid_output(char *s) } } +/* Remove all "\nSF:" from fingerprints */ +static char* xml_sf_convert (const char* str) { + char *temp = (char *) safe_malloc(strlen(str) + 1); + char *dst = temp, *src = (char *)str; + char *ampptr = 0; + int charcount = 0; + + while(*src && charcount < 2035) { /* 2048 - 14 */ + if (strncmp(src, "\nSF:", 4) == 0) { + src += 4; + continue; + } + /* Needed so "&something;" is not truncated midway */ + if (*src == '&') { + ampptr = dst; + } + else if (*src == ';') { + ampptr = 0; + } + *dst++ = *src++; + charcount++; + } + if (ampptr != 0) { + *ampptr = '\0'; + } + else { + *dst = '\0'; + } + return temp; +} + // Creates an XML <service> element for the information given in // serviceDeduction. It will be 0-length if none is neccessary. @@ -741,37 +772,6 @@ void log_vwrite(int logt, const char *fm return; } -/* Remove all "\nSF:" from fingerprints */ -char* xml_sf_convert (const char* str) { - char *temp = (char *) safe_malloc(strlen(str) + 1); - char *dst = temp, *src = (char *)str; - char *ampptr = 0; - int charcount = 0; - - while(*src && charcount < 2035) { /* 2048 - 14 */ - if (strncmp(src, "\nSF:", 4) == 0) { - src += 4; - continue; - } - /* Needed so "&something;" is not truncated midway */ - if (*src == '&') { - ampptr = dst; - } - else if (*src == ';') { - ampptr = 0; - } - *dst++ = *src++; - charcount++; - } - if (ampptr != 0) { - *ampptr = '\0'; - } - else { - *dst = '\0'; - } - return temp; -} - /* Write some information (printf style args) to the given log stream(s). Remember to watch out for format string bugs. */ void log_write(int logt, const char *fmt, ...) --- x/output.h 2006-04-22 18:03:01.000000000 -0500 +++ z/output.h 2006-08-25 09:58:12.000000000 -0500 @@ -203,5 +203,4 @@ void printStatusMessage(); void printfinaloutput(); char* xml_convert (const char* str); -char* xml_sf_convert (const char* str); #endif /* OUTPUT_H */ --- x/service_scan.cc 2006-07-04 18:05:03.000000000 -0500 +++ z/service_scan.cc 2006-08-25 10:28:02.000000000 -0500 @@ -255,10 +255,10 @@ struct substargs { }; /******************** PROTOTYPES *******************/ -void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi); +static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi); ServiceProbeMatch::ServiceProbeMatch() { deflineno = -1; @@ -1138,7 +1138,7 @@ void parse_nmap_service_probe_file(AllPr // Parses the nmap-service-probes file, and adds each probe to // the already-created 'probes' vector. -void parse_nmap_service_probes(AllProbes *AP) { +static void parse_nmap_service_probes(AllProbes *AP) { char filename[256]; if (nmap_fetchfile(filename, sizeof(filename), "nmap-service-probes") == -1){ @@ -1893,7 +1893,7 @@ static void handleHostIfDone(ServiceGrou // A simple helper function to cancel further work on a service and // set it to the given probe_state pass NULL for nsi if you don't want // it to be deleted (for example, if you already have done so). -void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) { +static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) { list<ServiceNFO *>::iterator member; Target *target = svc->target; @@ -1982,7 +1982,7 @@ static int launchSomeServiceProbes(nsock } -void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) { nsock_iod nsi = nse_iod(nse); enum nse_status status = nse_status(nse); enum nse_type type = nse_type(nse); @@ -2042,7 +2042,7 @@ void servicescan_connect_handler(nsock_p return; } -void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) { enum nse_status status = nse_status(nse); nsock_iod nsi; ServiceNFO *svc = (ServiceNFO *)mydata; @@ -2092,7 +2092,7 @@ void servicescan_write_handler(nsock_poo return; } -void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata) { nsock_iod nsi = nse_iod(nse); enum nse_status status = nse_status(nse); enum nse_type type = nse_type(nse); --- x/targets.cc 2006-07-04 18:05:03.000000000 -0500 +++ z/targets.cc 2006-08-25 10:06:19.000000000 -0500 @@ -887,8 +887,8 @@ static int sendconnecttcpqueries(Target return 0; } -int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16 probe_port, - u16 seq, struct timeval *time, struct pingtune *pt) { +static int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16 probe_port, + u16 seq, struct timeval *time, struct pingtune *pt) { int trynum = 0; unsigned short sportbase; @@ -906,8 +906,8 @@ else { return 0; } -int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int pingtype, u16 probe_port, - u16 seq, struct timeval *time, struct pingtune *pt) { +static int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int pingtype, u16 probe_port, + u16 seq, struct timeval *time, struct pingtune *pt) { int trynum = 0; int myseq; unsigned short sportbase; @@ -934,8 +934,8 @@ else { return 0; } -int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int pingtype, u16 seq, - struct timeval *time, struct pingtune *pt) { +static int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int pingtype, u16 seq, + struct timeval *time, struct pingtune *pt) { int i; struct eth_nfo eth; struct eth_nfo *ethptr = NULL; @@ -1096,10 +1096,10 @@ static int sendpingqueries(int sd, int r } -int get_connecttcpscan_results(struct tcpqueryinfo *tqi, - Target *hostbatch[], - struct timeval *time, struct pingtune *pt, - struct timeout_info *to) { +static int get_connecttcpscan_results(struct tcpqueryinfo *tqi, + Target *hostbatch[], + struct timeval *time, struct pingtune *pt, + struct timeout_info *to) { int res, res2; int tm; _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org

Next Message by Thread: click to view message preview

Re: [PATCH] Make 15 functions static

Eddie Bell wrote: > hello kris, > > I need get_initial_ttl_guess() for my imminent traceroute patch > > thanks > - eddie > > On 25/08/06, Kris Katterjohn <kjak@xxxxxxxxxxx> wrote: >> This patch localizes these 15 symbols: >> >> mac_prefix_init >> connect_dns_servers >> encoded_name_to_normal >> put_dns_packet_on_wire >> get_initial_ttl_guess >> xml_sf_convert >> end_svcprobe >> servicescan_read_handler >> parse_nmap_service_probes >> servicescan_write_handler >> servicescan_connect_handler >> sendrawtcppingquery >> sendrawudppingquery >> sendrawtcpudppingqueries >> get_connecttcpscan_results >> >> .. in their respective files. >> Okey-dokey, here's the updated patch. Anybody else working with one of these? Kris Katterjohn --- x/MACLookup.cc 2006-03-05 18:00:03.000000000 -0600 +++ z/MACLookup.cc 2006-08-25 09:46:34.000000000 -0500 @@ -128,7 +128,7 @@ static inline int MACTableHash(int prefi return prefix % table_capacity; } -void mac_prefix_init() { +static void mac_prefix_init() { static int initialized = 0; if (initialized) return; initialized = 1; --- x/nmap_dns.cc 2006-07-04 17:32:50.000000000 -0500 +++ z/nmap_dns.cc 2006-08-25 10:03:12.000000000 -0500 @@ -291,7 +291,7 @@ static ScanProgressMeter *SPM; //------------------- Prototypes and macros --------------------- -void put_dns_packet_on_wire(request *req); +static void put_dns_packet_on_wire(request *req); #define ACTION_FINISHED 0 #define ACTION_CNAME_LIST 1 @@ -391,7 +391,7 @@ static void write_evt_handler(nsock_pool // Takes a DNS request structure and actually puts it on the wire // (calls nsock_write()). Does various other tasks like recording // the time for the timeout. -void put_dns_packet_on_wire(request *req) { +static void put_dns_packet_on_wire(request *req) { char packet[512]; int plen=0; u32 ip; @@ -593,7 +593,7 @@ static u32 parse_inaddr_arpa(unsigned ch // Turns a DNS packet encoded name (see the RFC) and turns it into // a normal decimal separated hostname. // ASSUMES NAME LENGTH/VALIDITY HAS ALREADY BEEN VERIFIED -int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){ +static int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){ while (buf[0]) { if (buf[0] >= outputsize-1) return -1; memcpy(output, buf+1, buf[0]); @@ -833,7 +833,7 @@ void free_dns_servers() { // Creates a new nsi for each DNS server -void connect_dns_servers() { +static void connect_dns_servers() { std::list<dns_server *>::iterator serverI; dns_server *s; --- x/output.cc 2006-06-28 17:04:17.000000000 -0500 +++ z/output.cc 2006-08-25 09:58:07.000000000 -0500 @@ -156,6 +156,37 @@ static void skid_output(char *s) } } +/* Remove all "\nSF:" from fingerprints */ +static char* xml_sf_convert (const char* str) { + char *temp = (char *) safe_malloc(strlen(str) + 1); + char *dst = temp, *src = (char *)str; + char *ampptr = 0; + int charcount = 0; + + while(*src && charcount < 2035) { /* 2048 - 14 */ + if (strncmp(src, "\nSF:", 4) == 0) { + src += 4; + continue; + } + /* Needed so "&something;" is not truncated midway */ + if (*src == '&') { + ampptr = dst; + } + else if (*src == ';') { + ampptr = 0; + } + *dst++ = *src++; + charcount++; + } + if (ampptr != 0) { + *ampptr = '\0'; + } + else { + *dst = '\0'; + } + return temp; +} + // Creates an XML <service> element for the information given in // serviceDeduction. It will be 0-length if none is neccessary. @@ -741,37 +772,6 @@ void log_vwrite(int logt, const char *fm return; } -/* Remove all "\nSF:" from fingerprints */ -char* xml_sf_convert (const char* str) { - char *temp = (char *) safe_malloc(strlen(str) + 1); - char *dst = temp, *src = (char *)str; - char *ampptr = 0; - int charcount = 0; - - while(*src && charcount < 2035) { /* 2048 - 14 */ - if (strncmp(src, "\nSF:", 4) == 0) { - src += 4; - continue; - } - /* Needed so "&something;" is not truncated midway */ - if (*src == '&') { - ampptr = dst; - } - else if (*src == ';') { - ampptr = 0; - } - *dst++ = *src++; - charcount++; - } - if (ampptr != 0) { - *ampptr = '\0'; - } - else { - *dst = '\0'; - } - return temp; -} - /* Write some information (printf style args) to the given log stream(s). Remember to watch out for format string bugs. */ void log_write(int logt, const char *fmt, ...) --- x/output.h 2006-04-22 18:03:01.000000000 -0500 +++ z/output.h 2006-08-25 09:58:12.000000000 -0500 @@ -203,5 +203,4 @@ void printStatusMessage(); void printfinaloutput(); char* xml_convert (const char* str); -char* xml_sf_convert (const char* str); #endif /* OUTPUT_H */ --- x/service_scan.cc 2006-07-04 18:05:03.000000000 -0500 +++ z/service_scan.cc 2006-08-25 10:28:02.000000000 -0500 @@ -255,10 +255,10 @@ struct substargs { }; /******************** PROTOTYPES *******************/ -void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata); -void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi); +static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata); +static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi); ServiceProbeMatch::ServiceProbeMatch() { deflineno = -1; @@ -1138,7 +1138,7 @@ void parse_nmap_service_probe_file(AllPr // Parses the nmap-service-probes file, and adds each probe to // the already-created 'probes' vector. -void parse_nmap_service_probes(AllProbes *AP) { +static void parse_nmap_service_probes(AllProbes *AP) { char filename[256]; if (nmap_fetchfile(filename, sizeof(filename), "nmap-service-probes") == -1){ @@ -1893,7 +1893,7 @@ static void handleHostIfDone(ServiceGrou // A simple helper function to cancel further work on a service and // set it to the given probe_state pass NULL for nsi if you don't want // it to be deleted (for example, if you already have done so). -void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) { +static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod nsi) { list<ServiceNFO *>::iterator member; Target *target = svc->target; @@ -1982,7 +1982,7 @@ static int launchSomeServiceProbes(nsock } -void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) { nsock_iod nsi = nse_iod(nse); enum nse_status status = nse_status(nse); enum nse_type type = nse_type(nse); @@ -2042,7 +2042,7 @@ void servicescan_connect_handler(nsock_p return; } -void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) { enum nse_status status = nse_status(nse); nsock_iod nsi; ServiceNFO *svc = (ServiceNFO *)mydata; @@ -2092,7 +2092,7 @@ void servicescan_write_handler(nsock_poo return; } -void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata) { +static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata) { nsock_iod nsi = nse_iod(nse); enum nse_status status = nse_status(nse); enum nse_type type = nse_type(nse); --- x/targets.cc 2006-07-04 18:05:03.000000000 -0500 +++ z/targets.cc 2006-08-25 10:06:19.000000000 -0500 @@ -887,8 +887,8 @@ static int sendconnecttcpqueries(Target return 0; } -int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16 probe_port, - u16 seq, struct timeval *time, struct pingtune *pt) { +static int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16 probe_port, + u16 seq, struct timeval *time, struct pingtune *pt) { int trynum = 0; unsigned short sportbase; @@ -906,8 +906,8 @@ else { return 0; } -int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int pingtype, u16 probe_port, - u16 seq, struct timeval *time, struct pingtune *pt) { +static int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int pingtype, u16 probe_port, + u16 seq, struct timeval *time, struct pingtune *pt) { int trynum = 0; int myseq; unsigned short sportbase; @@ -934,8 +934,8 @@ else { return 0; } -int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int pingtype, u16 seq, - struct timeval *time, struct pingtune *pt) { +static int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int pingtype, u16 seq, + struct timeval *time, struct pingtune *pt) { int i; struct eth_nfo eth; struct eth_nfo *ethptr = NULL; @@ -1096,10 +1096,10 @@ static int sendpingqueries(int sd, int r } -int get_connecttcpscan_results(struct tcpqueryinfo *tqi, - Target *hostbatch[], - struct timeval *time, struct pingtune *pt, - struct timeout_info *to) { +static int get_connecttcpscan_results(struct tcpqueryinfo *tqi, + Target *hostbatch[], + struct timeval *time, struct pingtune *pt, + struct timeout_info *to) { int res, res2; int tm; _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by