项目作者: lnslbrty

项目描述 :
Tunnel TCP connections through ICMP.
高级语言: C
项目地址: git://github.com/lnslbrty/ptunnel-ng.git
创建时间: 2017-12-19T18:10:35Z
项目社区:https://github.com/lnslbrty/ptunnel-ng

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Coverity Status
Total alerts
Codacy Badge
GitHub issues
GitHub license
Gitter chat
Packaging status

PingTunnel-[N]ew[G]eneration Read Me

What is ptunnel-ng?

  1. Ptunnel-NG is a bugfixed and refactored version of Ptunnel with some additional
  2. features e.g. change the magic value without recompiling.

What is ptunnel?

  1. Ptunnel is an application that allows you to reliably tunnel TCP connections
  2. to a remote host using ICMP echo request and reply packets, commonly known as
  3. ping requests and replies.

Simple usage

Opens a SSH over ICMP tunnel to a remote.

Server:

sudo ptunnel-ng

Client:

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

ssh -p2222 -luser 127.0.0.1

Restricted usage

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

Server:

sudo ptunnel-ng -r10.0.3.1 -R22

Client:

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

ssh -p2222 -luser 127.0.0.1

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.
10.0.3.1 is the machine your SSH daemon listens on. This can be a virtual machine, container or (.*).

Server:

sudo ptunnel-ng -r10.0.3.1 -R22

Client:

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

ssh -R 127.0.0.1:22222 127.0.0.1 -p2222

Server:

ssh -p22222 -luser 127.0.0.1

How does it work?

  1. ICMP Packet structure

Ptunnel Packet Structure

  1. Ptunnel program setup

Ptunnel Setup

Contact details

  1. The ptunnel-ng fork was done by Toni Uhlig:
  2. <matzeton@googlemail.com>
  3. You can contact the author of ptunnel, Daniel Stoedle, here:
  4. <daniels@cs.uit.no>
  5. The official ptunnel website is located here:
  6. <http://www.cs.uit.no/~daniels/PingTunnel></http:>

Dependencies

  1. Required: pthread
  2. Optional: pcap, selinux

Compiling

  1. Either run "./autogen.sh" for a fully automatic build or run it manually with:
  2. "./configure && make"
  3. You should end up with a binary called ptunnel-ng.
  4. This serves as both the client and proxy. You can
  5. optionally install it using "make install".
  6. To compile the Windows binary. You will need mingw installed.
  7. If you want pcap support you will need the WinPcap library as well.
  8. WinPcap is available here:
  9. <http://www.winpcap.org/install/bin/WpdPack_4_0_2.zip>
  10. REMEMBER: ptunnel-ng might not work on Windows without WinPcap!

Running

  1. Ptunnel works best when starting as root, and usually requires starting as root.
  2. Common ptunnel-ng options:
  3. Proxy(Server):
  4. ./ptunnel-ng -r<destination address> -R<destination port> -v <loglevel>
  5. -P<password> -u<user> -g<group>
  6. Forwarder(Client):
  7. ./ptunnel-ng -p <address> -l <listen port> -r<destination address>
  8. -R<destination port> -v <loglevel>
  9. -P<password> -u<user> -g<group>
  10. The -p switch sets the address of the host on which the proxy is running. A
  11. quick test to see if the proxy will work is simply to try pinging this host -
  12. if you get replies, you should be able to make the tunnel work.
  13. If pinging works but you are not able to establish a tunnel, you should play
  14. around with the -m switch and change the magic value. A IDS/IPS or Firwall
  15. might try to fool you.
  16. The -l, -r and -R switches set the local listening port, destination address
  17. and destination port. For instance, to tunnel ssh connections from the client
  18. machine via a proxy running on proxy.pingtunnel.com to the computer
  19. login.domain.com, the following command line would be used:
  20. sudo ./ptunnel-ng -p proxy.pingtunnel.com -l 8000 -r login.domain.com -R 22
  21. An ssh connection to login.domain.com can now be established as follows:
  22. ssh -p 8000 localhost
  23. If ssh complains about potential man-in-the-middle attacks, simply remove the
  24. offending key from the known_hosts file. The warning/error is expected if you
  25. have previously ssh'd to your local computer (i.e., ssh localhost), or you have
  26. used ptunnel-ng to forward ssh connections to different hosts.
  27. Of course, for all of this to work, you need to start the proxy on your
  28. proxy-computer (we'll call it proxy.pingtunnel.com here). Doing this is very
  29. simple:
  30. sudo ./ptunnel-ng
  31. If you find that the proxy isn't working, you will need to enable packet
  32. capturing on the main network device. Currently this device is assumed to be
  33. an ethernet-device (i.e., ethernet or wireless). Packet capturing is enabled by
  34. giving the -L switch, and supplying the device name to capture packets on (for
  35. instance eth0 or en1). The same goes for the client. On versions of Mac OS X
  36. prior to 10.4 (Tiger), packet capturing must always be enabled (both for proxy
  37. and client), as resent packets won't be received otherwise.
  38. To protect yourself from others using your proxy, you can protect access to it
  39. with a password using the -P switch. The password is never sent in
  40. the clear, but keep in mind that it may be visible from tools like top or ps,
  41. which can display the command line used to start an application.
  42. Finally, the -u switch will attempt to run the proxy in unprivileged mode (i.e.,
  43. no need for root access), and the -v switch controls the amount of output from
  44. ptunnel-ng. -1 indicates no output, 0 shows errors only, 1 shows info messages, 2
  45. gives more output, 3 provides even more output, level 4 displays debug info and
  46. level 5 displays absolutely everything, including the nasty details of sends and
  47. receives. The -o switch allows output to be saved to a logfile.
  48. Security features: Please see the ptunnel-ng man-page for instructions.

Supported operating systems

  1. Ptunnel supports most operating systems with libpcap, the usual POSIX functions
  2. and a BSD sockets compatible API. In particular, it has been tested on Linux
  3. Fedora Core 2 and Mac OS X 10.3.6 and above. As of version 0.7, ptunnel-ng can also
  4. be compiled on Windows, courtesy of Mike Miller, assuming mingw and WinPcap is
  5. installed.

TODOs

  1. - refactoring
  2. - libsodium integration

Credits and contributors

  1. Daniel Stoedle et al.

License

  1. Ping Tunnel NG is Copyright (c) 2017-2019, Toni Uhlig <matzeton@googlemail.com>,
  2. All rights reserved. Ping Tunnel NG is licensed under the
  3. BSD License. Please see the COPYING file for details.