Skip to content

Commit

Permalink
[Add] ✨ Support Latest Bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-zklcdc committed May 17, 2024
1 parent 4b98da1 commit 0d56797
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 57 deletions.
18 changes: 0 additions & 18 deletions .devcontainer/supervisor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,6 @@ supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=http://127.0.0.1:9005

[program:xvfb]
priority=0
environment=START_XVFB=true
command=/opt/bin/start-xvfb.sh
autostart=true
autorestart=true

;Logs
redirect_stderr=false
stdout_logfile=/var/log/supervisor/xvfb-stdout.log
stderr_logfile=/var/log/supervisor/xvfb-stderr.log
stdout_logfile_maxbytes=50MB
stderr_logfile_maxbytes=50MB
stdout_logfile_backups=5
stderr_logfile_backups=5
stdout_capture_maxbytes=50MB
stderr_capture_maxbytes=50MB

[program:go-bingai-pass]
command=/app/go-bingai-pass
environment=PORT=45678
Expand Down
2 changes: 1 addition & 1 deletion api/bypass.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func BypassHandler(w http.ResponseWriter, r *http.Request) {
}
}

resp, status, err := binglib.Bypass(bypassServer, strings.Join(reqCookies, "; "), "local-gen-"+hex.NewUUID(), request.IG, "", "", request.T)
resp, status, err := binglib.Bypass(bypassServer, strings.Join(reqCookies, "; "), "local-gen-"+hex.NewUUID(), request.IG, "", "", request.T, r.Host)
if err != nil {
helper.ErrorResult(w, http.StatusInternalServerError, err.Error())
common.Logger.Error("Bypass Error: %v", err)
Expand Down
10 changes: 10 additions & 0 deletions api/challenge.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"adams549659584/go-proxy-bingai/common"
"adams549659584/go-proxy-bingai/common/helper"
"fmt"
"net/http"
Expand Down Expand Up @@ -96,6 +97,15 @@ func ChallengeHandler(w http.ResponseWriter, r *http.Request) {
return
}

if r.URL.Query().Get("h") != "" {
tmpReq := r.URL.Query()
tmpReq.Del("h")
r.URL.RawQuery = tmpReq.Encode()

common.NewSingleHostReverseProxy(common.BING_URL).ServeHTTP(w, r)
return
}

w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Write([]byte(fmt.Sprintf(respChallengeHtml, r.URL.Query().Get("iframeid"))))
}
2 changes: 1 addition & 1 deletion api/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func VerifyHandler(w http.ResponseWriter, r *http.Request) {
iframeid, _ := url.QueryUnescape(queryRaw.Get("iframeid"))
convId, _ := url.QueryUnescape(queryRaw.Get("convId"))
rid, _ := url.QueryUnescape(queryRaw.Get("rid"))
resp, status, err := binglib.Bypass(bypassServer, strings.Join(reqCookies, "; "), iframeid, IG, convId, rid, T)
resp, status, err := binglib.Bypass(bypassServer, strings.Join(reqCookies, "; "), iframeid, IG, convId, rid, T, r.Host)
if err != nil {
helper.ErrorResult(w, http.StatusInternalServerError, err.Error())
common.Logger.Error("VerifyHandler Bypass Error: %v", err)
Expand Down
8 changes: 7 additions & 1 deletion cloudflare/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ const verify = async (request, cookie) => {
'convId': currentUrl.searchParams.get('convId'),
'rid': currentUrl.searchParams.get('rid'),
'T': currentUrl.searchParams.get('T'),
'host': WEB_CONFIG.WORKER_URL.replace("http://", "").replace("https://", ""),
}
const newReq = new Request(bypassServer, {
method: 'POST',
Expand Down Expand Up @@ -531,7 +532,12 @@ export default {
}

if (currentUrl.pathname === '/turing/captcha/challenge') {
return challenge(request);
if (currentUrl.searchParams.get('h') != '') {
let params = currentUrl.searchParams.delete('h');
targetUrl = new URL(BING_ORIGIN + '/turing/captcha/challenge' + params.search);
} else {
return challenge(request);
}
}
if (currentUrl.pathname === '/challenge/verify') {
return verify(request, cookies);
Expand Down
2 changes: 1 addition & 1 deletion common/api/v1/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func getCookie(reqCookie, convId, rid string) (cookie string, err error) {
if err != nil {
return
}
resp, status, err := binglib.Bypass(common.BypassServer, reqCookie, "local-gen-"+hex.NewUUID(), IG, convId, rid, T)
resp, status, err := binglib.Bypass(common.BypassServer, reqCookie, "local-gen-"+hex.NewUUID(), IG, convId, rid, T, "")
if err != nil || status != http.StatusOK {
common.Logger.Error("Bypass Error: %v", err)
return
Expand Down
5 changes: 4 additions & 1 deletion docker/Dockerfile-nightly-with-pass
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /app

USER root

RUN apt-get update && apt-get install -y --no-install-recommends curl
RUN apt-get update && apt-get install -y --no-install-recommends curl supervisor

RUN curl -L https://github.com/Harry-zklcdc/go-proxy-bingai/releases/download/nightly/go-proxy-bingai-linux-amd64.tar.gz -o go-proxy-bingai-linux-amd64.tar.gz && \
tar -zxvf go-proxy-bingai-linux-amd64.tar.gz && \
Expand All @@ -22,6 +22,9 @@ RUN apt-get remove -y curl && \
rm go-proxy-bingai-linux-amd64.tar.gz

COPY docker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
RUN mkdir -p /tmp/edge /var/run/supervisor /var/log/supervisor
RUN chown "${GBP_USER_ID}:${GBP_USER_ID}" /var/run/supervisor /var/log/supervisor
RUN chmod 777 /tmp

USER $GBP_USER

Expand Down
5 changes: 4 additions & 1 deletion docker/Dockerfile-with-pass
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /app

USER root

RUN apt-get update && apt-get install -y --no-install-recommends curl
RUN apt-get update && apt-get install -y --no-install-recommends curl supervisor

RUN curl -L https://github.com/Harry-zklcdc/go-proxy-bingai/releases/latest/download/go-proxy-bingai-linux-amd64.tar.gz -o go-proxy-bingai-linux-amd64.tar.gz && \
tar -zxvf go-proxy-bingai-linux-amd64.tar.gz && \
Expand All @@ -22,6 +22,9 @@ RUN apt-get remove -y curl && \
rm go-proxy-bingai-linux-amd64.tar.gz

COPY docker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
RUN mkdir -p /tmp/edge /var/run/supervisor /var/log/supervisor
RUN chown "${GBP_USER_ID}:${GBP_USER_ID}" /var/run/supervisor /var/log/supervisor
RUN chmod 777 /tmp

USER $GBP_USER

Expand Down
18 changes: 0 additions & 18 deletions docker/supervisor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,6 @@ supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=http://127.0.0.1:9005

[program:xvfb]
priority=0
environment=START_XVFB=true
command=/opt/bin/start-xvfb.sh
autostart=true
autorestart=true

;Logs
redirect_stderr=false
stdout_logfile=/var/log/supervisor/xvfb-stdout.log
stderr_logfile=/var/log/supervisor/xvfb-stderr.log
stdout_logfile_maxbytes=50MB
stderr_logfile_maxbytes=50MB
stdout_logfile_backups=5
stderr_logfile_backups=5
stdout_capture_maxbytes=50MB
stderr_capture_maxbytes=50MB

[program:go-bingai-pass]
command=/app/go-bingai-pass
environment=PORT=45678
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21.4
toolchain go1.21.6

require (
github.com/Harry-zklcdc/bing-lib v1.7.0
github.com/Harry-zklcdc/bing-lib v1.8.0
github.com/Harry-zklcdc/ms-auth v1.1.6
github.com/andybalholm/brotli v1.1.0
github.com/refraction-networking/utls v1.6.6
Expand Down
16 changes: 2 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
github.com/Harry-zklcdc/bing-lib v1.6.8 h1:tbxhSCXTGMJ2OR/0VwE940mqtwJvdPpHeAEOFzEEGBk=
github.com/Harry-zklcdc/bing-lib v1.6.8/go.mod h1:Ruq9Ka/DqdYpKrX0vPUKikH3hn8RDZ8F+rAePRSyKAg=
github.com/Harry-zklcdc/bing-lib v1.7.0 h1:hr2KBp3Ja01hcizP5dDyy+u6DrQLv6/25km7gjpL6s0=
github.com/Harry-zklcdc/bing-lib v1.7.0/go.mod h1:T+A0nJjWv0oDOHq0Z9Jgjw3Ygy1Ct/7cZxwb6n0ToyY=
github.com/Harry-zklcdc/bing-lib v1.8.0 h1:tdkuw9qZkwc07V+Uitic/f1Iipnc/mwph0h+61aOOek=
github.com/Harry-zklcdc/bing-lib v1.8.0/go.mod h1:T+A0nJjWv0oDOHq0Z9Jgjw3Ygy1Ct/7cZxwb6n0ToyY=
github.com/Harry-zklcdc/ms-auth v1.1.6 h1:irdZ+oChYLdhvqUjRmKrKvul34KN1GoeI3RksZ/3Rg0=
github.com/Harry-zklcdc/ms-auth v1.1.6/go.mod h1:eLH5k8V2TyV/yAHb1+OSiCLeCzZfEcVFRfC2hPpmO68=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI=
github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand All @@ -16,19 +12,11 @@ github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/refraction-networking/utls v1.6.4 h1:aeynTroaYn7y+mFtqv8D0bQ4bw0y9nJHneGxJ7lvRDM=
github.com/refraction-networking/utls v1.6.4/go.mod h1:2VL2xfiqgFAZtJKeUTlf+PSYFs3Eu7km0gCtXJ3m8zs=
github.com/refraction-networking/utls v1.6.6 h1:igFsYBUJPYM8Rno9xUuDoM5GQrVEqY4llzEXOkL43Ig=
github.com/refraction-networking/utls v1.6.6/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

0 comments on commit 0d56797

Please sign in to comment.