aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/Config.in8
-rw-r--r--networking/nc.c27
2 files changed, 19 insertions, 16 deletions
diff --git a/networking/Config.in b/networking/Config.in
index 418ef4bc4..a84427981 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -422,6 +422,14 @@ config CONFIG_NC
422 A simple Unix utility which reads and writes data across network 422 A simple Unix utility which reads and writes data across network
423 connections. 423 connections.
424 424
425config CONFIG_NC_GAPING_SECURITY_HOLE
426 bool "gaping security hole"
427 default n
428 depends on CONFIG_NC
429 help
430 Add support for executing a program after making or receiving a
431 successful connection (-e option).
432
425config CONFIG_NETSTAT 433config CONFIG_NETSTAT
426 bool "netstat" 434 bool "netstat"
427 default n 435 default n
diff --git a/networking/nc.c b/networking/nc.c
index bbcbc0d13..bb6373fd3 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -4,7 +4,7 @@
4 4
5 0.0.1 6K It works. 5 0.0.1 6K It works.
6 0.0.2 5K Smaller and you can also check the exit condition if you wish. 6 0.0.2 5K Smaller and you can also check the exit condition if you wish.
7 0.0.3 Uses select() 7 0.0.3 Uses select()
8 8
9 19980918 Busy Boxed! Dave Cinege 9 19980918 Busy Boxed! Dave Cinege
10 19990512 Uses Select. Charles P. Wright 10 19990512 Uses Select. Charles P. Wright
@@ -23,7 +23,6 @@
23 You should have received a copy of the GNU General Public License 23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27*/ 26*/
28 27
29#include <stdio.h> 28#include <stdio.h>
@@ -41,8 +40,6 @@
41#include <sys/ioctl.h> 40#include <sys/ioctl.h>
42#include "busybox.h" 41#include "busybox.h"
43 42
44#define GAPING_SECURITY_HOLE
45
46static void timeout(int signum) 43static void timeout(int signum)
47{ 44{
48 bb_error_msg_and_die("Timed out"); 45 bb_error_msg_and_die("Timed out");
@@ -52,8 +49,8 @@ int nc_main(int argc, char **argv)
52{ 49{
53 int do_listen = 0, lport = 0, delay = 0, wsecs = 0, tmpfd, opt, sfd, x; 50 int do_listen = 0, lport = 0, delay = 0, wsecs = 0, tmpfd, opt, sfd, x;
54 char buf[BUFSIZ]; 51 char buf[BUFSIZ];
55#ifdef GAPING_SECURITY_HOLE 52#ifdef CONFIG_NC_GAPING_SECURITY_HOLE
56 char * pr00gie = NULL; 53 char *pr00gie = NULL;
57#endif 54#endif
58 55
59 struct sockaddr_in address; 56 struct sockaddr_in address;
@@ -72,7 +69,7 @@ int nc_main(int argc, char **argv)
72 case 'i': 69 case 'i':
73 delay = atoi(optarg); 70 delay = atoi(optarg);
74 break; 71 break;
75#ifdef GAPING_SECURITY_HOLE 72#ifdef CONFIG_NC_GAPING_SECURITY_HOLE
76 case 'e': 73 case 'e':
77 pr00gie = optarg; 74 pr00gie = optarg;
78 break; 75 break;
@@ -85,13 +82,12 @@ int nc_main(int argc, char **argv)
85 } 82 }
86 } 83 }
87 84
88#ifdef GAPING_SECURITY_HOLE 85#ifdef CONFIG_NC_GAPING_SECURITY_HOLE
89 if (pr00gie) { 86 if (pr00gie) {
90 /* won't need stdin */ 87 /* won't need stdin */
91 close (STDIN_FILENO); 88 close (STDIN_FILENO);
92 } 89 }
93#endif /* GAPING_SECURITY_HOLE */ 90#endif /* CONFIG_NC_GAPING_SECURITY_HOLE */
94
95 91
96 if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) 92 if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc))
97 bb_show_usage(); 93 bb_show_usage();
@@ -142,19 +138,18 @@ int nc_main(int argc, char **argv)
142 signal(SIGALRM, SIG_DFL); 138 signal(SIGALRM, SIG_DFL);
143 } 139 }
144 140
145#ifdef GAPING_SECURITY_HOLE 141#ifdef CONFIG_NC_GAPING_SECURITY_HOLE
146 /* -e given? */ 142 /* -e given? */
147 if (pr00gie) { 143 if (pr00gie) {
148 dup2(sfd, 0); 144 dup2(sfd, 0);
149 close(sfd); 145 close(sfd);
150 dup2 (0, 1); 146 dup2(0, 1);
151 dup2 (0, 2); 147 dup2(0, 2);
152 execl (pr00gie, pr00gie, NULL); 148 execl(pr00gie, pr00gie, NULL);
153 /* Don't print stuff or it will go over the wire.... */ 149 /* Don't print stuff or it will go over the wire.... */
154 _exit(-1); 150 _exit(-1);
155 } 151 }
156#endif /* GAPING_SECURITY_HOLE */ 152#endif /* CONFIG_NC_GAPING_SECURITY_HOLE */
157
158 153
159 FD_ZERO(&readfds); 154 FD_ZERO(&readfds);
160 FD_SET(sfd, &readfds); 155 FD_SET(sfd, &readfds);