pingtunnel

package module
v0.0.0-...-ed1063b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 27 Imported by: 2

README

Pingtunnel

Go Report Card

Pingtunnel is a tool that send TCP/UDP traffic over ICMP.

Note: This tool is only to be used for study and research, do not use it for illegal purposes

image

Usage

Install server
  • First prepare a server with a public IP, such as EC2 on AWS, assuming the domain name or public IP is www.yourserver.com
  • Download the corresponding installation package from releases, such as pingtunnel_linux64.zip, then decompress and execute with root privileges
  • “-key” parameter is int type, only supports numbers between 0-2147483647
sudo wget (link of latest release)
sudo unzip pingtunnel_linux64.zip
sudo ./pingtunnel -type server
  • (Optional) Disable system default ping
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
Install the client
  • Download the corresponding installation package from releases, such as pingtunnel_windows64.zip, and decompress it
  • Then run with administrator privileges. The commands corresponding to different forwarding functions are as follows.
  • If you see a log of ping pong, the connection is normal
  • “-key” parameter is int type, only supports numbers between 0-2147483647
Forward sock5
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
Use Docker

It can also be started directly with docker, which is more convenient. Same parameters as above

  • server:
docker run --name pingtunnel-server -d --privileged --network host --restart=always esrrhs/pingtunnel ./pingtunnel -type server -key 123456
  • client:
docker run --name pingtunnel-client -d --restart=always -p 1080:1080 esrrhs/pingtunnel ./pingtunnel -type client -l :1080 -s www.yourserver.com -sock5 1 -key 123456

Thanks for free JetBrains Open Source license

Documentation

Index

Constants

View Source
const (
	SEND_PROTO int = 8
	RECV_PROTO int = 0
)
View Source
const (
	FRAME_MAX_SIZE int = 888
	FRAME_MAX_ID   int = 1000000
)

Variables

View Source
var (
	MyMsg_TYPE_name = map[int32]string{
		0:     "DATA",
		1:     "PING",
		2:     "KICK",
		57005: "MAGIC",
	}
	MyMsg_TYPE_value = map[string]int32{
		"DATA":  0,
		"PING":  1,
		"KICK":  2,
		"MAGIC": 57005,
	}
)

Enum value maps for MyMsg_TYPE.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(addr string, server string, target string, timeout int, key int, icmpAddr string,
	tcpmode int, tcpmode_buffersize int, tcpmode_maxwin int, tcpmode_resend_timems int, tcpmode_compress int,
	tcpmode_stat int, open_sock5 int, maxconn int, sock5_filter *func(addr string) bool, cryptoConfig *CryptoConfig) (*Client, error)

func (*Client) Accept

func (p *Client) Accept() error

func (*Client) AcceptDirectTcpConn

func (p *Client) AcceptDirectTcpConn(conn *net.TCPConn, targetAddr string)

func (*Client) AcceptSock5Conn

func (p *Client) AcceptSock5Conn(conn *net.TCPConn)

func (*Client) AcceptTcp

func (p *Client) AcceptTcp() error

func (*Client) AcceptTcpConn

func (p *Client) AcceptTcpConn(conn *net.TCPConn, targetAddr string)

func (*Client) Addr

func (p *Client) Addr() string

func (*Client) ICMPAddr

func (p *Client) ICMPAddr() string

func (*Client) IPAddr

func (p *Client) IPAddr() *net.UDPAddr

func (*Client) LocalAddrToConnMapSize

func (p *Client) LocalAddrToConnMapSize() int

func (*Client) LocalIdToConnMapSize

func (p *Client) LocalIdToConnMapSize() int

func (*Client) RTT

func (p *Client) RTT() time.Duration

func (*Client) RecvPacket

func (p *Client) RecvPacket() uint64

func (*Client) RecvPacketSize

func (p *Client) RecvPacketSize() uint64

func (*Client) Run

func (p *Client) Run() error

func (*Client) SendPacket

func (p *Client) SendPacket() uint64

func (*Client) SendPacketSize

func (p *Client) SendPacketSize() uint64

func (*Client) ServerAddr

func (p *Client) ServerAddr() string

func (*Client) ServerIPAddr

func (p *Client) ServerIPAddr() *net.IPAddr

func (*Client) Stop

func (p *Client) Stop()

func (*Client) TargetAddr

func (p *Client) TargetAddr() string

type ClientConn

type ClientConn struct {
	// contains filtered or unexported fields
}

type CryptoConfig

type CryptoConfig struct {
	Mode   EncryptionMode
	Key    []byte
	Cipher cipher.AEAD
}

CryptoConfig holds encryption configuration

func NewCryptoConfig

func NewCryptoConfig(mode EncryptionMode, keyInput string) (*CryptoConfig, error)

NewCryptoConfig creates a new crypto configuration

func (*CryptoConfig) Decrypt

func (c *CryptoConfig) Decrypt(data []byte) ([]byte, error)

Decrypt decrypts the given data

func (*CryptoConfig) Encrypt

func (c *CryptoConfig) Encrypt(data []byte) ([]byte, error)

Encrypt encrypts the given data

type EncryptionMode

type EncryptionMode int

EncryptionMode represents the encryption mode

const (
	NoEncryption EncryptionMode = iota
	AES128
	AES256
	CHACHA20
)

func ParseEncryptionMode

func ParseEncryptionMode(s string) (EncryptionMode, error)

ParseEncryptionMode parses a string into an EncryptionMode

func (EncryptionMode) String

func (m EncryptionMode) String() string

String returns a string representation of the encryption mode

type MyMsg

type MyMsg struct {
	Id                  string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Type                int32  `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"`
	Target              string `protobuf:"bytes,3,opt,name=target,proto3" json:"target,omitempty"`
	Data                []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
	Rproto              int32  `protobuf:"zigzag32,5,opt,name=rproto,proto3" json:"rproto,omitempty"`
	Magic               int32  `protobuf:"zigzag32,6,opt,name=magic,proto3" json:"magic,omitempty"`
	Key                 int32  `protobuf:"zigzag32,7,opt,name=key,proto3" json:"key,omitempty"`
	Timeout             int32  `protobuf:"varint,8,opt,name=timeout,proto3" json:"timeout,omitempty"`
	Tcpmode             int32  `protobuf:"varint,9,opt,name=tcpmode,proto3" json:"tcpmode,omitempty"`
	TcpmodeBuffersize   int32  `protobuf:"varint,10,opt,name=tcpmode_buffersize,json=tcpmodeBuffersize,proto3" json:"tcpmode_buffersize,omitempty"`
	TcpmodeMaxwin       int32  `protobuf:"varint,11,opt,name=tcpmode_maxwin,json=tcpmodeMaxwin,proto3" json:"tcpmode_maxwin,omitempty"`
	TcpmodeResendTimems int32  `protobuf:"varint,12,opt,name=tcpmode_resend_timems,json=tcpmodeResendTimems,proto3" json:"tcpmode_resend_timems,omitempty"`
	TcpmodeCompress     int32  `protobuf:"varint,13,opt,name=tcpmode_compress,json=tcpmodeCompress,proto3" json:"tcpmode_compress,omitempty"`
	TcpmodeStat         int32  `protobuf:"varint,14,opt,name=tcpmode_stat,json=tcpmodeStat,proto3" json:"tcpmode_stat,omitempty"`
	// contains filtered or unexported fields
}

func (*MyMsg) Descriptor deprecated

func (*MyMsg) Descriptor() ([]byte, []int)

Deprecated: Use MyMsg.ProtoReflect.Descriptor instead.

func (*MyMsg) GetData

func (x *MyMsg) GetData() []byte

func (*MyMsg) GetId

func (x *MyMsg) GetId() string

func (*MyMsg) GetKey

func (x *MyMsg) GetKey() int32

func (*MyMsg) GetMagic

func (x *MyMsg) GetMagic() int32

func (*MyMsg) GetRproto

func (x *MyMsg) GetRproto() int32

func (*MyMsg) GetTarget

func (x *MyMsg) GetTarget() string

func (*MyMsg) GetTcpmode

func (x *MyMsg) GetTcpmode() int32

func (*MyMsg) GetTcpmodeBuffersize

func (x *MyMsg) GetTcpmodeBuffersize() int32

func (*MyMsg) GetTcpmodeCompress

func (x *MyMsg) GetTcpmodeCompress() int32

func (*MyMsg) GetTcpmodeMaxwin

func (x *MyMsg) GetTcpmodeMaxwin() int32

func (*MyMsg) GetTcpmodeResendTimems

func (x *MyMsg) GetTcpmodeResendTimems() int32

func (*MyMsg) GetTcpmodeStat

func (x *MyMsg) GetTcpmodeStat() int32

func (*MyMsg) GetTimeout

func (x *MyMsg) GetTimeout() int32

func (*MyMsg) GetType

func (x *MyMsg) GetType() int32

func (*MyMsg) ProtoMessage

func (*MyMsg) ProtoMessage()

func (*MyMsg) ProtoReflect

func (x *MyMsg) ProtoReflect() protoreflect.Message

func (*MyMsg) Reset

func (x *MyMsg) Reset()

func (*MyMsg) String

func (x *MyMsg) String() string

type MyMsg_TYPE

type MyMsg_TYPE int32
const (
	MyMsg_DATA  MyMsg_TYPE = 0
	MyMsg_PING  MyMsg_TYPE = 1
	MyMsg_KICK  MyMsg_TYPE = 2
	MyMsg_MAGIC MyMsg_TYPE = 57005
)

func (MyMsg_TYPE) Descriptor

func (MyMsg_TYPE) Descriptor() protoreflect.EnumDescriptor

func (MyMsg_TYPE) Enum

func (x MyMsg_TYPE) Enum() *MyMsg_TYPE

func (MyMsg_TYPE) EnumDescriptor deprecated

func (MyMsg_TYPE) EnumDescriptor() ([]byte, []int)

Deprecated: Use MyMsg_TYPE.Descriptor instead.

func (MyMsg_TYPE) Number

func (x MyMsg_TYPE) Number() protoreflect.EnumNumber

func (MyMsg_TYPE) String

func (x MyMsg_TYPE) String() string

func (MyMsg_TYPE) Type

type Packet

type Packet struct {
	// contains filtered or unexported fields
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(icmpAddr string, key int, maxconn int, maxprocessthread int, maxprocessbuffer int, connecttmeout int, cryptoConfig *CryptoConfig) (*Server, error)

func (*Server) Recv

func (p *Server) Recv(conn *ServerConn, id string, src *net.IPAddr)

func (*Server) RecvTCP

func (p *Server) RecvTCP(conn *ServerConn, id string, src *net.IPAddr)

func (*Server) Run

func (p *Server) Run() error

func (*Server) Stop

func (p *Server) Stop()

type ServerConn

type ServerConn struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL