-
Notifications
You must be signed in to change notification settings - Fork 2
feat: save&overwrite client hello #2
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 acco 8000 unt
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ import ( | |
"net/http" | ||
"net/url" | ||
"os" | ||
"path" | ||
"strconv" | ||
"strings" | ||
"sync" | ||
"sync/atomic" | ||
|
@@ -225,10 +227,34 @@ func (proxy *ProxyHttpServer) handleHttps(w http.ResponseWriter, r *http.Request | |
} | ||
defer clientConn.Close() | ||
|
||
clientHello, err := sniffer.ReadClientHello() | ||
if err != nil { | ||
ctx.Warnf("Cannot read client hello %s", err) | ||
return | ||
var clientHello []byte | ||
if p, ok := os.LookupEnv("GOPROXY_OVERWRITE_CLIENT_HELLO"); ok { | ||
ch, err := os.ReadFile(p) | ||
if err != nil { | ||
ctx.Warnf("cannot read client hello from file: %s", err) | ||
return | ||
} | ||
clientHello = ch | ||
fmt.Println("overwrote client hello UwU") | ||
} else { | ||
ch, err := sniffer.ReadClientHello() | ||
if err != nil { | ||
ctx.Warnf("cannot read client hello from network: %s", err) | ||
return | ||
} | ||
clientHello = ch | ||
} | ||
|
||
ts := strconv.FormatInt(time.Now().UnixMilli(), 10) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem reliable. Let's use the host from the CONNECT as the filename instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also could be a good idea to guard the folder (each file) with a mutex but not a big deal |
||
if dir, ok := os.LookupEnv("GOPROXY_CLIENT_HELLO_SAVE_DIR"); ok { | ||
os.Mkdir(dir, 0755) // create dir, ignore error | ||
clientHelloPath := path.Join(dir, ts+".bin") | ||
if err := os.WriteFile(clientHelloPath, clientHello, 0660); err != nil { | ||
ctx.Warnf("error writing client hello: %s", err) | ||
return | ||
} | ||
ctx.Logf("Wrote client hello to %s", clientHelloPath) | ||
fmt.Printf("Wrote client hello to %s\n", clientHelloPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundant |
||
} | ||
|
||
clientHelloSpec, err := utlsFingerprinter.FingerprintClientHello(clientHello) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets remove this?