replace cycletls with bogdanfinn/tls-client for better tls fingerprint spoofing reliability
This commit is contained in:
@@ -10,7 +10,8 @@ func MasqueradeAsGoogleBot() proxychain.RequestModification {
|
||||
const botUA string = "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; http://www.google.com/bot.html) Chrome/79.0.3945.120 Safari/537.36"
|
||||
const botIP string = "66.249.78.8" // TODO: create a random ip pool from https://developers.google.com/static/search/apis/ipranges/googlebot.json
|
||||
// https://github.com/trisulnsm/trisul-scripts/blob/master/lua/frontend_scripts/reassembly/ja3/prints/ja3fingerprint.json
|
||||
const ja3 string = "769,49195-49199-49200-49161-49171-49162-49172-156-157-47-10-53-51-57,65281-0-23-35-13-13172-11-10,29-23-24,0"
|
||||
const ja3 string = "769,49195-49199-49196-49200-52393-52392-52244-52243-49161-49171-49162-49172-156-157-47-53-10,65281-0-23-35-13-5-18-16-11-10-21,29-23-24,0"
|
||||
// "741,49195-49199-49200-49161-49171-49162-49172-156-157-47-10-53-51-57,65281-0-23-35-13-13172-11-10,29-23-24,0"
|
||||
|
||||
return masqueradeAsTrustedBot(botUA, botIP, ja3)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package requestmodifers
|
||||
|
||||
import (
|
||||
//"net/http"
|
||||
http "github.com/Danny-Dasilva/fhttp"
|
||||
//http "github.com/Danny-Dasilva/fhttp"
|
||||
http "github.com/bogdanfinn/fhttp"
|
||||
|
||||
"ladder/proxychain"
|
||||
)
|
||||
|
||||
@@ -4,9 +4,13 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
http "github.com/bogdanfinn/fhttp"
|
||||
"net"
|
||||
//"net/http"
|
||||
http "github.com/Danny-Dasilva/fhttp"
|
||||
/*
|
||||
tls_client "github.com/bogdanfinn/tls-client"
|
||||
//"net/http"
|
||||
*/
|
||||
|
||||
"time"
|
||||
|
||||
"ladder/proxychain"
|
||||
@@ -38,45 +42,53 @@ func resolveWithGoogleDoH(host string) (string, error) {
|
||||
return "", fmt.Errorf("no DoH DNS record found for %s", host)
|
||||
}
|
||||
|
||||
type CustomDialer struct {
|
||||
*net.Dialer
|
||||
}
|
||||
|
||||
func NewCustomDialer(timeout, keepAlive time.Duration) *CustomDialer {
|
||||
return &CustomDialer{
|
||||
Dialer: &net.Dialer{
|
||||
Timeout: timeout,
|
||||
KeepAlive: keepAlive,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (cd *CustomDialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
host, port, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
port = "443"
|
||||
}
|
||||
|
||||
resolvedHost, err := resolveWithGoogleDoH(host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cd.Dialer.DialContext(ctx, network, net.JoinHostPort(resolvedHost, port))
|
||||
}
|
||||
|
||||
// ResolveWithGoogleDoH modifies a ProxyChain's client to make the request by resolving the URL
|
||||
// using Google's DNS over HTTPs service
|
||||
func ResolveWithGoogleDoH() proxychain.RequestModification {
|
||||
return func(px *proxychain.ProxyChain) error {
|
||||
client := &http.Client{
|
||||
Timeout: px.Client.Timeout,
|
||||
}
|
||||
|
||||
dialer := &net.Dialer{
|
||||
Timeout: 5 * time.Second,
|
||||
KeepAlive: 5 * time.Second,
|
||||
}
|
||||
|
||||
customDialContext := func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
host, port, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
// If the addr doesn't include a port, determine it based on the URL scheme
|
||||
if px.Request.URL.Scheme == "https" {
|
||||
port = "443"
|
||||
} else {
|
||||
port = "80"
|
||||
}
|
||||
host = addr // assume the entire addr is the host
|
||||
///customDialer := NewCustomDialer(10*time.Second, 10*time.Second)
|
||||
return func(chain *proxychain.ProxyChain) error {
|
||||
/*
|
||||
options := []tls_client.HttpClientOption{
|
||||
tls_client.WithTimeoutSeconds(30),
|
||||
tls_client.WithRandomTLSExtensionOrder(),
|
||||
tls_client.WithDialer(*customDialer.Dialer),
|
||||
//tls_client.WithClientProfile(profiles.Chrome_105),
|
||||
}
|
||||
|
||||
resolvedHost, err := resolveWithGoogleDoH(host)
|
||||
client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
return dialer.DialContext(ctx, network, net.JoinHostPort(resolvedHost, port))
|
||||
}
|
||||
|
||||
patchedTransportWithDoH := &http.Transport{
|
||||
DialContext: customDialContext,
|
||||
}
|
||||
|
||||
client.Transport = patchedTransportWithDoH
|
||||
px.Client = client // Assign the modified client to the ProxyChain
|
||||
chain.SetOnceHTTPClient(client)
|
||||
*/
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package requestmodifers
|
||||
|
||||
// removed due to using a different TLS spoofing technique
|
||||
|
||||
/*
|
||||
import (
|
||||
"github.com/Danny-Dasilva/CycleTLS/cycletls"
|
||||
http "github.com/Danny-Dasilva/fhttp"
|
||||
//"github.com/Danny-Dasilva/CycleTLS/cycletls"
|
||||
//http "github.com/Danny-Dasilva/fhttp"
|
||||
//http "github.com/bogdanfinn/fhttp"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
"ladder/proxychain"
|
||||
)
|
||||
@@ -14,14 +19,14 @@ import (
|
||||
func SpoofJA3fingerprint(ja3 string, userAgent string) proxychain.RequestModification {
|
||||
//fmt.Println(ja3)
|
||||
return func(chain *proxychain.ProxyChain) error {
|
||||
// deep copy existing client while modifying http transport
|
||||
ja3SpoofClient := &http.Client{
|
||||
Transport: cycletls.NewTransport(ja3, userAgent),
|
||||
Timeout: chain.Client.Timeout,
|
||||
CheckRedirect: chain.Client.CheckRedirect,
|
||||
}
|
||||
// deep copy existing client while modifying http transport
|
||||
ja3SpoofClient := &http.Client{
|
||||
Transport: cycletls.NewTransport(ja3, userAgent),
|
||||
Timeout: chain.Client.Timeout,
|
||||
CheckRedirect: chain.Client.CheckRedirect,
|
||||
}
|
||||
|
||||
chain.SetOnceHTTPClient(ja3SpoofClient)
|
||||
chain.SetOnceHTTPClient(ja3SpoofClient)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -33,14 +38,15 @@ func SpoofJA3fingerprint(ja3 string, userAgent string) proxychain.RequestModific
|
||||
func SpoofJA3fingerprintWithProxy(ja3 string, userAgent string, proxy proxy.ContextDialer) proxychain.RequestModification {
|
||||
return func(chain *proxychain.ProxyChain) error {
|
||||
|
||||
// deep copy existing client while modifying http transport
|
||||
ja3SpoofClient := &http.Client{
|
||||
Transport: cycletls.NewTransportWithProxy(ja3, userAgent, proxy),
|
||||
Timeout: chain.Client.Timeout,
|
||||
CheckRedirect: chain.Client.CheckRedirect,
|
||||
}
|
||||
// deep copy existing client while modifying http transport
|
||||
ja3SpoofClient := &http.Client{
|
||||
Transport: cycletls.NewTransportWithProxy(ja3, userAgent, proxy),
|
||||
Timeout: chain.Client.Timeout,
|
||||
CheckRedirect: chain.Client.CheckRedirect,
|
||||
}
|
||||
|
||||
chain.SetOnceHTTPClient(ja3SpoofClient)
|
||||
chain.SetOnceHTTPClient(ja3SpoofClient)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user