summaryrefslogtreecommitdiff
path: root/src/usr.bin
diff options
context:
space:
mode:
authormarkus <>2004-01-22 13:28:46 +0000
committermarkus <>2004-01-22 13:28:46 +0000
commit25065dc9542519de5f238f16c84ba1d8864ec13b (patch)
treed880df63e932001570f866e80f21ba6811110443 /src/usr.bin
parent9d8f0334912497dc64a4c98c61e586a9caeccac8 (diff)
downloadopenbsd-25065dc9542519de5f238f16c84ba1d8864ec13b.tar.gz
openbsd-25065dc9542519de5f238f16c84ba1d8864ec13b.tar.bz2
openbsd-25065dc9542519de5f238f16c84ba1d8864ec13b.zip
-S enables tcp md5 signature option; ok deraadt@, mcbride@
Diffstat (limited to 'src/usr.bin')
-rw-r--r--src/usr.bin/nc/nc.16
-rw-r--r--src/usr.bin/nc/netcat.c25
2 files changed, 25 insertions, 6 deletions
diff --git a/src/usr.bin/nc/nc.1 b/src/usr.bin/nc/nc.1
index 29f506945c..5bf4480433 100644
--- a/src/usr.bin/nc/nc.1
+++ b/src/usr.bin/nc/nc.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: nc.1,v 1.26 2003/09/05 16:54:07 jmc Exp $ 1.\" $OpenBSD: nc.1,v 1.27 2004/01/22 13:28:46 markus Exp $
2.\" 2.\"
3.\" Copyright (c) 1996 David Sacerdote 3.\" Copyright (c) 1996 David Sacerdote
4.\" All rights reserved. 4.\" All rights reserved.
@@ -33,7 +33,7 @@
33.Nd "arbitrary TCP and UDP connections and listens" 33.Nd "arbitrary TCP and UDP connections and listens"
34.Sh SYNOPSIS 34.Sh SYNOPSIS
35.Nm nc 35.Nm nc
36.Op Fl 46hklnrtuvzU 36.Op Fl 46hklnrtuvzSU
37.Op Fl i Ar interval 37.Op Fl i Ar interval
38.Op Fl p Ar source port 38.Op Fl p Ar source port
39.Op Fl s Ar source ip address 39.Op Fl s Ar source ip address
@@ -154,6 +154,8 @@ If port is not specified, port 1080 is used.
154Specifies that 154Specifies that
155.Nm 155.Nm
156should just scan for listening daemons, without sending any data to them. 156should just scan for listening daemons, without sending any data to them.
157.It Fl S
158Enables the RFC 2385 TCP MD5 signature option.
157.It Fl U 159.It Fl U
158Specifies to use Unix Domain Sockets. 160Specifies to use Unix Domain Sockets.
159.It Fl X Ar version 161.It Fl X Ar version
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c
index df5c44a8ce..baeb3cefd1 100644
--- a/src/usr.bin/nc/netcat.c
+++ b/src/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: netcat.c,v 1.64 2003/10/19 22:50:35 deraadt Exp $ */ 1/* $OpenBSD: netcat.c,v 1.65 2004/01/22 13:28:46 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> 3 * Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
4 * 4 *
@@ -37,6 +37,7 @@
37#include <sys/un.h> 37#include <sys/un.h>
38 38
39#include <netinet/in.h> 39#include <netinet/in.h>
40#include <netinet/tcp.h>
40#include <arpa/telnet.h> 41#include <arpa/telnet.h>
41 42
42#include <err.h> 43#include <err.h>
@@ -71,6 +72,7 @@ int uflag; /* UDP - Default to TCP */
71int vflag; /* Verbosity */ 72int vflag; /* Verbosity */
72int xflag; /* Socks proxy */ 73int xflag; /* Socks proxy */
73int zflag; /* Port Scan Flag */ 74int zflag; /* Port Scan Flag */
75int Sflag; /* TCP MD5 signature option */
74 76
75int timeout = -1; 77int timeout = -1;
76int family = AF_UNSPEC; 78int family = AF_UNSPEC;
@@ -111,7 +113,7 @@ main(int argc, char *argv[])
111 endp = NULL; 113 endp = NULL;
112 sv = NULL; 114 sv = NULL;
113 115
114 while ((ch = getopt(argc, argv, "46UX:hi:klnp:rs:tuvw:x:z")) != -1) { 116 while ((ch = getopt(argc, argv, "46UX:hi:klnp:rs:tuvw:x:zS")) != -1) {
115 switch (ch) { 117 switch (ch) {
116 case '4': 118 case '4':
117 family = AF_INET; 119 family = AF_INET;
@@ -178,6 +180,9 @@ main(int argc, char *argv[])
178 case 'z': 180 case 'z':
179 zflag = 1; 181 zflag = 1;
180 break; 182 break;
183 case 'S':
184 Sflag = 1;
185 break;
181 default: 186 default:
182 usage(1); 187 usage(1);
183 } 188 }
@@ -437,7 +442,7 @@ int
437remote_connect(char *host, char *port, struct addrinfo hints) 442remote_connect(char *host, char *port, struct addrinfo hints)
438{ 443{
439 struct addrinfo *res, *res0; 444 struct addrinfo *res, *res0;
440 int s, error; 445 int s, error, x = 1;
441 446
442 if ((error = getaddrinfo(host, port, &hints, &res))) 447 if ((error = getaddrinfo(host, port, &hints, &res)))
443 errx(1, "getaddrinfo: %s", gai_strerror(error)); 448 errx(1, "getaddrinfo: %s", gai_strerror(error));
@@ -472,6 +477,11 @@ remote_connect(char *host, char *port, struct addrinfo hints)
472 errx(1, "bind failed: %s", strerror(errno)); 477 errx(1, "bind failed: %s", strerror(errno));
473 freeaddrinfo(ares); 478 freeaddrinfo(ares);
474 } 479 }
480 if (Sflag) {
481 if (setsockopt(s, IPPROTO_TCP, TCP_SIGNATURE_ENABLE,
482 &x, sizeof(x)) == -1)
483 err(1, NULL);
484 }
475 485
476 if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0) 486 if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0)
477 break; 487 break;
@@ -519,6 +529,12 @@ local_listen(char *host, char *port, struct addrinfo hints)
519 ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); 529 ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
520 if (ret == -1) 530 if (ret == -1)
521 err(1, NULL); 531 err(1, NULL);
532 if (Sflag) {
533 ret = setsockopt(s, IPPROTO_TCP, TCP_SIGNATURE_ENABLE,
534 &x, sizeof(x));
535 if (ret == -1)
536 err(1, NULL);
537 }
522 538
523 if (bind(s, (struct sockaddr *)res0->ai_addr, 539 if (bind(s, (struct sockaddr *)res0->ai_addr,
524 res0->ai_addrlen) == 0) 540 res0->ai_addrlen) == 0)
@@ -730,6 +746,7 @@ help(void)
730 fprintf(stderr, "\tCommand Summary:\n\ 746 fprintf(stderr, "\tCommand Summary:\n\
731 \t-4 Use IPv4\n\ 747 \t-4 Use IPv4\n\
732 \t-6 Use IPv6\n\ 748 \t-6 Use IPv6\n\
749 \t-S Enable the TCP MD5 signature option\n\
733 \t-U Use UNIX domain socket\n\ 750 \t-U Use UNIX domain socket\n\
734 \t-X vers\t SOCKS version (4 or 5)\n\ 751 \t-X vers\t SOCKS version (4 or 5)\n\
735 \t-h This help text\n\ 752 \t-h This help text\n\
@@ -753,7 +770,7 @@ help(void)
753void 770void
754usage(int ret) 771usage(int ret)
755{ 772{
756 fprintf(stderr, "usage: nc [-46Uhklnrtuvz] [-i interval] [-p source port]\n"); 773 fprintf(stderr, "usage: nc [-46SUhklnrtuvz] [-i interval] [-p source port]\n");
757 fprintf(stderr, "\t [-s ip address] [-w timeout] [-X vers] [-x proxy address [:port]]\n"); 774 fprintf(stderr, "\t [-s ip address] [-w timeout] [-X vers] [-x proxy address [:port]]\n");
758 fprintf(stderr, "\t [hostname] [port[s...]]\n"); 775 fprintf(stderr, "\t [hostname] [port[s...]]\n");
759 if (ret) 776 if (ret)