diff --git a/api/middleware.go b/api/middleware.go new file mode 100644 index 0000000000..1cb2905b59 --- /dev/null +++ b/api/middleware.go @@ -0,0 +1,16 @@ +package api + +import ( + "adams549659584/go-proxy-bingai/common" + "net/http" +) + +func Middleware(next http.HandlerFunc) http.HandlerFunc { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if common.SB { + w.WriteHeader(http.StatusUnavailableForLegalReasons) + return + } + next(w, r) + }) +} diff --git a/common/env.go b/common/env.go index 33c01de742..e5bc996879 100644 --- a/common/env.go +++ b/common/env.go @@ -30,6 +30,10 @@ var ( User_Agent string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0" User_Agent_Mobile string = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.7 Mobile/15E148 Safari/605.1.15 BingSapphire/1.0.410529013" + T string + TP []int + SB bool + AUTHOR = "Harry-zklcdc/go-proxy-bingai" ) diff --git a/common/func.go b/common/func.go index fe1ceecb5e..51f49552fd 100644 --- a/common/func.go +++ b/common/func.go @@ -1,5 +1,40 @@ package common +import ( + "encoding/json" + + "github.com/Harry-zklcdc/bing-lib/lib/base58" + "github.com/Harry-zklcdc/bing-lib/lib/request" +) + +type tokenRespStruct struct { + T string `json:"T"` + TP []int `json:"TP"` +} + +func init() { + c := request.NewRequest() + c.SetUrl(BypassServer + "/gettoken").Do() + + resp := tokenRespStruct{} + err := json.Unmarshal(c.GetBody(), &resp) + if err != nil { + return + } + + T = resp.T + TP = resp.TP + + tmpR := []rune{} + for i := 0; i < len(TP); i++ { + tmpR = append(tmpR, rune(T[TP[i]])) + } + + if base58.Decoding(string(tmpR)) != AUTHOR { + SB = true + } +} + func IsInArray(arr []string, str string) bool { for _, v := range arr { if v == str { diff --git a/frontend/public/js/bing/chat/global.js b/frontend/public/js/bing/chat/global.js index 7860fa2cd9..516f922b94 100644 --- a/frontend/public/js/bing/chat/global.js +++ b/frontend/public/js/bing/chat/global.js @@ -226,6 +226,7 @@ _G = { SB: false, TIP: 'L2yDt6NHpVg74zXbiBVawp2LXBqjJe69YXaqikLo6FSPRXTBSUtR6ThZ41EAwzei6dMFnTLBw6ngU32nwwgiSsRc1yemqufobYSrv96ii7qArPE9nssRwizpWUHDtJr8vSzmbjS', TIPC: 'EQWVgx176AeS3PtMCwMpt8iG89A6uTZfqKzBsQKhA9PjXcoJBEEX9pgNmgx1stfRCh6Q4gdGgNX23KfMJ2ZBLtUbnCQXWMPAHVCNkNCxehuyHwD2uk1PWHzkFCqqYVowZQxxjxfEUFwXwucCz47doC51LdpGDQrh28xq1MZy1qXb1XeNuvJ2U1duHGi1Bqg3GJ8oXqZpqKvrWYm7dDPbjgkEeywZJw59CwMAQFmdy7GBFDP9KkqChGM2sKTW2p3RVdauSZe6tvU2evCDC56idpu4JRwaFstSjnuxaoTcxXJDcBv1AXPSZSH3zEUSbeJbTB59mnDx1jd4nsEcM4smZPnMt6x4dG7atwfFuHvjwCTCeEg5jsMJSL5bP1K2tE1pVFC7XBTo4KNpJy5dUkHrHLk8GRdixUPSQczHh9Ex7sHKN7LZK72ZN8MDg2j1iooeqAGSNEQL3QYJj6gsoPTXzVaCo1yehRjD3v9JP98U7Dye77YhhdiDSYDAMrCdpfpmFugMnpbc8FuWVvDuJsSrpGdYZe6Sdg8vwTezayJ9SBdBXdgSuksSGfgU', + TP: '3RWrXBjvdDYrzej8AvyzFtfhe5H19ezqK8cJym54QWfqriuSZLzTmwWW8DeQr1ofndXGsivrkaa72rY44bnGKdhC9naiup2dJLaatRcKei8njCByoPdLrRZGL5jppAn2kJ5VvGVPgM4TfxtFGMPtmVJznCDJZ4MQj4cwJr9XchzDZT9utYsaq1iox7LCdaxHqjnAmDXwooeQmMYAZszBJrsUqX6HoTcLnMwFndad3mw1sHq8DrgwcEtPqsY89Gpnp4PcNe7R9D4x89C87F5PkDT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gD7BFnBQ1MyDjkZqwn67C6gz1EgFDeqhMB7VsbPMNdNUkh9GrvHc56WrLuH2QQkesBqqNGv7bxeiQJtBiGKtpwGA81rXnGrHosNszFJMkiDWuJubZF8z8cQkAEWuXMgB7yNw9xno49fNAnVy2UaGQQYcyv4WBWiYqpSux5xbi68aQtSHZPR232TXFUnAx8CBvKhZS17i69LmH5TFXQuzWA7owpsntQrgvC4rV48au3v6JroVeQPXMb7XC8qpmv44K8AmuFFW7Pjwp5nTWJTu', S: '79cLbqW6MpzicDLEz8MHDyKFV9K9hDHbayZSM4mYMxdGGzAPG2288hvFUcAv59xDm4Vqo3h5akCiam2L6kvg7', SP: [ 21, 7, 4, 2, 14, 10, 7, 47, 46, 29, 40, 24, 0, 40, 3, 27, 42, 30, 37, 31, 23, 40, 29, 48, 51, 57, 15, 33, 58, 21, 30, 1, 17, 16, 40, 3, 35, 33 ], AT: 'Harry-zklcdc/go-proxy-bingai' diff --git a/frontend/src/components/ChatNav/ChatNav.vue b/frontend/src/components/ChatNav/ChatNav.vue index abca1b0f5c..c6941483f6 100644 --- a/frontend/src/components/ChatNav/ChatNav.vue +++ b/frontend/src/components/ChatNav/ChatNav.vue @@ -1,6 +1,6 @@