cycletls

package module
v0.0.0-...-713e3ed Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: GPL-3.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecompressBody

func DecompressBody(Body []byte, encoding []string, content []string) (parsedBody string)

DecompressBody unzips compressed data

func HandleRequest

func HandleRequest(client *http.Client, req *nhttp.Request) (res *nhttp.Response, err error)

func NewClient

func NewClient(browser Browser, timeout int, disableRedirect bool, UserAgent string, proxyURL ...string) (http.Client, error)

newClient creates a new http client

func NewTransport

func NewTransport(ja3 string, useragent string) http.RoundTripper

NewTransport creates a new HTTP client transport that modifies HTTPS requests to imitiate a specific JA3 hash and User-Agent. # Example Usage import (

"github.com/procoder17/CycleTLSForGoProxy/cycletls"
http "github.com/Danny-Dasilva/fhttp" // note this is a drop-in replacement for net/http

)

ja3 := "771,52393-52392-52244-52243-49195-49199-49196-49200-49171-49172-156-157-47-53-10,65281-0-23-35-13-5-18-16-30032-11-10,29-23-24,0" ua := "Chrome Version 57.0.2987.110 (64-bit) Linux"

cycleClient := &http.Client{
	Transport:     cycletls.NewTransport(ja3, ua),
}

cycleClient.Get("https://tls.peet.ws/")

func NewTransportWithProxy

func NewTransportWithProxy(ja3 string, useragent string, proxy proxy.ContextDialer) http.RoundTripper

NewTransport creates a new HTTP client transport that modifies HTTPS requests to imitiate a specific JA3 hash and User-Agent, optionally specifying a proxy via proxy.ContextDialer.

func ParseDateString

func ParseDateString(dt string) (time.Time, error)

ParseDateString takes a string and passes it through Approxidate Parses into a time.Time

func PrettyStruct

func PrettyStruct(data interface{}) (string, error)

PrettyStruct formats json

func StringToSpec

func StringToSpec(ja3 string, userAgent string, forceHTTP1 bool) (*utls.ClientHelloSpec, error)

StringToSpec creates a ClientHelloSpec based on a JA3 string

func WSEndpoint

func WSEndpoint(w nhttp.ResponseWriter, r *nhttp.Request)

WSEndpoint exports the main cycletls function as we websocket connection that clients can connect to

Types

type Browser

type Browser struct {
	// Return a greeting that embeds the name in a message.
	JA3                string
	UserAgent          string
	Cookies            []Cookie
	InsecureSkipVerify bool
	// contains filtered or unexported fields
}

type ContextKeyHeader

type ContextKeyHeader struct{}

ContextKeyHeader Users of context.WithValue should define their own types for keys

type Cookie struct {
	Name  string `json:"name"`
	Value string `json:"value"`

	Path        string `json:"path"`   // optional
	Domain      string `json:"domain"` // optional
	Expires     time.Time
	JSONExpires Time   `json:"expires"`    // optional
	RawExpires  string `json:"rawExpires"` // for reading cookies only

	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
	// MaxAge>0 means Max-Age attribute present and given in seconds
	MaxAge   int            `json:"maxAge"`
	Secure   bool           `json:"secure"`
	HTTPOnly bool           `json:"httpOnly"`
	SameSite nhttp.SameSite `json:"sameSite"`
	Raw      string
	Unparsed []string `json:"unparsed"` // Raw text of unparsed attribute-value pairs
}

A Cookie represents an HTTP cookie as sent in the Set-Cookie header of an HTTP response or the Cookie header of an HTTP request.

See https://tools.ietf.org/html/rfc6265 for details. Stolen from Net/http/cookies

type CycleTLS

type CycleTLS struct {
	ReqChan  chan fullRequest
	RespChan chan Response
}

CycleTLS creates full request and response

func Init

func Init(workers ...bool) CycleTLS

Init starts the worker pool or returns a empty cycletls struct

func (CycleTLS) Close

func (client CycleTLS) Close()

Close closes channels

func (CycleTLS) Do

func (client CycleTLS) Do(URL string, options Options, Method string) (response Response, err error)

Do creates a single request

func (CycleTLS) Queue

func (client CycleTLS) Queue(URL string, options Options, Method string)

Queue queues request in worker pool

type Extensions

type Extensions struct {
	//PKCS1WithSHA256 SignatureScheme = 0x0401
	//PKCS1WithSHA384 SignatureScheme = 0x0501
	//PKCS1WithSHA512 SignatureScheme = 0x0601
	//PSSWithSHA256 SignatureScheme = 0x0804
	//PSSWithSHA384 SignatureScheme = 0x0805
	//PSSWithSHA512 SignatureScheme = 0x0806
	//ECDSAWithP256AndSHA256 SignatureScheme = 0x0403
	//ECDSAWithP384AndSHA384 SignatureScheme = 0x0503
	//ECDSAWithP521AndSHA512 SignatureScheme = 0x0603
	//Ed25519 SignatureScheme = 0x0807
	//PKCS1WithSHA1 SignatureScheme = 0x0201
	//ECDSAWithSHA1 SignatureScheme = 0x0203
	SupportedSignatureAlgorithms []string `json:"SupportedSignatureAlgorithms"`
	//CertCompressionZlib   CertCompressionAlgo = 0x0001
	//CertCompressionBrotli CertCompressionAlgo = 0x0002
	//CertCompressionZstd   CertCompressionAlgo = 0x0003
	CertCompressionAlgo []string `json:"CertCompressionAlgo"`
	// Limit: 0x4001
	RecordSizeLimit int `json:"RecordSizeLimit"`
	//PKCS1WithSHA256 SignatureScheme = 0x0401
	//PKCS1WithSHA384 SignatureScheme = 0x0501
	//PKCS1WithSHA512 SignatureScheme = 0x0601
	//PSSWithSHA256 SignatureScheme = 0x0804
	//PSSWithSHA384 SignatureScheme = 0x0805
	//PSSWithSHA512 SignatureScheme = 0x0806
	//ECDSAWithP256AndSHA256 SignatureScheme = 0x0403
	//ECDSAWithP384AndSHA384 SignatureScheme = 0x0503
	//ECDSAWithP521AndSHA512 SignatureScheme = 0x0603
	//Ed25519 SignatureScheme = 0x0807
	//PKCS1WithSHA1 SignatureScheme = 0x0201
	//ECDSAWithSHA1 SignatureScheme = 0x0203
	DelegatedCredentials []string `json:"DelegatedCredentials"`
	//GREASE_PLACEHOLDER = 0x0a0a
	//VersionTLS10 = 0x0301
	//VersionTLS11 = 0x0302
	//VersionTLS12 = 0x0303
	//VersionTLS13 = 0x0304
	//VersionSSL30 = 0x0300
	SupportedVersions []string `json:"SupportedVersions"`
	//PskModePlain uint8 = pskModePlain
	//PskModeDHE   uint8 = pskModeDHE
	PSKKeyExchangeModes []string `json:"PSKKeyExchangeModes"`
	//PKCS1WithSHA256 SignatureScheme = 0x0401
	//PKCS1WithSHA384 SignatureScheme = 0x0501
	//PKCS1WithSHA512 SignatureScheme = 0x0601
	//PSSWithSHA256 SignatureScheme = 0x0804
	//PSSWithSHA384 SignatureScheme = 0x0805
	//PSSWithSHA512 SignatureScheme = 0x0806
	//ECDSAWithP256AndSHA256 SignatureScheme = 0x0403
	//ECDSAWithP384AndSHA384 SignatureScheme = 0x0503
	//ECDSAWithP521AndSHA512 SignatureScheme = 0x0603
	//Ed25519 SignatureScheme = 0x0807
	//PKCS1WithSHA1 SignatureScheme = 0x0201
	//ECDSAWithSHA1 SignatureScheme = 0x0203
	SignatureAlgorithmsCert []string `json:"SignatureAlgorithmsCert"`
	//GREASE_PLACEHOLDER = 0x0a0a
	//CurveP256 CurveID = 23
	//CurveP384 CurveID = 24
	//CurveP521 CurveID = 25
	//X25519    CurveID = 29
	KeyShareCurves []string `json:"KeyShareCurves"`
	//default is false, default is used grease, if not used grease the UseGREASE param is true
	UseGREASE bool `json:"UseGREASE"`
}

type Options

type Options struct {
	URL                string            `json:"url"`
	Method             string            `json:"method"`
	Headers            map[string]string `json:"headers"`
	Body               string            `json:"body"`
	Ja3                string            `json:"ja3"`
	UserAgent          string            `json:"userAgent"`
	Proxy              string            `json:"proxy"`
	Cookies            []Cookie          `json:"cookies"`
	Timeout            int               `json:"timeout"`
	DisableRedirect    bool              `json:"disableRedirect"`
	HeaderOrder        []string          `json:"headerOrder"`
	OrderAsProvided    bool              `json:"orderAsProvided"` //TODO
	InsecureSkipVerify bool              `json:"insecureSkipVerify"`
	ForceHTTP1         bool              `json:"forceHTTP1"`
}

Options sets CycleTLS client options

type Response

type Response struct {
	RequestID string
	Status    int
	Body      string
	Headers   map[string]string
	Cookies   []*nhttp.Cookie
	FinalUrl  string
}

Response contains Cycletls response data

func (Response) JSONBody

func (re Response) JSONBody() map[string]interface{}

JSONBody converts response body to json

type SocksDialer

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

func (*SocksDialer) Dial

func (d *SocksDialer) Dial(network, addr string) (net.Conn, error)

func (*SocksDialer) DialContext

func (d *SocksDialer) DialContext(_ context.Context, network, addr string) (net.Conn, error)

type TLSExtensions

type TLSExtensions struct {
	SupportedSignatureAlgorithms *utls.SignatureAlgorithmsExtension
	CertCompressionAlgo          *utls.UtlsCompressCertExtension
	RecordSizeLimit              *utls.FakeRecordSizeLimitExtension
	DelegatedCredentials         *utls.DelegatedCredentialsExtension
	SupportedVersions            *utls.SupportedVersionsExtension
	PSKKeyExchangeModes          *utls.PSKKeyExchangeModesExtension
	SignatureAlgorithmsCert      *utls.SignatureAlgorithmsCertExtension
	KeyShareCurves               *utls.KeyShareExtension
	UseGREASE                    bool
}

func ToTLSExtensions

func ToTLSExtensions(e *Extensions) (extensions *TLSExtensions)

type Time

type Time struct {
	time.Time
}

Time wraps time.Time overriddin the json marshal/unmarshal to pass timestamp as integer

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(buf []byte) error

UnmarshalJSON implements json.Unmarshaler inferface.

type UserAgent

type UserAgent struct {
	UserAgent   string
	HeaderOrder []string
}

Jump to

Keyboard shortcuts

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