phantomtcp

package
v0.0.0-...-a20358d Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: LGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OPT_NONE  = 0x0
	OPT_TTL   = 0x1 << 0
	OPT_MSS   = 0x1 << 1
	OPT_WMD5  = 0x1 << 2
	OPT_NACK  = 0x1 << 3
	OPT_WACK  = 0x1 << 4
	OPT_WCSUM = 0x1 << 5
	OPT_WSEQ  = 0x1 << 6
	OPT_WTIME = 0x1 << 7

	OPT_TFO       = 0x1 << 8
	OPT_HTFO      = 0x1 << 9
	OPT_KEEPALIVE = 0x1 << 10
	OPT_SYNX2     = 0x1 << 11

	OPT_HTTP     = 0x1 << 16
	OPT_HTTPS    = 0x1 << 17
	OPT_MOVE     = 0x1 << 18
	OPT_STRIP    = 0x1 << 19
	OPT_FRONTING = 0x1 << 20
	OPT_IPV4     = 0x1 << 21
	OPT_IPV6     = 0x1 << 22
	OPT_MODE2    = 0x1 << 23
	OPT_DF       = 0x1 << 24
	OPT_SAT      = 0x1 << 25
	OPT_RAND     = 0x1 << 26
	OPT_SSEG     = 0x1 << 27
	OPT_1SEG     = 0x1 << 28

	OPT_PROXY = 0x1 << 31
)
View Source
const (
	SO_ORIGINAL_DST      = 80
	IP6T_SO_ORIGINAL_DST = 80
)
View Source
const OPT_MODIFY = OPT_FAKE | OPT_SSEG | OPT_TFO | OPT_HTFO | OPT_MODE2

Variables

View Source
var AAAACache sync.Map
View Source
var ACache sync.Map
View Source
var ConnInfo4 [65536]chan *ConnectionInfo
View Source
var ConnInfo6 [65536]chan *ConnectionInfo
View Source
var ConnSyn sync.Map
View Source
var ConnWait4 [65536]uint32
View Source
var ConnWait6 [65536]uint32
View Source
var DNS string = ""
View Source
var DNSMinTTL uint32 = 0
View Source
var DomainMap map[string]*PhantomServer
View Source
var Forward bool = false
View Source
var HTTPSCache sync.Map
View Source
var LogLevel = 0
View Source
var Logger *log.Logger
View Source
var MethodMap = map[string]uint32{
	"none":   OPT_NONE,
	"ttl":    OPT_TTL,
	"mss":    OPT_MSS,
	"w-md5":  OPT_WMD5,
	"n-ack":  OPT_NACK,
	"w-ack":  OPT_WACK,
	"w-csum": OPT_WCSUM,
	"w-seq":  OPT_WSEQ,
	"w-time": OPT_WTIME,

	"tfo":        OPT_TFO,
	"half-tfo":   OPT_HTFO,
	"keep-alive": OPT_KEEPALIVE,
	"synx2":      OPT_SYNX2,

	"http":     OPT_HTTP,
	"https":    OPT_HTTPS,
	"move":     OPT_MOVE,
	"strip":    OPT_STRIP,
	"fronting": OPT_FRONTING,
	"ipv4":     OPT_IPV4,
	"ipv6":     OPT_IPV6,
	"mode2":    OPT_MODE2,
	"df":       OPT_DF,
	"sat":      OPT_SAT,
	"rand":     OPT_RAND,
	"s-seg":    OPT_SSEG,
	"1-seg":    OPT_1SEG,

	"proxy": OPT_PROXY,
}
View Source
var Nose []string = []string{"phantom.socks"}
View Source
var NoseLock sync.Mutex
View Source
var SubdomainDepth = 2
View Source
var TFOCookies sync.Map
View Source
var TFOPayload [64][]byte
View Source
var TFOSynID uint8 = 0
View Source
var VirtualAddrPrefix byte = 255

Functions

func AddConn

func AddConn(synAddr string, option uint32)

func BuildLie

func BuildLie(request []byte, qtype int, id int) []byte

func BuildResponse

func BuildResponse(request []byte, qtype int, ttl uint32, ips []net.IP) []byte

func ComputeUDPChecksum

func ComputeUDPChecksum(buffer []byte) uint16

func ConnectionMonitor

func ConnectionMonitor(devices []string) bool

func DelConn

func DelConn(synAddr string)

func DevicePrint

func DevicePrint()

func DialStrip

func DialStrip(host string, fronting string) (*tls.Conn, error)

func GetAddressFromInterface

func GetAddressFromInterface(iface string, ipv6 bool) (string, error)

func GetHost

func GetHost(b []byte) (offset int, length int)

func GetLocalAddr

func GetLocalAddr(name string, ipv6 bool) (*net.TCPAddr, error)

func GetName

func GetName(buf []byte, offset int) (string, int)

func GetNameOffset

func GetNameOffset(response []byte, offset int) int

func GetOriginalDST

func GetOriginalDST(conn *net.TCPConn) (*net.TCPAddr, error)

func GetPAC

func GetPAC(address string) string

func GetQName

func GetQName(buf []byte) (string, int, int)

func GetSNI

func GetSNI(b []byte) (offset int, length int)

func HTTPSlookup

func HTTPSlookup(request []byte, u *url.URL, host string) ([]byte, error)

func HttpMove

func HttpMove(conn net.Conn, host string, b []byte) bool

func Init

func Init()

func IsAddressInUse

func IsAddressInUse(err error) bool

func IsIPv6

func IsIPv6(addr string) bool

func IsNormalError

func IsNormalError(err error) bool

func ListenUDP

func ListenUDP(address string) (*net.UDPConn, error)

func LoadConfig

func LoadConfig(filename string) error

func LoadHosts

func LoadHosts(filename string) error

func ModifyAndSendPacket

func ModifyAndSendPacket(connInfo *ConnectionInfo, payload []byte, method uint32, ttl uint8, count int) error

func NSLookup

func NSLookup(name string, option uint32, server string) (int, []net.IP)

func NSRequest

func NSRequest(request []byte, cache bool) []byte

func PackQName

func PackQName(name string) []byte

func PackRequest

func PackRequest(name string, qtype uint16, id uint16, ecs string) []byte

func ReadAtLeast

func ReadAtLeast()

func Redirect

func Redirect(dst string, to_port int, forward bool)

func RedirectDNS

func RedirectDNS()

func RedirectProxy

func RedirectProxy(client net.Conn)

func SNIProxy

func SNIProxy(client net.Conn)

func SocksProxy

func SocksProxy(client net.Conn)

func StoreDNSCache

func StoreDNSCache(qname string, qtype uint16, answer DomainIP)

func TCPMapping

func TCPMapping(Address string, Hosts string) error

func TCPlookup

func TCPlookup(request []byte, address string, server *PhantomServer) ([]byte, error)

func TCPlookupDNS64

func TCPlookupDNS64(request []byte, address string, offset int, prefix []byte) ([]byte, error)

func TFOlookup

func TFOlookup(request []byte, address string) ([]byte, error)

func TLSlookup

func TLSlookup(request []byte, address string) ([]byte, error)

func UDPMapping

func UDPMapping(Address, Host string) error

func UDPMonitor

func UDPMonitor(devices []string) bool

func UDPlookup

func UDPlookup(request []byte, address string) ([]byte, error)

Types

type ConnectionInfo

type ConnectionInfo struct {
	Link gopacket.LinkLayer
	IP   gopacket.NetworkLayer
	TCP  layers.TCP
}

func DialConnInfo

func DialConnInfo(laddr, raddr *net.TCPAddr, server *PhantomServer, payload []byte) (net.Conn, *ConnectionInfo, error)

type DomainIP

type DomainIP struct {
	Index     int
	TTL       int64
	Addresses []net.IP
}

func LoadDNSCache

func LoadDNSCache(qname string, qtype uint16) (DomainIP, bool)

type PhantomServer

type PhantomServer struct {
	Option uint32
	TTL    byte
	MAXTTL byte
	MSS    uint16
	Server string
	Device string
}

func ConfigLookup

func ConfigLookup(name string) (PhantomServer, bool)

func GetConfig

func GetConfig(name string) (PhantomServer, bool)

func (*PhantomServer) Dial

func (server *PhantomServer) Dial(addresses []net.IP, port int, b []byte) (net.Conn, error)

func (*PhantomServer) DialProxy

func (server *PhantomServer) DialProxy(address string, header []byte) (net.Conn, error)

func (*PhantomServer) HTTP

func (server *PhantomServer) HTTP(client net.Conn, addresses []net.IP, port int, b []byte) (net.Conn, error)

type ServerOptions

type ServerOptions struct {
	ECS  string
	Type string
	PD   string
	Host string
}

func ParseOptions

func ParseOptions(options string) ServerOptions

type SynInfo

type SynInfo struct {
	Number uint32
	Option uint32
}

Jump to

Keyboard shortcuts

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