aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2017-12-19 02:03:02 +0100
committerToni Uhlig <matzeton@googlemail.com>2017-12-19 02:03:02 +0100
commit23bcd14d85b272e486ff90e1f761dadd4d9508e1 (patch)
treec173d5d785eebcd45aea8ba99c5b23fce2a0e217 /src
parent3c491a8bec71606b7af5f1d8c34de8e9710bbe13 (diff)
ptunnel-ng:
* autotools set/use package version string * autotools renamed output binary to ptunnel-ng * more "intuitive" short options * removed ptunnel version info, copyright update
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am11
-rw-r--r--src/options.c15
-rw-r--r--src/pconfig.h3
-rw-r--r--src/ptunnel-ng.8123
-rw-r--r--src/ptunnel.c9
5 files changed, 144 insertions, 17 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b51bad2..4e802cc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,14 +1,15 @@
-bin_PROGRAMS = ptunnel
+bin_PROGRAMS = ptunnel-ng
+man8_MANS = ptunnel-ng.8
-ptunnel_CFLAGS = -Wall
+ptunnel_ng_CFLAGS = -Wall
if HAVE_PCAP
-ptunnel_CFLAGS += -DHAVE_PCAP=1
+ptunnel_ng_CFLAGS += -DHAVE_PCAP=1
endif
if HAVE_SELINUX
-ptunnel_CFLAGS += -DHAVE_SELINUX=1
+ptunnel_ng_CFLAGS += -DHAVE_SELINUX=1
endif
-ptunnel_SOURCES = \
+ptunnel_ng_SOURCES = \
md5.c \
challenge.c \
options.c \
diff --git a/src/options.c b/src/options.c
index 0c9bbe8..d8061bd 100644
--- a/src/options.c
+++ b/src/options.c
@@ -6,6 +6,9 @@
#include <ctype.h>
#include <assert.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "options.h"
#include "utils.h"
#include "ptunnel.h"
@@ -138,10 +141,10 @@ static struct option long_options[] = {
{"remote-port", optional_argument, 0, 'R'},
{"connections", required_argument, 0, 'c'},
{"verbosity", required_argument, 0, 'v'},
- {"libpcap", required_argument, 0, 'a'},
+ {"libpcap", required_argument, 0, 'L'},
{"logfile", optional_argument, 0, 'o'},
{"statistics", no_argument, 0, 's'},
- {"passwd", required_argument, 0, 'x'},
+ {"passwd", required_argument, 0, 'P'},
{"udp", no_argument, &opts.udp, 1 },
{"unprivileged", no_argument, &opts.unprivileged, 1 },
{"base64", no_argument, &opts.base64, 1 },
@@ -292,7 +295,7 @@ static void print_short_help(unsigned index, int required_state) {
void print_usage(const char *arg0) {
unsigned i;
- printf("ptunnel-ng v%d.%.2d\n\nUsage: %s", kMajor_version, kMinor_version, arg0);
+ printf("%s\n\nUsage: %s", PACKAGE_STRING, arg0);
/* print (short)help argument line */
for (i = 0; i < ARRAY_SIZE(usage); ++i) {
print_short_help(i, 1);
@@ -328,7 +331,7 @@ int parse_options(int argc, char **argv) {
/* parse command line arguments */
while (1) {
- c = getopt_long(argc, argv, "m:p:l:r::R::c:v:a::o::sd::Sx:u::g::C::eh", &long_options[0], &optind);
+ c = getopt_long(argc, argv, "m:p:l:r::R::c:v:L::o::sP:d::Su::g::C::eh", &long_options[0], &optind);
if (c == -1) break;
switch (c) {
@@ -364,7 +367,7 @@ int parse_options(int argc, char **argv) {
case 'v':
opts.log_level = strtol(optarg, NULL, 10);
break;
- case 'a':
+ case 'L':
#ifdef HAVE_PCAP
opts.pcap = 1;
if (!optarg)
@@ -388,7 +391,7 @@ int parse_options(int argc, char **argv) {
case 's':
opts.print_stats = !opts.print_stats;
break;
- case 'x':
+ case 'P':
if (opts.password)
free(opts.password);
opts.password = strdup(optarg);
diff --git a/src/pconfig.h b/src/pconfig.h
index 4adabc9..0d79167 100644
--- a/src/pconfig.h
+++ b/src/pconfig.h
@@ -18,10 +18,7 @@ enum {
kLog_verbose,
kLog_debug,
kLog_sendrecv,
- /** Major (0.xx) and minor (x.70) version */
- kMajor_version = 0,
/** numbers */
- kMinor_version = 72,
kIP_packet_max_size = 576,
/** In bytes, mind you */
kIP_header_size = 20,
diff --git a/src/ptunnel-ng.8 b/src/ptunnel-ng.8
new file mode 100644
index 0000000..2377b2f
--- /dev/null
+++ b/src/ptunnel-ng.8
@@ -0,0 +1,123 @@
+.TH ptunnel 8 "September 5, 2011" "Version 0.72" "Yellow Lemon Software"
+.SH NAME
+ptunnel \- tunnel TCP connections over ICMP echo request/reply packets.
+.SH SYNOPSIS
+.B ptunnel
+\-p proxy_address \-lp listen_port \-da destination_address \-dp dest_port [\-c network_device] [\-v verbosity] [\-f file] [\-udp] [\-syslog]
+
+.B ptunnel
+[\-c network_device] [\-v verbosity] [\-f file] [\-udp] [\-syslog] [\-daemon file]
+
+.B ptunnel
+[\-u] [\-x password] [\-setuid user] [\-setgid group] [\-chroot dir] [\-setcon context]
+
+.B ptunnel
+\-h
+.SH DESCRIPTION
+ptunnel is an application that allows you to reliably tunnel TCP connections to a remote host using ICMP echo request and reply packets, commonly known as ping requests and replies. At first glance, this might seem like a rather useless thing to do, but it can actually come in handy in some cases. The following example illustrates the main motivation in creating ptunnel:
+.PP
+Setting: You're on the go, and stumble across an open wireless network. The network gives you an IP address, but won't let you send TCP or UDP packets out to the rest of the internet, for instance to check your mail. What to do? By chance, you discover that the network will allow you to ping any computer on the rest of the internet. With ptunnel, you can utilize this feature to check your mail, or do other things that require TCP.
+.SH OPTIONS
+.TP
+.SH Client options:
+.TP
+.B \-p proxy_address
+Specify the host on which the proxy is running.
+.TP
+.B \-lp listen_port
+Specifies the port on which the client will listen for incoming TCP connections.
+.TP
+.B \-da destination_addr
+Specifies the address to which you want your packets tunneled after reaching the proxy when in client mode, or restricts the destination packets can be forwarded to when in server mode.
+.TP
+.B \-dp destination_port
+Specifies/restrict the port that the proxy should tunnel the TCP connection to.
+.TP
+.SH Shared options:
+.TP
+.B \-c network_device
+Specify the network interface to capture packets from. Note that packet capturing isn't always necessary, but you should try this if you experience problems with ptunnel.
+.TP
+.B \-v verbosity
+Controls the verbosity level. \-1 is no output, 0 shows errors only, 1 shows info messages, 2 gives more output, 3 provides even more output, level 4 displays debug info and level 5 displays absolutely everything, including the nasty details of sends and receives.
+.TP
+.B \-udp
+Enables tunneling over UDP port 53 (DNS) instead of using ICMP. This will only work if your proxy can accept incoming traffic on port 53, and the client is able to send data to the proxy on port 53. Note that this option does not wrap ptunnel's data in DNS\-compliant packets. This option must be given on both the proxy and client side for things to work correctly.
+.TP
+.B \-syslog (Not available on Windows.)
+Changes logging to use the built\-in syslog fascility.
+.TP
+.B \-daemon file (Not available on Windows.)
+Run in background, writing PID in file.
+.TP
+.B \-u
+Attempts to run ptunnel without privileges. This doesn't usually work! On UNIX systems please consider using the following three options instead:
+.TP
+.B \-setuid user (Not available on Windows.)
+When started in privileged mode, drop down to user's rights as soon as possible.
+.TP
+.B \-setgid group (Not available on Windows.)
+When started in privileged mode, drop down to group's rights as soon as possible.
+.TP
+.B \-chroot dir (Not available on Windows.)
+When started in privileged mode, restrict file access to the specified directory.
+.TP
+.B \-setcon context (Not available on Windows.)
+Set SELinux context when all there is left to do are network I/O operations.
+In order to be able to combine with \-chroot you will have to `mount --bind /proc /chrootdir/proc`
+.TP
+.B \-x password
+Specifies a password or passphrase to use. This will allow you to protect the proxy from use by others who don't know the password. It needs to be specified on both proxy and client.
+.TP
+.B \-f file
+Specifies a log file. If you specify \-syslog, syslog is always used instead.
+.TP
+.B \-h
+Displays brief usage information.
+
+.SH EXAMPLES
+The following assumes that ptunnel is run as root, both on the proxy and client. To tunnel ssh connections from the client machine via a proxy running on proxy.pingtunnel.com to the computer login.domain.com, the following command line would be used:
+.TP
+.B ptunnel \-p proxy.pingtunnel.com \-lp 8000 \-da login.domain.com \-dp 22
+.PP
+An ssh connection to login.domain.com can now be established as follows:
+.TP
+.B ssh \-p 8000 localhost
+.PP
+If ssh complains about potential man\-in\-the\-middle attacks, simply remove the offending key from the known_hosts file. The warning/error is expected if you have previously ssh'd to your local computer (i.e., ssh localhost), or you have used ptunnel to forward ssh connections to different hosts.
+
+Of course, for all of this to work, you need to start the proxy on your proxy\-computer (proxy.pingtunnel.com). Doing this is very simple:
+
+.B ptunnel
+
+If you find that the proxy isn't working, you will need to enable packet capturing on the main network device. Currently this device is assumed to be an ethernet-device (i.e., ethernet or wireless). Packet capturing is enabled by giving the -c switch, and supplying the device name to capture packets on (for instance eth0 or en1). The same goes for the client. On Mac OS X, packet capturing must always be enabled (both for proxy and client), as resent packets won't be received otherwise.
+
+To protect yourself from others using your proxy, you can protect access to it with a password using the <tt>\-x</tt> switch. The password is never sent in the clear, but keep in mind that it may be visible from tools like top or ps, which can display the command line used to start an application.
+
+.SH EXIT STATUS
+.B ptunnel
+does not exit until forced to do so by an interrupt (Ctrl\-C) or if it crashes.
+.SH BUGS
+.B ptunnel
+currently does not handle packet capturing on network interfaces other than ethernet or wireless correctly.
+.SH AUTHORS AND CONTRIBUTORS
+Daniel Stoedle (daniels@cs.uit.no)
+
+Windows port: Mike Miller (mike@mikeage.net)
+
+SELinux support: Sebastien Raveau (sebastien.raveau@epita.fr)
+
+Patches: Joe McKenzie, Steffen Wendzel and StalkR.
+
+.SH LICENSE
+.B ptunnel
+is licensed under the BSD License.
+.SH AVAILABILITY
+.TP
+The ptunnel homepage is currently located here:
+http://www.cs.uit.no/~daniels/PingTunnel/
+.TP
+The freshmeat project page is located here:
+http://freshmeat.net/projects/ptunnel/
+.PP
+Please take the time to rate ptunnel if you find it useful. Thanks!
diff --git a/src/ptunnel.c b/src/ptunnel.c
index 0af75f8..95ebbac 100644
--- a/src/ptunnel.c
+++ b/src/ptunnel.c
@@ -42,7 +42,9 @@
*
* Note that the source code is best viewed with tabs set to 4 spaces.
*/
-
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "ptunnel.h"
#include "options.h"
#include "utils.h"
@@ -150,8 +152,9 @@ int main(int argc, char *argv[]) {
opts.pcap = 0;
}
#endif
- pt_log(kLog_info, "Starting ptunnel v %d.%.2d.\n", kMajor_version, kMinor_version);
+ pt_log(kLog_info, "Starting %s.\n", PACKAGE_STRING);
pt_log(kLog_info, "(c) 2004-2011 Daniel Stoedle, <daniels@cs.uit.no>\n");
+ pt_log(kLog_info, "(c) 2017 Toni Uhlig, <matzeton@googlemail.com>\n");
#ifdef WIN32
pt_log(kLog_info, "Windows version by Mike Miller, <mike@mikeage.net>\n");
#else
@@ -635,7 +638,7 @@ void* pt_proxy(void *args) {
if (opts.pcap) {
if (pcap_dispatch(pc.pcap_desc, 32, pcap_packet_handler, (u_char*)&pc.pkt_q) > 0) {
pqueue_elem_t *cur;
- /* pt_log(kLog_verbose, "pcap captured %d packets - handling them..\n", pc.pkt_q.elems); */
+ pt_log(kLog_verbose, "pcap captured %d packets - handling them..\n", pc.pkt_q.elems);
while (pc.pkt_q.head) {
cur = pc.pkt_q.head;
memset(&addr, 0, sizeof(struct sockaddr));