diff options
34 files changed, 911 insertions, 51 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..df158f1 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,28 @@ +image: debian:stable-slim + +stages: + - build + +build: + script: + - apt-get -qq update + - apt-get install -y git debhelper fakeroot + - apt-get install -y libpcap-dev libselinux1-dev + - apt-get install -y binutils-mingw-w64-i686 gcc-mingw-w64 mingw-w64-i686-dev mingw-w64-common + - apt-get install -y autoconf automake dh-autoreconf + - mkdir -p ../bin + - ./autogen.sh + - cp ./src/ptunnel-ng ../bin/ + - git clean -df . && dpkg-buildpackage -b -us -uc + - git clean -df . && export CC=i686-w64-mingw32-gcc && ./autogen.sh --host=i686-w64-mingw32 --build=$(gcc -dumpmachine) + - cp ./src/ptunnel-ng.exe ../bin/ + - mkdir -p ./bin + - cp -v ../*.deb ../bin/* ./bin/ + - cp -v ./bin/ptunnel-ng ./bin/ptunnel-ng-dbgsym && strip -s ./bin/ptunnel-ng + - cp -v ./bin/ptunnel-ng.exe ./bin/ptunnel-ng-dbgsym.exe && i686-w64-mingw32-strip -s ./bin/ptunnel-ng.exe + artifacts: + paths: + - bin/ + stage: build + only: + - master diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..99d698e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +language: c +before_install: +- sudo apt-get -qq update +- sudo apt-get install -y git debhelper fakeroot +- sudo apt-get install -y libpcap-dev libselinux1-dev +- sudo apt-get install -y binutils-mingw-w64-i686 gcc-mingw-w64 mingw-w64-i686-dev + mingw-w64-common +- sudo apt-get install -y autoconf automake dh-autoreconf +after_failure: +- cat config.log +script: +- "./autogen.sh" +- git clean -df . && dpkg-buildpackage -b -us -uc +- git clean -df . && export CC=i686-w64-mingw32-gcc && ./autogen.sh --host=i686-w64-mingw32 + --build=$(gcc -dumpmachine) +env: + global: + - secure: CN5K1QzTszUC/+U9m7cs2JJON/xUHf5umtAGQDrDCkr1o0y4+jbLv6LS5iBoJ3mG5mCeoVHfubg+2kk46+QiwgoRnENw59/aXotAELYZjkYDhi4KpZ/AjJ0sUiC2YlHE6pyC9PO/atMWGqATboP77EwbgYd+JAjblzh3FzKZ8GTavpaHDo8P96UE/YlmYewlHe2iqm36OyXhrOApqqa2hEDYmSXS8HIWhXszm0nwpdeee6ys8pC+ZHxSkPZ0u+N8pf71my25vqRGcpz7VWktv0FMfNvld9+dgw+SZBk9i9YALvJHkEdcBwAmlg9EoT8LsI3GPvuPI1C0sQPq5fT2POUa4DB59IiKbhRoajwFs7g+LiJvuW2VewWWf3K0eacyQ5/G5ATfzuCC83qo1mr3UwVSTwdpPdHumUV6DnR7JPbh1d2ZzzpG9rUpkB7Gg7DiR19w0DRyRq5FvaBmEdRudjBeySXmOE+MwxfBqZUgmNtd2rTaNKWj2XlGCHuyi5rUD2Y0cFaOOdqqwYEIDNEPpdOGoihHfGDFsvAg21h81peW/9p9CBmnXOH+8b/BnSeh0ibP0SXnPZMFUy8RaHBVnNTmOqDSym4uBB+KzJ5a/VGdO4O4SAwHF/PkQfqHQr5TNO4WaZd6mY7JWsXkYRi+4KIglQIIBYhkhBO1Z7L855k= + - secure: hiXIUA1FAFvFoAsw5PHTqjhcOC3Iji2Kc7dbaaC8GRFzg5nlZTTLpsI9u0vA7OcCMAR5EfQsMp6a8p7VDPnJVcydAS3wz534GpHr5ooDfVngQDIFdtZ3SHn17KoM20X/3ksZZmqUjACXYxYwAOOQxLWf9Ribi94T0uaTWAiw9m9fBm3YGLVf20AFsschHSil0XqrTE/EK1an6enqQkCsiodsNaoBnMij8KpgUy4n9CoA0afbOgc10LEwChqbuEytZoP2Nr0mIxNA/ZdOk8BmdSMCJE0SOfJdZl0NFmo1UY69WOIuhUCvRnnWfTMRn0T5VncXLBL8kXoETwsVGUkjaDkdwwNWT/t6AIKRyzz0sH/wiht5wf0+f8uVwszcMhEFJU3QonfZ1JQrjfqQpaX7zeH9SSfpMJsgaWc8cFGHwxeU8+LNMuSnSXDNgLUxG2lX7ozoXVs85jUL6RG6ET9AZCf70OonKT9S+fXFDtfIFrdJPyQ2xDANthDsp3v4cuGYesSGSOk3LGc4GOheorRSUovwBVfACTaVvTf8m5XkU6Kt9rMOgG50SeZlum3tsJt0DH6GOGoYglkoKUtqFur1PGTcyaGFMQscj4yVBBd+0g7h2ypl+9uQsqdREbJoYXA9IXQ+Goj24C2AmZQ880k46K1z0uHalDZYaiHmNf25RYE= +addons: + coverity_scan: + project: + name: lnslbrty/ptunnel-ng + notification_email: matzeton@googlemail.com + build_command_prepend: autoreconf -i && ./configure + build_command: make + branch_pattern: coverity_scan @@ -1,6 +1,12 @@ PingTunnel-NG Changelog ======================= +1.20 - 15. July 2018 +- Readme improvements +- Fixes a possible memory leak when a packet could not send +- Better error handling on socket descriptor creation +- All Coverity issues fixed + 1.00 - 18. December 2017 - First public release - Fixes a exploitable memory leak (proxy/forwarder) if using password diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..2e4186a --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,28 @@ +pkgname="ptunnel-ng" +pkgver=1.1 +pkgrel=1 +pkgdesc="PingTunnel-NG binary for icmp/udp tunneling" +arch=('i686' 'x86_64') +url='https://www.github.com/lnslbrty/ptunnel-ng' +license=('BSD-3') +makedepends=('git') +provides=("ptunnel-ng=${pkgver}") +source=("https://github.com/lnslbrty/ptunnel-ng/archive/v${pkgver}.tar.gz") +md5sums=('SKIP') + +build() { + cd "${srcdir}/${pkgname}-${pkgver}" + ./configure \ + --prefix=/usr \ + --libdir=/usr/lib \ + --disable-pcap \ + --disable-selinux + make +} + +package() { + cd "${srcdir}/${pkgname}-${pkgver}" + make DESTDIR="${pkgdir}" install + find "${pkgdir}" -type d -name .git -exec rm -r '{}' + + install -D -m644 COPYING "${pkgdir}/usr/share/licenses/ptunnel-ng/LICENSE" +} @@ -24,6 +24,12 @@ The official ptunnel website is located here: <http://www.cs.uit.no/~daniels/PingTunnel/> +Dependencies +------------ +Required: pthread +Optional: pcap, selinux + + Compiling --------- Either run "./autogen.sh" for a fully automatic build or run it manually with: diff --git a/README.md b/README.md new file mode 100644 index 0000000..34c00c1 --- /dev/null +++ b/README.md @@ -0,0 +1,150 @@ +[](https://travis-ci.org/lnslbrty/ptunnel-ng) +[](https://scan.coverity.com/projects/14737) +[](https://www.codacy.com/app/lnslbrty/ptunnel-ng?utm_source=github.com&utm_medium=referral&utm_content=lnslbrty/ptunnel-ng&utm_campaign=Badge_Grade) +[](https://github.com/lnslbrty/ptunnel-ng/issues) +[](https://github.com/lnslbrty/ptunnel-ng/blob/master/COPYING) +[](https://gitter.im/ptunnel-ng/Lobby) + +# PingTunnel-[N]ew[G]eneration Read Me + +## What is ptunnel-ng? +``` +Ptunnel-NG is a bugfixed and refactored version of Ptunnel with some additional +features e.g. change the magic value without recompiling (bypass Cisco IPS). +``` + +## What is ptunnel? +``` +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. +``` + +## How does it work? +``` +ICMP Packet structure +``` + +``` +Ptunnel program setup +``` + + +## Contact details +``` +The ptunnel-ng fork was done by Toni Uhlig: + <matzeton@googlemail.com> +You can contact the author of ptunnel, Daniel Stoedle, here: + <daniels@cs.uit.no> +The official ptunnel website is located here: + <http://www.cs.uit.no/~daniels/PingTunnel/> +``` + +## Dependencies +``` +Required: pthread +Optional: pcap, selinux +``` + +## Compiling +``` +Either run "./autogen.sh" for a fully automatic build or run it manually with: + "./configure && make" + +You should end up with a binary called ptunnel-ng. +This serves as both the client and proxy. You can +optionally install it using "make install". +To compile the Windows binary. You will need mingw installed. +If you want pcap support you will need the WinPcap library as well. +WinPcap is available here: + <http://www.winpcap.org/install/bin/WpdPack_4_0_2.zip> + +REMEMBER: ptunnel-ng might not work on Windows without WinPcap! +``` + +## Running +``` +Ptunnel works best when starting as root, and usually requires starting as root. +Common ptunnel-ng options: + +Proxy(Server): + ./ptunnel-ng -r<destination address> -R<destination port> -v <loglevel> + -P<password> -u<user> -g<group> + +Forwarder(Client): + ./ptunnel-ng -p <address> -l <listen port> -r<destination address> + -R<destination port> -v <loglevel> + -P<password> -u<user> -g<group> + +The -p switch sets the address of the host on which the proxy is running. A +quick test to see if the proxy will work is simply to try pinging this host - +if you get replies, you should be able to make the tunnel work. +If pinging works but you are not able to establish a tunnel, you should play +around with the -m switch and change the magic value. A IDS/IPS or Firwall +might try to fool you. + +The -l, -r and -R switches set the local listening port, destination address +and destination port. For instance, 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: + +sudo ./ptunnel-ng -p proxy.pingtunnel.com -l 8000 -r login.domain.com -R 22 + +An ssh connection to login.domain.com can now be established as follows: + +ssh -p 8000 localhost + +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-ng 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 (we'll call it proxy.pingtunnel.com here). Doing this is very +simple: + +sudo ./ptunnel-ng + +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 -L switch, and supplying the device name to capture packets on (for +instance eth0 or en1). The same goes for the client. On versions of Mac OS X +prior to 10.4 (Tiger), 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 -P 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. + +Finally, the -u switch will attempt to run the proxy in unprivileged mode (i.e., +no need for root access), and the -v switch controls the amount of output from +ptunnel-ng. -1 indicates 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. The -o switch allows output to be saved to a logfile. + +Security features: Please see the ptunnel-ng man-page for instructions. +``` + +## Supported operating systems +``` +Ptunnel supports most operating systems with libpcap, the usual POSIX functions +and a BSD sockets compatible API. In particular, it has been tested on Linux +Fedora Core 2 and Mac OS X 10.3.6 and above. As of version 0.7, ptunnel-ng can also +be compiled on Windows, courtesy of Mike Miller, assuming mingw and WinPcap is +installed. +``` + +## Credits and contributors +``` +Daniel Stoedle et al. +``` + +## License +``` +Ping Tunnel NG is Copyright (c) 2017, Toni Uhlig <matzeton@googlemail.com>, +All rights reserved. Ping Tunnel NG is licensed under the +BSD License. Please see the COPYING file for details. +``` diff --git a/configure.ac b/configure.ac index 54285fc..a96a2fc 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.69) -AC_INIT([ptunnel-ng], [1.0], [], [], []) +AC_INIT([ptunnel-ng], [1.2], [], [], []) AC_CONFIG_SRCDIR([src/config.h.in]) AC_CONFIG_FILES([Makefile src/Makefile]) @@ -26,6 +26,8 @@ esac AM_SILENT_RULES([yes]) AM_INIT_AUTOMAKE AC_PROG_INSTALL +AC_PROG_CC +AC_PROG_CC_STDC AC_USE_SYSTEM_EXTENSIONS AC_C_CONST AC_C_INLINE @@ -34,6 +36,11 @@ AC_CHECK_HEADER_STDBOOL AC_FUNC_VPRINTF AC_FUNC_MEMCMP +dnl Check for -std=gnu99 +if test x"${ac_cv_prog_cc_stdc}" = x"no"; then + AC_MSG_ERROR([Your compiler does not support \`-std=gnu99\`. This is fatal.]) +fi + dnl Check for std includes. AC_CHECK_HEADERS([stdarg.h stdio.h unistd.h stdlib.h string.h stdint.h time.h signal.h assert.h],, [AC_MSG_ERROR([Missing essential std headers.])]) diff --git a/contrib/freetz/make/pingtunnel-ng/Config.in b/contrib/freetz/make/pingtunnel-ng/Config.in new file mode 100644 index 0000000..c4e7655 --- /dev/null +++ b/contrib/freetz/make/pingtunnel-ng/Config.in @@ -0,0 +1,9 @@ +config FREETZ_PACKAGE_PINGTUNNEL_NG + bool "Pingtunnel-NG 1.1" + default n + help + Ptunnel-NG 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. This is the [N]ew [G]eneration fork of PingTunnel! diff --git a/contrib/freetz/make/pingtunnel-ng/external.files b/contrib/freetz/make/pingtunnel-ng/external.files new file mode 100644 index 0000000..0491f65 --- /dev/null +++ b/contrib/freetz/make/pingtunnel-ng/external.files @@ -0,0 +1 @@ +[ "$EXTERNAL_FREETZ_PACKAGE_PINGTUNNEL_NG" == "y" ] && EXTERNAL_FILES+=" /usr/sbin/ptunnel-ng" diff --git a/contrib/freetz/make/pingtunnel-ng/external.in b/contrib/freetz/make/pingtunnel-ng/external.in new file mode 100644 index 0000000..033f18a --- /dev/null +++ b/contrib/freetz/make/pingtunnel-ng/external.in @@ -0,0 +1,7 @@ +config EXTERNAL_FREETZ_PACKAGE_PINGTUNNEL_NG + depends on EXTERNAL_ENABLED && FREETZ_PACKAGE_PINGTUNNEL_NG + bool "pingtunnel-ng" + default n + help + externals the following file(s): + /usr/sbin/ptunnel-ng diff --git a/contrib/freetz/make/pingtunnel-ng/external.services b/contrib/freetz/make/pingtunnel-ng/external.services new file mode 100644 index 0000000..73ea3a2 --- /dev/null +++ b/contrib/freetz/make/pingtunnel-ng/external.services @@ -0,0 +1,2 @@ +[ "$EXTERNAL_FREETZ_PACKAGE_PINGTUNNEL_NG" == "y" ] && EXTERNAL_SERVICES+=" pingtunnel-ng" + diff --git a/contrib/freetz/make/pingtunnel-ng/files/root/etc/default.pingtunnel-ng/pingtunnel-ng.cfg b/contrib/freetz/make/pingtunnel-ng/files/root/etc/default.pingtunnel-ng/pingtunnel-ng.cfg new file mode 100644 index 0000000..a70e8e6 --- /dev/null +++ b/contrib/freetz/make/pingtunnel-ng/files/root/etc/default.pingtunnel-ng/pingtunnel-ng.cfg @@ -0,0 +1,4 @@ +export PINGTUNNELNG_ENABLED='no' +export PINGTUNNELNG_PASSWORD='' +export PINGTUNNELNG_EXTRA='' +export PINGTUNNELNG_MAGIC='0xdeadc0de' diff --git a/contrib/freetz/make/pingtunnel-ng/files/root/etc/init.d/rc.pingtunnel-ng b/contrib/freetz/make/pingtunnel-ng/files/root/etc/init.d/rc.pingtunnel-ng new file mode 100755 index 0000000..cc60526 --- /dev/null +++ b/contrib/freetz/make/pingtunnel-ng/files/root/etc/init.d/rc.pingtunnel-ng @@ -0,0 +1,57 @@ +#!/bin/sh + +DAEMON=pingtunnel-ng +DAEMON_BIN=ptunnel-ng +PID_FILE=/var/run/$DAEMON.pid +. /etc/init.d/modlibrc + +start() { + mkdir -p /tmp/$DAEMON_BIN + [ -z "$PINGTUNNELNG_EXTRA" ] && PINGTUNNELNG_EXTRA="--syslog" + modlib_startdaemon $DAEMON_BIN \ + $PINGTUNNELNG_EXTRA \ + --magic $PINGTUNNELNG_MAGIC \ + --passwd $PINGTUNNELNG_PASSWORD \ + --daemon $PID_FILE \ + --chroot /tmp/$DAEMON_BIN \ + --user nobody \ + --group nobody +} + +stop_post() { + [ "$1" == "0" ] && rm -rf /tmp/$DAEMON_BIN 2>/dev/null +} + +case $1 in + ""|load) + modlib_add_user_and_group nobody + + modreg cgi 'pingtunnel-ng' 'pingtunnel-ng' + modreg daemon $DAEMON + + modlib_start $PINGTUNNELNG_ENABLED + ;; + unload) + modunreg daemon $DAEMON + modunreg cgi 'pingtunnel-ng' + modlib_stop + ;; + start) + modlib_start + ;; + stop) + modlib_stop + ;; + restart) + modlib_restart + ;; + status) + modlib_status + ;; + *) + echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 + exit 1 + ;; +esac + +exit 0 diff --git a/contrib/freetz/make/pingtunnel-ng/files/root/usr/lib/cgi-bin/pingtunnel-ng.cgi b/contrib/freetz/make/pingtunnel-ng/files/root/usr/lib/cgi-bin/pingtunnel-ng.cgi new file mode 100755 index 0000000..ae6b9e4 --- /dev/null +++ b/contrib/freetz/make/pingtunnel-ng/files/root/usr/lib/cgi-bin/pingtunnel-ng.cgi @@ -0,0 +1,20 @@ +#!/bin/sh + +. /usr/lib/libmodcgi.sh + +sec_begin '$(lang de:"Starttyp" en:"Start type")' +cgi_print_radiogroup_service_starttype "enabled" "$PINGTUNNELNG_ENABLED" "" "" 0 +sec_end + +sec_begin '$(lang de:"Server" en:"Server")' + +cgi_print_password_p "password" "$PINGTUNNELNG_PASSWORD" 20/32 \ + "$(lang de:"Tunnel-Passwort" en:"Tunnel password"): " + +cgi_print_textline_p "extra" "$PINGTUNNELNG_EXTRA" 40/255 \ + "$(lang de:"Erweiterte Optionen" en:"Extra options"): " + +cgi_print_textline_p "magic" "$PINGTUNNELNG_MAGIC" 20/32 \ + "$(lang de:"ICMP Tunnel magische Nummer" en:"ICMP Tunnel Magic Number"): " + +sec_end diff --git a/contrib/freetz/make/pingtunnel-ng/pingtunnel-ng.mk b/contrib/freetz/make/pingtunnel-ng/pingtunnel-ng.mk new file mode 100644 index 0000000..20c2a8d --- /dev/null +++ b/contrib/freetz/make/pingtunnel-ng/pingtunnel-ng.mk @@ -0,0 +1,35 @@ +$(call PKG_INIT_BIN, 1.1) +$(PKG)_SOURCE:=ptunnel-ng-$($(PKG)_VERSION).tar.gz +$(PKG)_SOURCE_SHA256:=3182ecc4f9a7ef3ae8895b460aa596ae050b9718b98fd5eaf224772fba017c22 +$(PKG)_SITE:=https://github.com/lnslbrty/ptunnel-ng/releases/download/v$($(PKG)_VERSION) +$(PKG)_DIR:=$($(PKG)_SOURCE_DIR)/ptunnel-ng-$($(PKG)_VERSION) + +$(PKG)_BINARY:=$($(PKG)_DIR)/src/ptunnel-ng +$(PKG)_TARGET_BINARY:=$($(PKG)_DEST_DIR)/usr/sbin/ptunnel-ng + +$(PKG)_BUILD_PREREQ += aclocal automake autoconf +$(PKG)_DEPENDS_ON += libpcap + +$(PKG)_EXTRA_CFLAGS += -std=gnu99 +$(PKG)_CONFIGURE_OPTIONS += --disable-selinux + +$(PKG_SOURCE_DOWNLOAD) +$(PKG_UNPACKED) +$(PKG_CONFIGURED_CONFIGURE) + +$($(PKG)_BINARY): $($(PKG)_DIR)/.configured + echo "______$(PINGTUNNEL_NG_EXTRA_CFLAGS)_____" + $(SUBMAKE) -C $(PINGTUNNEL_NG_DIR) V=1 \ + CFLAGS="$(TARGET_CFLAGS) $(PINGTUNNEL_NG_EXTRA_CFLAGS)" + +$($(PKG)_TARGET_BINARY): $($(PKG)_BINARY) + $(INSTALL_BINARY_STRIP) + +$(pkg): + +$(pkg)-precompiled: $($(PKG)_TARGET_BINARY) + +$(pkg)-uninstall: + $(RM) $(PINGTUNNEL_NG_TARGET_BINARY) + +$(PKG_FINISH) diff --git a/debian/control b/debian/control index c6423fd..6b3e172 100644 --- a/debian/control +++ b/debian/control @@ -4,8 +4,7 @@ Priority: optional Maintainer: Debian QA Group <packages@qa.debian.org> Build-Depends: debhelper (>= 9), libpcap0.8-dev | libpcap-dev, - libselinux1-dev [linux-any], - patchutils (>= 0.2.25) + libselinux1-dev [linux-any] Standards-Version: 3.9.7 Homepage: https://github.com/lnslbrty/ptunnel-ng diff --git a/selinux/CVS/Entries b/selinux/CVS/Entries deleted file mode 100644 index 32b83d2..0000000 --- a/selinux/CVS/Entries +++ /dev/null @@ -1,2 +0,0 @@ -/ptunnel.te/1.1/Mon Jun 22 08:09:46 2009// -D diff --git a/selinux/CVS/Repository b/selinux/CVS/Repository deleted file mode 100644 index f41a656..0000000 --- a/selinux/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -pingtunnel/selinux diff --git a/selinux/CVS/Root b/selinux/CVS/Root deleted file mode 100644 index d2a18e8..0000000 --- a/selinux/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:ext:daniels@lgserv3.stud.cs.uit.no:/users/daniels/cvsroot diff --git a/src/challenge.c b/src/challenge.c index 4d8bf65..24a13f7 100644 --- a/src/challenge.c +++ b/src/challenge.c @@ -1,3 +1,48 @@ +/* + * challenge.c + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #include <stdlib.h> #include <string.h> #include <sys/time.h> diff --git a/src/challenge.h b/src/challenge.h index 4863782..035a97e 100644 --- a/src/challenge.h +++ b/src/challenge.h @@ -1,3 +1,48 @@ +/* + * challenge.h + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #ifndef CHALLENGE_H #define CHALLENGE_H 1 diff --git a/src/options.c b/src/options.c index 89bae5e..b52c1ac 100644 --- a/src/options.c +++ b/src/options.c @@ -1,3 +1,36 @@ +/* + * options.c + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + #include <stdio.h> #include <unistd.h> #include <stdint.h> @@ -361,8 +394,7 @@ int parse_options(int argc, char **argv) { opts.given_proxy_hostname = strdup(optarg); break; case 'l': - if (optarg) - opts.tcp_listen_port = strtoul(optarg, NULL, 10); + opts.tcp_listen_port = strtoul(optarg, NULL, 10); break; case 'r': opts.restrict_dst_ip = 1; diff --git a/src/options.h b/src/options.h index d5023a4..3c42a19 100644 --- a/src/options.h +++ b/src/options.h @@ -1,3 +1,36 @@ +/* + * options.h + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef OPTIONS_H #define OPTIONS_H 1 diff --git a/src/pconfig.h b/src/pconfig.h index 0d79167..c85df14 100644 --- a/src/pconfig.h +++ b/src/pconfig.h @@ -1,3 +1,48 @@ +/* + * pconfig.h + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #ifndef PCONFIG_H #define PCONFIG_H 1 diff --git a/src/pdesc.c b/src/pdesc.c index 0181cae..906f35c 100644 --- a/src/pdesc.c +++ b/src/pdesc.c @@ -1,3 +1,48 @@ +/* + * pdesc.c + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #include <stdlib.h> #include <sys/time.h> @@ -42,7 +87,9 @@ proxy_desc_t* create_and_insert_proxy_desc(uint16_t id_no, uint16_t icmp_id, addr->sin_addr.s_addr = dst_ip; addr->sin_family = AF_INET; /* Let's just assume success, shall we? */ - if (connect(cur->sock, (struct sockaddr*)addr, sizeof(struct sockaddr_in)) < 0) { + if (cur->sock >= 0 && + connect(cur->sock, (struct sockaddr*)addr, sizeof(struct sockaddr_in)) < 0) + { pt_log(kLog_error, "Connect to %s:%d failed: %s\n", inet_ntoa(*(struct in_addr*)&addr->sin_addr.s_addr) , ntohs(addr->sin_port), strerror(errno)); } } @@ -169,6 +216,7 @@ int queue_packet(int icmp_sock, uint8_t type, char *buf, int num_bytes, (struct sockaddr*)dest_addr, sizeof(struct sockaddr)); if (err < 0) { pt_log(kLog_error, "Failed to send ICMP packet: %s\n", strerror(errno)); + free(pkt); return -1; } else if (err != pkt_len) diff --git a/src/pdesc.h b/src/pdesc.h index 9c759ef..35147db 100644 --- a/src/pdesc.h +++ b/src/pdesc.h @@ -1,3 +1,48 @@ +/* + * pdesc.h + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #ifndef PDESC_H #define PDESC_H 1 @@ -1,3 +1,48 @@ +/* + * pkt.c + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #ifndef WIN32 #include <netinet/in.h> #include <arpa/inet.h> @@ -1,3 +1,48 @@ +/* + * pkt.h + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #ifndef PKT_H #define PKT_H 1 diff --git a/src/ptunnel.c b/src/ptunnel.c index e7a93de..7ac7ecb 100644 --- a/src/ptunnel.c +++ b/src/ptunnel.c @@ -261,6 +261,10 @@ void pt_forwarder(void) { pt_log(kLog_debug, "Starting forwarder..\n"); /** Open our listening socket */ sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock < 0) { + pt_log(kLog_error, "Failed to create socket: %s\n", strerror(errno)); + return; + } if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const void *) &yes, sizeof(int)) == -1) { pt_log(kLog_error, "Failed to set SO_REUSEADDR option on listening socket: %s\n", strerror(errno)); close(sock); diff --git a/src/ptunnel.h b/src/ptunnel.h index f2b514d..966f5ba 100644 --- a/src/ptunnel.h +++ b/src/ptunnel.h @@ -1,44 +1,45 @@ -/* ptunnel.h - ptunnel is licensed under the BSD license: - - Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, - Yellow Lemon Software. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - - Neither the name of the Yellow Lemon Software nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - Contacting the author: - You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, - in case your text editor didn't realize), here: <daniels@cs.uit.no> - - The official ptunnel website is here: - <http://www.cs.uit.no/~daniels/PingTunnel/> - - Note that the source code is best viewed with tabs set to 4 spaces. -*/ +/* + * ptunnel.h + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ #ifndef PING_TUNNEL_H #define PING_TUNNEL_H 1 diff --git a/src/utils.c b/src/utils.c index 3305456..2cbebc4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,3 +1,48 @@ +/* + * utils.c + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #include <stdarg.h> #include <string.h> diff --git a/src/utils.h b/src/utils.h index e0355d1..8afa45c 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,3 +1,48 @@ +/* + * utils.h + * ptunnel is licensed under the BSD license: + * + * Copyright (c) 2004-2011, Daniel Stoedle <daniels@cs.uit.no>, + * Yellow Lemon Software. All rights reserved. + * + * Copyright (c) 2017 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of the Yellow Lemon Software nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Contacting the author: + * You can get in touch with me, Daniel Stødle (that's the Norwegian letter oe, + * in case your text editor didn't realize), here: <daniels@cs.uit.no> + * + * The official ptunnel website is here: + * <http://www.cs.uit.no/~daniels/PingTunnel/> + * + * Note that the source code is best viewed with tabs set to 4 spaces. + */ + #ifndef UTILS_H #define UTILS_H 1 diff --git a/web/._index.html b/web/._index.html Binary files differdeleted file mode 100755 index 79a7755..0000000 --- a/web/._index.html +++ /dev/null diff --git a/web/._setup.png b/web/._setup.png Binary files differdeleted file mode 100755 index 0ddac7c..0000000 --- a/web/._setup.png +++ /dev/null |