为cloudflareCookies增加基本的合法性验证
This commit is contained in:
parent
1d6cca7a9e
commit
f305d8f55c
@ -5,6 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -275,7 +277,22 @@ func (cp *commonPage) terminal(c *gin.Context) {
|
|||||||
}, true)
|
}, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cloudflareCookies, _ := c.Cookie("CF_Authorization")
|
cloudflareCookies, _ := c.Cookie("CF_Authorization")
|
||||||
|
// CloudflareCookies合法性验证
|
||||||
|
// 其应该包含.分隔的三组BASE64-URL编码
|
||||||
|
if cloudflareCookies != "" {
|
||||||
|
encodedCookies := strings.Split(cloudflareCookies, ".")
|
||||||
|
if len(encodedCookies) == 3 {
|
||||||
|
for i := 0; i < 3; i++ {
|
||||||
|
if valid, _ := regexp.MatchString("^[A-Za-z0-9-_]+$", encodedCookies[i]); !valid {
|
||||||
|
cloudflareCookies = ""
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cloudflareCookies = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
terminalData, _ := utils.Json.Marshal(&model.TerminalTask{
|
terminalData, _ := utils.Json.Marshal(&model.TerminalTask{
|
||||||
Host: terminal.host,
|
Host: terminal.host,
|
||||||
UseSSL: terminal.useSSL,
|
UseSSL: terminal.useSSL,
|
||||||
|
Loading…
Reference in New Issue
Block a user