8000 feat: save&overwrite client hello by clouedoc · Pull Request #2 · saucesteals/goproxy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions https.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"net/http"
"net/url"
"os"
"path"
"strconv"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove this?

} 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)
Copy link
Owner

Choose a reason for hiding this comment

The 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

Copy link
Owner

Choose a reason for hiding this comment

The 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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant

}

clientHelloSpec, err := utlsFingerprinter.FingerprintClientHello(clientHello)
Expand Down
0