Nmap Development mailing list archives
ncat udp
From: Marius Sturm <marius.sturm () web de>
Date: Wed, 25 Mar 2009 14:49:17 +0100
Hey list, I could't find a good reason, why ncat must run in a while loop when using udp protocol. I would expect, that it behaves almost the same as in tcp mode. Attached is a patch to go into this direction. Any comments are welcome! Best regards, Marius
diff -urNb nmap/ncat/ncat_exec.c nmap-udp/ncat/ncat_exec.c --- nmap/ncat/ncat_exec.c 2009-03-25 14:23:09.000000000 +0100 +++ nmap-udp/ncat/ncat_exec.c 2009-03-25 14:31:13.000000000 +0100 @@ -7,6 +7,8 @@ int netrun(int fd, char *cmdexec) { int pid; + int opt; + int opt_len = sizeof(opt); errno = 0; pid = fork(); @@ -18,6 +20,10 @@ if (pid == -1 && verbose_flag) Fprintf(stderr, "DEBUG: error in fork: %s\n", strerror(errno)); + waitpid(pid, NULL, NULL); + getsockopt(fd, SOL_SOCKET, SO_TYPE, &opt, &opt_len); + + if (opt != SOCK_DGRAM) Close(fd); return pid; diff -urNb nmap/ncat/ncat_listen.c nmap-udp/ncat/ncat_listen.c --- nmap/ncat/ncat_listen.c 2009-03-25 14:23:09.000000000 +0100 +++ nmap-udp/ncat/ncat_listen.c 2009-03-25 14:04:55.000000000 +0100 @@ -341,10 +341,6 @@ /* clean slate for buf */ zmem(buf, sizeof(buf)); - /* are we executing a command? then do it */ - if (o.cmdexec) - netexec(sockfd, o.cmdexec); - FD_SET(sockfd, &master); FD_SET(STDIN_FILENO, &master); fdmax = sockfd; @@ -375,6 +371,10 @@ Write(STDOUT_FILENO, buf, nbytes); } + /* are we executing a command? then do it */ + if (o.cmdexec && ! o.recvonly) + netrun(sockfd, o.cmdexec); + zmem(buf, sizeof(buf)); }
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- ncat udp Marius Sturm (Mar 25)
- Re: ncat udp David Fifield (Mar 25)
- <Possible follow-ups>
- Re: ncat udp Marius Sturm (Mar 26)
- Re: ncat udp David Fifield (Mar 26)
- Re: ncat udp Marius Sturm (Mar 27)
- Re: ncat udp David Fifield (Mar 27)
- Re: ncat udp David Fifield (Mar 27)
- Re: ncat udp David Fifield (Mar 26)