Refactored version of

Toni Uhlig 3556572668 libsodium support for asymmetric crypto (using mud) 2 years ago
contrib 4f11b7b6a0 added systemd conf/service file 3 years ago
debian 96bae72483 debian/rules: package systemd files 3 years ago
selinux f62bbc8257 updated selinux policy file and added compile script 3 years ago
src 3556572668 libsodium support for asymmetric crypto (using mud) 1 year ago
test 4a3636d068 ignore incomplete packets instead of exit(0), only allow packet queueing if state allows it 2 years ago
web 7f3f14fb0a removed CVS leftover.. 5 years ago
.clang-format fe14d74de4 initial clang-format file 2 years ago
.dockerignore 2995606f4d docker 2 years ago
.gitlab-ci.yml a54f0345f4 fixed archlinux ci build 2 years ago
.travis.yml 03d894452b travis-ci: do not spam me with config.log 2 years ago
AUTHORS da8d892491 updated AUTHORS (masaq-, elnerd) 3 years ago
COPYING d9d7a33d2e copyright update 3 years ago
ChangeLog 1d0cbc46e8 1.42-release 3 years ago
Dockerfile 60de9d5caa use tini init 2 years ago 3c491a8bec ptunnel-ng: 5 years ago
NEWS 3c491a8bec ptunnel-ng: 5 years ago
PKGBUILD 76afa73321 ArchLinux PKGBUILD md5 chksm update 3 years ago fa14c8d99a added PKGBUILD dev version (builds from git-master), both 3 years ago
README 3d8dc5110c README's provide some simple ptunnel-ng usage examples (fixes #21) 2 years ago 3d8dc5110c README's provide some simple ptunnel-ng usage examples (fixes #21) 2 years ago 9922993eb2 can now be executed from any current working directory 2 years ago 70bcc46b82 enable ASAN, LSAN and UBSAN 3 years ago
model_file.c 092a71c228 added coverity model file 4 years ago


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.

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.

Simple usage
Opens a SSH over ICMP tunnel to a remote.

sudo ptunnel-ng

sudo ptunnel-ng -p[Server-IP/NAME] -l2222
ssh -p2222 -luser

Restricted usage
Opens a SSH over ICMP tunnel to a remote but restricts destination IP/Port for tunnel clients. is the machine your SSH daemon listens on. This can be a virtual machine, container or (.*).

sudo ptunnel-ng -r10.0.3.1 -R22

sudo ptunnel-ng -p[Server-IP/NAME] -l2222 -r10.0.3.1 -R22
ssh -p2222 -luser

Reverse shell usage
Opens a SSH over ICMP tunnel to a remote and creates a reverse tunnel on same
but restricts destination IP/Port for tunnel clients. is the machine your SSH daemon listens on. This can be a virtual machine, container or (.*).

sudo ptunnel-ng -r10.0.3.1 -R22

sudo ./src/ptunnel-ng -p[Server-IP/NAME] -l2222 -r10.0.3.1 -R22
ssh -R -p2222

ssh -p22222 -luser

Contact details
The ptunnel-ng fork was done by Toni Uhlig:

You can contact the author of ptunnel, Daniel Stoedle, here:

The official ptunnel website is located here:

Required: pthread
Optional: pcap, selinux

Either run "./" 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:

REMEMBER: ptunnel-ng might not work on Windows without WinPcap!

Ptunnel works best when starting as root, and usually requires starting as root.
Common ptunnel-ng options:

./ptunnel-ng -r -R -v
-P -u -g

./ptunnel-ng -p -l -r
-R -v
-P -u -g

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 to the computer, the following command line would be used:

sudo ./ptunnel-ng -p -l 8000 -r -R 22

An ssh connection to 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 here). Doing this is very

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

- refactoring
- libsodium integration

Credits and contributors
Daniel Stoedle et al.

Ping Tunnel NG is Copyright (c) 2017-2019, Toni Uhlig ,
All rights reserved. Ping Tunnel NG is licensed under the
BSD License. Please see the COPYING file for details.