Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make response work with utls #7

Closed
3052 opened this issue Aug 31, 2024 · 3 comments
Closed

make response work with utls #7

3052 opened this issue Aug 31, 2024 · 3 comments

Comments

@3052
Copy link

3052 commented Aug 31, 2024

currently the response from https://tlshello.agwa.name cannot be used with uTLS. with this:

https://pkg.go.dev/github.com/refraction-networking/utls#ClientHelloSpec.FromRaw

it fails because The data should be the full tls record, including the record type/version/length header as well as the handshake type/length/version header

and with these:

https://pkg.go.dev/github.com/refraction-networking/utls#ClientHelloSpec.ImportTLSClientHello
https://pkg.go.dev/github.com/refraction-networking/utls#ClientHelloSpec.ImportTLSClientHelloFromJSON

it fails because the response is a different format

@AGWA
Copy link
Owner

AGWA commented Aug 31, 2024

The raw field contains a Handshake message. I'm not going to change that, but it would be trivial for you to prepend the necessary header to turn it into the TLSPlaintext message expected by the utls package.

@AGWA AGWA closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2024
@3052
Copy link
Author

3052 commented Aug 31, 2024

this seems to fix it:

package tlshacks

func prepend(raw []byte) []byte {
   var data []byte
   data = append(data, 22) // record type
   data = append(data, 0, 0) // record version
   data = append(data, 0, 0) // record length
   return append(data, raw...)
}

@3052
Copy link
Author

3052 commented Aug 31, 2024

for another workaround, you can use this with MITM Proxy:

import mitmproxy
import logging
import base64

def tls_clienthello(data: mitmproxy.tls.ClientHelloData):
   hello = data.client_hello.raw_bytes()
   logging.info(base64.b64encode(hello))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants