Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
T
tls-forward
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangmingming
tls-forward
Commits
0cb8b154
Commit
0cb8b154
authored
Dec 08, 2023
by
wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
111
parent
c24cbc73
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
266 additions
and
2 deletions
+266
-2
test.go
test.go
+153
-0
client.go
tls/client.go
+113
-2
No files found.
test.go
0 → 100644
View file @
0cb8b154
package
main
import
(
"fmt"
"github.com/bogdanfinn/fhttp/http2"
tls_client
"github.com/bogdanfinn/tls-client"
"github.com/bogdanfinn/tls-client/profiles"
tls
"github.com/bogdanfinn/utls"
"io"
)
// var Chrome_117 = profiles.ClientProfile{
// clientHelloId: ,
// settings: ,
// settingsOrder: ,
// pseudoHeaderOrder: ,
// connectionFlow: 15663105,
// }
func
main
()
{
clientHello
:=
tls
.
ClientHelloID
{
Client
:
"Chrome"
,
RandomExtensionOrder
:
false
,
Version
:
"117"
,
Seed
:
nil
,
SpecFactory
:
func
()
(
tls
.
ClientHelloSpec
,
error
)
{
return
tls
.
ClientHelloSpec
{
CipherSuites
:
[]
uint16
{
tls
.
GREASE_PLACEHOLDER
,
tls
.
TLS_AES_128_GCM_SHA256
,
tls
.
TLS_AES_256_GCM_SHA384
,
tls
.
TLS_CHACHA20_POLY1305_SHA256
,
tls
.
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
,
tls
.
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
,
tls
.
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
,
tls
.
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
,
tls
.
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
tls
.
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
tls
.
TLS_RSA_WITH_AES_128_GCM_SHA256
,
tls
.
TLS_RSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_RSA_WITH_AES_128_CBC_SHA
,
tls
.
TLS_RSA_WITH_AES_256_CBC_SHA
,
},
CompressionMethods
:
[]
uint8
{
tls
.
CompressionNone
,
},
Extensions
:
[]
tls
.
TLSExtension
{
&
tls
.
UtlsGREASEExtension
{},
&
tls
.
SNIExtension
{},
&
tls
.
StatusRequestExtension
{},
// 5
&
tls
.
SupportedCurvesExtension
{[]
tls
.
CurveID
{
// 10
tls
.
CurveID
(
tls
.
GREASE_PLACEHOLDER
),
tls
.
X25519
,
tls
.
CurveP256
,
tls
.
CurveP384
,
}},
&
tls
.
SupportedPointsExtension
{
SupportedPoints
:
[]
byte
{
// 11
tls
.
PointFormatUncompressed
,
}},
&
tls
.
ALPNExtension
{
AlpnProtocols
:
[]
string
{
"h2"
,
"http/1.1"
}},
// 16
&
tls
.
StatusRequestV2Extension
{},
//17
&
tls
.
UtlsExtendedMasterSecretExtension
{},
//23
&
tls
.
SessionTicketExtension
{},
//35
&
tls
.
SignatureAlgorithmsExtension
{
SupportedSignatureAlgorithms
:
[]
tls
.
SignatureScheme
{
//13
tls
.
ECDSAWithP256AndSHA256
,
tls
.
PSSWithSHA256
,
tls
.
PKCS1WithSHA256
,
tls
.
ECDSAWithP384AndSHA384
,
tls
.
PSSWithSHA384
,
tls
.
PKCS1WithSHA384
,
tls
.
PSSWithSHA512
,
tls
.
PKCS1WithSHA512
,
}},
&
tls
.
SupportedVersionsExtension
{[]
uint16
{
//43
tls
.
GREASE_PLACEHOLDER
,
tls
.
VersionTLS13
,
tls
.
VersionTLS12
,
}},
&
tls
.
PSKKeyExchangeModesExtension
{[]
uint8
{
// 45
tls
.
PskModeDHE
,
}},
&
tls
.
SignatureAlgorithmsCertExtension
{
SupportedSignatureAlgorithms
:
[]
tls
.
SignatureScheme
{
tls
.
PKCS1WithSHA256
}},
// 50
&
tls
.
KeyShareExtension
{[]
tls
.
KeyShare
{
//51
{
Group
:
tls
.
CurveID
(
tls
.
GREASE_PLACEHOLDER
),
Data
:
[]
byte
{
0
}},
{
Group
:
tls
.
X25519
},
}},
&
tls
.
RenegotiationInfoExtension
{
Renegotiation
:
tls
.
RenegotiateOnceAsClient
},
// 65281
//&tls.PreSharedKeyExtension{},
//
//&tls.ALPSExtension{SupportedProtocols: []string{"h2"}}, // 17513
//
//&tls.UtlsCompressCertExtension{[]tls.CertCompressionAlgo{ //27
// tls.CertCompressionBrotli,
//}},
//&tls.SCTExtension{}, // 18
//
//&tls.UtlsGREASEExtension{},
//&tls.UtlsPaddingExtension{GetPaddingLen: tls.BoringPaddingStyle}, // 21
},
},
nil
},
}
h2Settings
:=
map
[
http2
.
SettingID
]
uint32
{
http2
.
SettingHeaderTableSize
:
65536
,
http2
.
SettingEnablePush
:
0
,
http2
.
SettingInitialWindowSize
:
6291456
,
http2
.
SettingMaxHeaderListSize
:
262144
,
}
h2SettingIds
:=
[]
http2
.
SettingID
{
http2
.
SettingHeaderTableSize
,
http2
.
SettingEnablePush
,
http2
.
SettingInitialWindowSize
,
http2
.
SettingMaxHeaderListSize
,
}
h2Order
:=
[]
string
{
":method"
,
":authority"
,
":scheme"
,
":path"
,
}
Chrome
:=
profiles
.
NewClientProfile
(
clientHello
,
h2Settings
,
h2SettingIds
,
h2Order
,
15663105
,
nil
,
nil
)
url
:=
"https://tls.peet.ws/api/all"
jar
:=
tls_client
.
NewCookieJar
()
options
:=
[]
tls_client
.
HttpClientOption
{
tls_client
.
WithClientProfile
(
Chrome
),
//tls_client.WithForceHttp1(),
tls_client
.
WithCookieJar
(
jar
),
//tls_client.WithRandomTLSExtensionOrder(),
//tls_client.WithProxyUrl("http://user:pass@host:port"),
tls_client
.
WithInsecureSkipVerify
(),
}
logger
:=
tls_client
.
NewNoopLogger
()
client
,
err
:=
tls_client
.
NewHttpClient
(
logger
,
options
...
)
if
err
!=
nil
{
panic
(
client
)
}
get
,
err
:=
client
.
Get
(
url
)
if
err
!=
nil
{
return
}
defer
get
.
Body
.
Close
()
all
,
err
:=
io
.
ReadAll
(
get
.
Body
)
if
err
!=
nil
{
return
}
fmt
.
Print
(
string
(
all
))
}
tls/client.go
View file @
0cb8b154
...
@@ -9,8 +9,10 @@ import (
...
@@ -9,8 +9,10 @@ import (
"errors"
"errors"
"github.com/andybalholm/brotli"
"github.com/andybalholm/brotli"
http
"github.com/bogdanfinn/fhttp"
http
"github.com/bogdanfinn/fhttp"
"github.com/bogdanfinn/fhttp/http2"
tls_client
"github.com/bogdanfinn/tls-client"
tls_client
"github.com/bogdanfinn/tls-client"
"github.com/bogdanfinn/tls-client/profiles"
"github.com/bogdanfinn/tls-client/profiles"
tls
"github.com/bogdanfinn/utls"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"io/ioutil"
"io/ioutil"
"math/big"
"math/big"
...
@@ -128,8 +130,8 @@ var chromes = []profiles.ClientProfile{
...
@@ -128,8 +130,8 @@ var chromes = []profiles.ClientProfile{
//profiles.Chrome_107,
//profiles.Chrome_107,
//profiles.Chrome_108,
//profiles.Chrome_108,
profiles
.
Chrome_117
,
profiles
.
Chrome_117
,
//
tls_client
.Safari_15_6_1,
//
profiles
.Safari_15_6_1,
//
tls_client
.Safari_16_0,
//
profiles
.Safari_16_0,
//tls_client.Safari_Ipad_15_6,
//tls_client.Safari_Ipad_15_6,
}
}
...
@@ -143,6 +145,115 @@ func NewClient(forWard ForwardItem, ios bool) (Client, error) {
...
@@ -143,6 +145,115 @@ func NewClient(forWard ForwardItem, ios bool) (Client, error) {
if
ios
{
if
ios
{
tlsVersion
=
profiles
.
Safari_IOS_16_0
tlsVersion
=
profiles
.
Safari_IOS_16_0
}
}
clientHello
:=
tls
.
ClientHelloID
{
Client
:
"Chrome"
,
RandomExtensionOrder
:
false
,
Version
:
"117"
,
Seed
:
nil
,
SpecFactory
:
func
()
(
tls
.
ClientHelloSpec
,
error
)
{
return
tls
.
ClientHelloSpec
{
CipherSuites
:
[]
uint16
{
tls
.
GREASE_PLACEHOLDER
,
tls
.
TLS_AES_128_GCM_SHA256
,
tls
.
TLS_AES_256_GCM_SHA384
,
tls
.
TLS_CHACHA20_POLY1305_SHA256
,
tls
.
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
,
tls
.
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
,
tls
.
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
,
tls
.
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
,
tls
.
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
tls
.
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
tls
.
TLS_RSA_WITH_AES_128_GCM_SHA256
,
tls
.
TLS_RSA_WITH_AES_256_GCM_SHA384
,
tls
.
TLS_RSA_WITH_AES_128_CBC_SHA
,
tls
.
TLS_RSA_WITH_AES_256_CBC_SHA
,
},
CompressionMethods
:
[]
uint8
{
tls
.
CompressionNone
,
},
Extensions
:
[]
tls
.
TLSExtension
{
&
tls
.
UtlsGREASEExtension
{},
&
tls
.
SNIExtension
{},
&
tls
.
StatusRequestExtension
{},
// 5
&
tls
.
SupportedCurvesExtension
{[]
tls
.
CurveID
{
// 10
tls
.
CurveID
(
tls
.
GREASE_PLACEHOLDER
),
tls
.
X25519
,
tls
.
CurveP256
,
tls
.
CurveP384
,
}},
&
tls
.
SupportedPointsExtension
{
SupportedPoints
:
[]
byte
{
// 11
tls
.
PointFormatUncompressed
,
}},
&
tls
.
ALPNExtension
{
AlpnProtocols
:
[]
string
{
"h2"
,
"http/1.1"
}},
// 16
&
tls
.
StatusRequestV2Extension
{},
//17
&
tls
.
UtlsExtendedMasterSecretExtension
{},
//23
&
tls
.
SessionTicketExtension
{},
//35
&
tls
.
SignatureAlgorithmsExtension
{
SupportedSignatureAlgorithms
:
[]
tls
.
SignatureScheme
{
//13
tls
.
ECDSAWithP256AndSHA256
,
tls
.
PSSWithSHA256
,
tls
.
PKCS1WithSHA256
,
tls
.
ECDSAWithP384AndSHA384
,
tls
.
PSSWithSHA384
,
tls
.
PKCS1WithSHA384
,
tls
.
PSSWithSHA512
,
tls
.
PKCS1WithSHA512
,
}},
&
tls
.
SupportedVersionsExtension
{[]
uint16
{
//43
tls
.
GREASE_PLACEHOLDER
,
tls
.
VersionTLS13
,
tls
.
VersionTLS12
,
}},
&
tls
.
PSKKeyExchangeModesExtension
{[]
uint8
{
// 45
tls
.
PskModeDHE
,
}},
&
tls
.
SignatureAlgorithmsCertExtension
{
SupportedSignatureAlgorithms
:
[]
tls
.
SignatureScheme
{
tls
.
PKCS1WithSHA256
}},
// 50
&
tls
.
KeyShareExtension
{[]
tls
.
KeyShare
{
//51
{
Group
:
tls
.
CurveID
(
tls
.
GREASE_PLACEHOLDER
),
Data
:
[]
byte
{
0
}},
{
Group
:
tls
.
X25519
},
}},
&
tls
.
RenegotiationInfoExtension
{
Renegotiation
:
tls
.
RenegotiateOnceAsClient
},
// 65281
//&tls.PreSharedKeyExtension{},
//
//&tls.ALPSExtension{SupportedProtocols: []string{"h2"}}, // 17513
//
//&tls.UtlsCompressCertExtension{[]tls.CertCompressionAlgo{ //27
// tls.CertCompressionBrotli,
//}},
//&tls.SCTExtension{}, // 18
//
//&tls.UtlsGREASEExtension{},
//&tls.UtlsPaddingExtension{GetPaddingLen: tls.BoringPaddingStyle}, // 21
},
},
nil
},
}
h2Settings
:=
map
[
http2
.
SettingID
]
uint32
{
http2
.
SettingHeaderTableSize
:
65536
,
http2
.
SettingEnablePush
:
0
,
http2
.
SettingInitialWindowSize
:
6291456
,
http2
.
SettingMaxHeaderListSize
:
262144
,
}
h2SettingIds
:=
[]
http2
.
SettingID
{
http2
.
SettingHeaderTableSize
,
http2
.
SettingEnablePush
,
http2
.
SettingInitialWindowSize
,
http2
.
SettingMaxHeaderListSize
,
}
h2Order
:=
[]
string
{
":method"
,
":authority"
,
":scheme"
,
":path"
,
}
Chrome
:=
profiles
.
NewClientProfile
(
clientHello
,
h2Settings
,
h2SettingIds
,
h2Order
,
15663105
,
nil
,
nil
)
tlsVersion
=
Chrome
options
:=
[]
tls_client
.
HttpClientOption
{
options
:=
[]
tls_client
.
HttpClientOption
{
tls_client
.
WithTimeoutSeconds
(
forWard
.
Timeout
),
tls_client
.
WithTimeoutSeconds
(
forWard
.
Timeout
),
tls_client
.
WithClientProfile
(
tlsVersion
),
tls_client
.
WithClientProfile
(
tlsVersion
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment