obfuscation

package
v0.0.0-...-fe4519f Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	EnabledMethods    []ObfuscationMethod  `json:"enabled_methods"`
	PrimaryMethod     ObfuscationMethod    `json:"primary_method"`
	FallbackMethods   []ObfuscationMethod  `json:"fallback_methods"`
	AutoDetection     bool                 `json:"auto_detection"`
	SwitchThreshold   int                  `json:"switch_threshold"`
	DetectionTimeout  time.Duration        `json:"detection_timeout"`
	RegionalProfile   string               `json:"regional_profile"`
	PacketPadding     PacketPaddingConfig  `json:"packet_padding"`
	TimingObfuscation TimingObfsConfig     `json:"timing_obfuscation"`
	TrafficPadding    TrafficPaddingConfig `json:"traffic_padding"`
	FlowWatermark     FlowWatermarkConfig  `json:"flow_watermark"`
	TLSTunnel         TLSTunnelConfig      `json:"tls_tunnel"`
	HTTPMimicry       HTTPMimicryConfig    `json:"http_mimicry"`
	DNSTunnel         DNSTunnelConfig      `json:"dns_tunnel"`
	HTTPStego         HTTPStegoConfig      `json:"http_stego"`
	XORKey            []byte               `json:"xor_key,omitempty"`
	Obfsproxy         ObfsproxyConfig      `json:"obfsproxy"`
}

Config contains configuration for the obfuscation engine

type DNSTunnel

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

DNSTunnel DNS tunneling obfuscator for emergency backup communication

func (*DNSTunnel) Deobfuscate

func (d *DNSTunnel) Deobfuscate(data []byte) ([]byte, error)

func (*DNSTunnel) GetMetrics

func (d *DNSTunnel) GetMetrics() ObfuscatorMetrics

func (*DNSTunnel) IsAvailable

func (d *DNSTunnel) IsAvailable() bool

func (*DNSTunnel) Name

func (d *DNSTunnel) Name() ObfuscationMethod

func (*DNSTunnel) Obfuscate

func (d *DNSTunnel) Obfuscate(data []byte) ([]byte, error)

func (*DNSTunnel) WrapConn

func (d *DNSTunnel) WrapConn(conn net.Conn) (net.Conn, error)

type DNSTunnelConfig

type DNSTunnelConfig struct {
	Enabled        bool          `json:"enabled"`
	DomainSuffix   string        `json:"domain_suffix"`
	DNSServers     []string      `json:"dns_servers"`
	QueryTypes     []string      `json:"query_types"`
	EncodingMethod string        `json:"encoding_method"`
	MaxPayloadSize int           `json:"max_payload_size"`
	QueryDelay     time.Duration `json:"query_delay"`
	Subdomain      string        `json:"subdomain"`
}

type DPIDetector

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

DPIDetector detects DPI blocking

func NewDPIDetector

func NewDPIDetector(timeout time.Duration, logger *log.Logger) *DPIDetector

func (*DPIDetector) ShouldSwitch

func (d *DPIDetector) ShouldSwitch(method ObfuscationMethod, err error) bool

type Engine

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

Engine main obfuscation engine

func NewEngine

func NewEngine(config *Config, logger *log.Logger) (*Engine, error)

func (*Engine) Close

func (e *Engine) Close() error

func (*Engine) DeobfuscateData

func (e *Engine) DeobfuscateData(data []byte) ([]byte, error)

func (*Engine) GetCurrentMethod

func (e *Engine) GetCurrentMethod() ObfuscationMethod

func (*Engine) GetMetrics

func (e *Engine) GetMetrics() *EngineMetrics

func (*Engine) ObfuscateData

func (e *Engine) ObfuscateData(data []byte) ([]byte, error)

func (*Engine) WrapConnection

func (e *Engine) WrapConnection(conn net.Conn) (net.Conn, error)

type EngineMetrics

type EngineMetrics struct {
	TotalPackets    int64                                    `json:"total_packets"`
	TotalBytes      int64                                    `json:"total_bytes"`
	MethodSwitches  int64                                    `json:"method_switches"`
	DetectionEvents int64                                    `json:"detection_events"`
	MethodMetrics   map[ObfuscationMethod]*ObfuscatorMetrics `json:"method_metrics"`
	StartTime       time.Time                                `json:"start_time"`
	// contains filtered or unexported fields
}

type FlowWatermark

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

FlowWatermark adds hidden watermarks to traffic flow to distort statistical characteristics

func (*FlowWatermark) Deobfuscate

func (fw *FlowWatermark) Deobfuscate(data []byte) ([]byte, error)

func (*FlowWatermark) GetMetrics

func (fw *FlowWatermark) GetMetrics() ObfuscatorMetrics

func (*FlowWatermark) IsAvailable

func (fw *FlowWatermark) IsAvailable() bool

func (*FlowWatermark) Name

func (fw *FlowWatermark) Name() ObfuscationMethod

func (*FlowWatermark) Obfuscate

func (fw *FlowWatermark) Obfuscate(data []byte) ([]byte, error)

func (*FlowWatermark) WrapConn

func (fw *FlowWatermark) WrapConn(conn net.Conn) (net.Conn, error)

type FlowWatermarkConfig

type FlowWatermarkConfig struct {
	Enabled         bool          `json:"enabled"`
	WatermarkKey    []byte        `json:"watermark_key,omitempty"`
	PatternInterval time.Duration `json:"pattern_interval"`
	PatternStrength float64       `json:"pattern_strength"`
	NoiseLevel      float64       `json:"noise_level"`
	RotationPeriod  time.Duration `json:"rotation_period"`
	StatisticalMode bool          `json:"statistical_mode"`
	FrequencyBands  []int         `json:"frequency_bands"`
}

type HTTPMimicry

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

HTTPMimicry disguises VPN traffic as legitimate HTTP requests/responses

func (*HTTPMimicry) Deobfuscate

func (h *HTTPMimicry) Deobfuscate(data []byte) ([]byte, error)

func (*HTTPMimicry) GetMetrics

func (h *HTTPMimicry) GetMetrics() ObfuscatorMetrics

func (*HTTPMimicry) IsAvailable

func (h *HTTPMimicry) IsAvailable() bool

func (*HTTPMimicry) Name

func (h *HTTPMimicry) Name() ObfuscationMethod

func (*HTTPMimicry) Obfuscate

func (h *HTTPMimicry) Obfuscate(data []byte) ([]byte, error)

func (*HTTPMimicry) WrapConn

func (h *HTTPMimicry) WrapConn(conn net.Conn) (net.Conn, error)

type HTTPMimicryConfig

type HTTPMimicryConfig struct {
	UserAgent     string            `json:"user_agent"`
	FakeHost      string            `json:"fake_host"`
	CustomHeaders map[string]string `json:"custom_headers"`
	MimicWebsite  string            `json:"mimic_website"`
}

type HTTPSteganography

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

HTTPSteganography hides VPN data within HTTP traffic using steganographic techniques

func (*HTTPSteganography) Deobfuscate

func (h *HTTPSteganography) Deobfuscate(data []byte) ([]byte, error)

func (*HTTPSteganography) GetMetrics

func (h *HTTPSteganography) GetMetrics() ObfuscatorMetrics

func (*HTTPSteganography) IsAvailable

func (h *HTTPSteganography) IsAvailable() bool

func (*HTTPSteganography) Name

func (*HTTPSteganography) Obfuscate

func (h *HTTPSteganography) Obfuscate(data []byte) ([]byte, error)

func (*HTTPSteganography) WrapConn

func (h *HTTPSteganography) WrapConn(conn net.Conn) (net.Conn, error)

type HTTPStegoConfig

type HTTPStegoConfig struct {
	Enabled        bool              `json:"enabled"`
	CoverWebsites  []string          `json:"cover_websites"`
	UserAgents     []string          `json:"user_agents"`
	ContentTypes   []string          `json:"content_types"`
	CustomHeaders  map[string]string `json:"custom_headers"`
	SteganoMethod  string            `json:"stegano_method"`
	ChunkSize      int               `json:"chunk_size"`
	ErrorRate      float64           `json:"error_rate"`
	SessionTimeout time.Duration     `json:"session_timeout"`
	EnableMIME     bool              `json:"enable_mime"`
	CachingEnabled bool              `json:"caching_enabled"`
}

type Obfsproxy

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

Obfsproxy implements obfuscation through obfsproxy

func NewObfsproxy

func NewObfsproxy(config *ObfsproxyConfig, logger *log.Logger) (*Obfsproxy, error)

NewObfsproxy creates a new instance of Obfsproxy

func (*Obfsproxy) Deobfuscate

func (o *Obfsproxy) Deobfuscate(data []byte) ([]byte, error)

Deobfuscate deobfuscates data through obfsproxy

func (*Obfsproxy) GetMetrics

func (o *Obfsproxy) GetMetrics() ObfuscatorMetrics

GetMetrics returns obfuscation metrics

func (*Obfsproxy) IsAvailable

func (o *Obfsproxy) IsAvailable() bool

IsAvailable checks if obfsproxy is available

func (*Obfsproxy) Name

func (o *Obfsproxy) Name() ObfuscationMethod

Name returns the name of the obfuscation method

func (*Obfsproxy) Obfuscate

func (o *Obfsproxy) Obfuscate(data []byte) ([]byte, error)

Obfuscate obfuscates data through obfsproxy

func (*Obfsproxy) WrapConn

func (o *Obfsproxy) WrapConn(conn net.Conn) (net.Conn, error)

WrapConn wraps a connection in obfsproxy

type ObfsproxyConfig

type ObfsproxyConfig struct {
	Enabled    bool   `json:"enabled"`
	Executable string `json:"executable"`
	Mode       string `json:"mode"`      // "client" or "server"
	Transport  string `json:"transport"` // "obfs3", "obfs4", "scramblesuit"
	Address    string `json:"address"`
	Port       int    `json:"port"`
	Options    string `json:"options"`
	LogLevel   string `json:"log_level"`
}

ObfsproxyConfig contains configuration for obfsproxy

type ObfuscationMethod

type ObfuscationMethod string

ObfuscationMethod represents the type of obfuscation method

const (
	MethodTLSTunnel      ObfuscationMethod = "tls_tunnel"
	MethodHTTPMimicry    ObfuscationMethod = "http_mimicry"
	MethodSSHMimicry     ObfuscationMethod = "ssh_mimicry"
	MethodDNSTunnel      ObfuscationMethod = "dns_tunnel"
	MethodXORCipher      ObfuscationMethod = "xor_cipher"
	MethodPacketPadding  ObfuscationMethod = "packet_padding"
	MethodTimingObfs     ObfuscationMethod = "timing_obfs"
	MethodTrafficPadding ObfuscationMethod = "traffic_padding"
	MethodFlowWatermark  ObfuscationMethod = "flow_watermark"
	MethodHTTPStego      ObfuscationMethod = "http_stego"
	MethodObfsproxy      ObfuscationMethod = "obfsproxy"
)

type Obfuscator

type Obfuscator interface {
	Name() ObfuscationMethod
	Obfuscate(data []byte) ([]byte, error)
	Deobfuscate(data []byte) ([]byte, error)
	WrapConn(conn net.Conn) (net.Conn, error)
	IsAvailable() bool
	GetMetrics() ObfuscatorMetrics
}

Obfuscator interface for all obfuscation methods

func NewDNSTunnel

func NewDNSTunnel(config *DNSTunnelConfig, logger *log.Logger) (Obfuscator, error)

func NewFlowWatermark

func NewFlowWatermark(config *FlowWatermarkConfig, logger *log.Logger) (Obfuscator, error)

func NewHTTPMimicry

func NewHTTPMimicry(config *HTTPMimicryConfig, logger *log.Logger) (Obfuscator, error)

func NewHTTPSteganography

func NewHTTPSteganography(config *HTTPStegoConfig, logger *log.Logger) (Obfuscator, error)

func NewHTTPSteganographyWithDefaults

func NewHTTPSteganographyWithDefaults(logger *log.Logger) (Obfuscator, error)

func NewPacketPadding

func NewPacketPadding(config *PacketPaddingConfig, logger *log.Logger) (Obfuscator, error)

func NewTLSTunnel

func NewTLSTunnel(config *TLSTunnelConfig, logger *log.Logger) (Obfuscator, error)

func NewTimingObfuscation

func NewTimingObfuscation(config *TimingObfsConfig, logger *log.Logger) (Obfuscator, error)

func NewTrafficPadding

func NewTrafficPadding(config *TrafficPaddingConfig, logger *log.Logger) (Obfuscator, error)

type ObfuscatorMetrics

type ObfuscatorMetrics struct {
	PacketsProcessed int64         `json:"packets_processed"`
	BytesProcessed   int64         `json:"bytes_processed"`
	Errors           int64         `json:"errors"`
	AvgProcessTime   time.Duration `json:"avg_process_time"`
	LastUsed         time.Time     `json:"last_used"`
}

ObfuscatorMetrics metrics for each obfuscator

type PacketPadding

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

PacketPadding packet size randomization obfuscator

func (*PacketPadding) Deobfuscate

func (p *PacketPadding) Deobfuscate(data []byte) ([]byte, error)

func (*PacketPadding) GetMetrics

func (p *PacketPadding) GetMetrics() ObfuscatorMetrics

func (*PacketPadding) IsAvailable

func (p *PacketPadding) IsAvailable() bool

func (*PacketPadding) Name

func (p *PacketPadding) Name() ObfuscationMethod

func (*PacketPadding) Obfuscate

func (p *PacketPadding) Obfuscate(data []byte) ([]byte, error)

func (*PacketPadding) WrapConn

func (p *PacketPadding) WrapConn(conn net.Conn) (net.Conn, error)

type PacketPaddingConfig

type PacketPaddingConfig struct {
	Enabled       bool `json:"enabled"`
	MinPadding    int  `json:"min_padding"`
	MaxPadding    int  `json:"max_padding"`
	RandomizeSize bool `json:"randomize_size"`
}

type TLSTunnel

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

TLSTunnel TLS tunneling obfuscator

func (*TLSTunnel) Deobfuscate

func (t *TLSTunnel) Deobfuscate(data []byte) ([]byte, error)

func (*TLSTunnel) GetMetrics

func (t *TLSTunnel) GetMetrics() ObfuscatorMetrics

func (*TLSTunnel) IsAvailable

func (t *TLSTunnel) IsAvailable() bool

func (*TLSTunnel) Name

func (t *TLSTunnel) Name() ObfuscationMethod

func (*TLSTunnel) Obfuscate

func (t *TLSTunnel) Obfuscate(data []byte) ([]byte, error)

func (*TLSTunnel) WrapConn

func (t *TLSTunnel) WrapConn(conn net.Conn) (net.Conn, error)

type TLSTunnelConfig

type TLSTunnelConfig struct {
	ServerName      string   `json:"server_name"`
	ALPN            []string `json:"alpn"`
	FakeHTTPHeaders bool     `json:"fake_http_headers"`
}

type TimingObfsConfig

type TimingObfsConfig struct {
	Enabled      bool          `json:"enabled"`
	MinDelay     time.Duration `json:"min_delay"`
	MaxDelay     time.Duration `json:"max_delay"`
	RandomJitter bool          `json:"random_jitter"`
}

type TimingObfuscation

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

TimingObfuscation introduces random delays between packets to obfuscate timing patterns

func (*TimingObfuscation) Deobfuscate

func (t *TimingObfuscation) Deobfuscate(data []byte) ([]byte, error)

func (*TimingObfuscation) GetMetrics

func (t *TimingObfuscation) GetMetrics() ObfuscatorMetrics

func (*TimingObfuscation) IsAvailable

func (t *TimingObfuscation) IsAvailable() bool

func (*TimingObfuscation) Name

func (*TimingObfuscation) Obfuscate

func (t *TimingObfuscation) Obfuscate(data []byte) ([]byte, error)

func (*TimingObfuscation) WrapConn

func (t *TimingObfuscation) WrapConn(conn net.Conn) (net.Conn, error)

type TrafficPadding

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

TrafficPadding adds dummy traffic between real packets to mask traffic patterns

func (*TrafficPadding) Deobfuscate

func (tp *TrafficPadding) Deobfuscate(data []byte) ([]byte, error)

func (*TrafficPadding) GetMetrics

func (tp *TrafficPadding) GetMetrics() ObfuscatorMetrics

func (*TrafficPadding) IsAvailable

func (tp *TrafficPadding) IsAvailable() bool

func (*TrafficPadding) Name

func (tp *TrafficPadding) Name() ObfuscationMethod

func (*TrafficPadding) Obfuscate

func (tp *TrafficPadding) Obfuscate(data []byte) ([]byte, error)

func (*TrafficPadding) WrapConn

func (tp *TrafficPadding) WrapConn(conn net.Conn) (net.Conn, error)

type TrafficPaddingConfig

type TrafficPaddingConfig struct {
	Enabled      bool          `json:"enabled"`
	MinInterval  time.Duration `json:"min_interval"`
	MaxInterval  time.Duration `json:"max_interval"`
	MinDummySize int           `json:"min_dummy_size"`
	MaxDummySize int           `json:"max_dummy_size"`
	BurstMode    bool          `json:"burst_mode"`
	BurstSize    int           `json:"burst_size"`
	AdaptiveMode bool          `json:"adaptive_mode"`
}

type XORCipher

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

XORCipher simple XOR obfuscator

func NewXORCipher

func NewXORCipher(key []byte, logger *log.Logger) (*XORCipher, error)

func (*XORCipher) Deobfuscate

func (x *XORCipher) Deobfuscate(data []byte) ([]byte, error)

func (*XORCipher) GetMetrics

func (x *XORCipher) GetMetrics() ObfuscatorMetrics

func (*XORCipher) IsAvailable

func (x *XORCipher) IsAvailable() bool

func (*XORCipher) Name

func (x *XORCipher) Name() ObfuscationMethod

func (*XORCipher) Obfuscate

func (x *XORCipher) Obfuscate(data []byte) ([]byte, error)

func (*XORCipher) WrapConn

func (x *XORCipher) WrapConn(conn net.Conn) (net.Conn, error)

Jump to

Keyboard shortcuts

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