pingtunnel

repository·master·Indexed 25 days ago

https://github.com/esrrhs/pingtunnel

A tool for study and research that provides tunneling capabilities via ICMP, including support for SOCKS5, TCP, and UDP forwarding. It features Docker deployment options, encryption modes (AES128, AES256, ChaCha20), and GeoIP-based filtering for SOCKS5 traffic.

Tokens
5.1K
Snippets
10
Records
36
Agent score
86%

What's inside pingtunnel

  1. Forward traffic using the Pingtunnel client

    master

    Use the following command patterns to forward different types of traffic through the ICMP tunnel. Replace www.yourserver.com with your actual server address.

    Forward SOCKS5

    Use the -sock5 1 flag.

    Forward TCP

    Use the -t flag to specify the target destination and the -tcp 1 flag.

    Forward UDP

    Use the -t flag to specify the target destination.

    # Forward SOCKS5
    pingtunnel.exe -type client -l :4455 -s www.yourserver.com -sock5 1
    
    # Forward tcp
    pingtunnel.exe -type client -l :4455 -s www.yourserver.com -t www.yourserver.com:4455 -tcp 1
    
    # Forward udp
    pingtunnel.exe -type client -l :4455 -s www.yourserver.com -t www.yourserver.com:4455
  2. Run Pingtunnel using Docker

    master

    You can run both the server and client using Docker containers. The parameters used are the same as the binary versions.

    Server requirements: Must run with --privileged and --network host to handle ICMP traffic correctly.

  3. Deploy Pingtunnel using Docker Compose

    master

    To deploy Pingtunnel using Docker Compose, follow these steps:

    1. Configure Environment: Edit the .env file in the docker-compose/ directory with your appropriate values.
    2. Start the Server: Run the following command in the server directory:
      docker-compose -f server.yml up -d
    3. Start the Client: Run the following command on the client machine:
      docker-compose -f client.yml up -d

    Once deployed, a SOCKS5 proxy will be available on port 1080 of your client machine.

  4. Install and use the Pingtunnel client

    master

    Download the appropriate installation package from releases and decompress it. Run the client with administrator privileges.

    Successful connections are indicated by ping/pong logs in the output.

    Note on -key parameter: If used, the -key parameter must be an integer between 0 and 2147483647.

  5. Install the Pingtunnel server

    master

    To set up a Pingtunnel server, you need a machine with a public IP (e.g., AWS EC2).

    1. Download the appropriate installation package from the releases page (e.g., pingtunnel_linux64.zip).
    2. Decompress the package.
    3. Execute the binary with root privileges using the -type server flag.

    Note on -key parameter: If used, the -key parameter must be an integer between 0 and 2147483647.

    (Optional) You can disable the system default ping response by running: echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

    sudo wget (link of latest release)
    sudo unzip pingtunnel_linux64.zip
    sudo ./pingtunnel -type server
  6. Handle SOCKS5 UDP datagrams

    master

    The package provides utilities to parse and build SOCKS5 UDP datagrams for UDP association support.

    • parseSocks5UDPDatagram(packet []byte): Extracts the target address and the actual payload from a raw UDP packet.
    • buildSocks5UDPDatagram(targetAddr string, payload []byte): Encapsulates a payload into a SOCKS5-compliant UDP datagram for a specific target address.
  7. Retrieve Client Connection Metadata

    master

    The Client struct provides several methods to inspect the current state and configuration of the tunnel:

    • Addr(): Returns the local address string.
    • IPAddr(): Returns the local UDP address.
    • TargetAddr(): Returns the target destination address string.
    • ICMPAddr(): Returns the ICMP address string.
    • ServerIPAddr(): Returns the resolved server IP address.
    • ServerAddr(): Returns the server address string.
    • RTT(): Returns the current Round Trip Time.
    • RecvPacket(): Returns the total number of received packets.
    • SendPacket(): Returns the total number of sent packets.
    • RecvPacketSize(): Returns the total bytes received.
    • SendPacketSize(): Returns the total bytes sent.
    • LocalIdToConnMapSize(): Returns the number of active connections tracked by ID.
    • LocalAddrToConnMapSize(): Returns the number of active connections tracked by local address.
  8. Initialize a new Pingtunnel Server

    master
    Use NewServer to create a new instance of the Server. This function configures the ICMP listening address, security key, connection limits, and thread pool settings for processing data packets.
  9. Parse encryption mode from string

    master

    Use ParseEncryptionMode to convert a string representation into an EncryptionMode type. This is useful for processing configuration files or CLI arguments.

    Supported string values:

    • "" or "none" -> NoEncryption
    • "aes128" -> AES128
    • "aes256" -> AES256
    • "chacha20" or "chacha20-poly1305" -> CHACHA20