mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2025-01-03 04:50:11 +00:00
add method validation
This commit is contained in:
parent
2fd2503dd5
commit
72d5770d18
@ -37,6 +37,11 @@ func Start() {
|
|||||||
|
|
||||||
util.Debug("Client sent data: ", len(message))
|
util.Debug("Client sent data: ", len(message))
|
||||||
|
|
||||||
|
method := util.ExtractMethod(&message)
|
||||||
|
if !util.IsValidMethod(method) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
domain := util.ExtractDomain(&message)
|
domain := util.ExtractDomain(&message)
|
||||||
|
|
||||||
ip, err := util.DnsLookupOverHttps(config.GetConfig().DNS, domain) // Dns lookup over https
|
ip, err := util.DnsLookupOverHttps(config.GetConfig().DNS, domain) // Dns lookup over https
|
||||||
|
46
util/util.go
46
util/util.go
@ -7,6 +7,50 @@ import (
|
|||||||
"github.com/xvzc/SpoofDPI/config"
|
"github.com/xvzc/SpoofDPI/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var validMethod = map[string]struct{}{
|
||||||
|
"DELETE": {},
|
||||||
|
"GET": {},
|
||||||
|
"HEAD": {},
|
||||||
|
"POST": {},
|
||||||
|
"PUT": {},
|
||||||
|
"CONNECT": {},
|
||||||
|
"OPTIONS": {},
|
||||||
|
"TRACE": {},
|
||||||
|
"COPY": {},
|
||||||
|
"LOCK": {},
|
||||||
|
"MKCOL": {},
|
||||||
|
"MOVE": {},
|
||||||
|
"PROPFIND": {},
|
||||||
|
"PROPPATCH": {},
|
||||||
|
"SEARCH": {},
|
||||||
|
"UNLOCK": {},
|
||||||
|
"BIND": {},
|
||||||
|
"REBIND": {},
|
||||||
|
"UNBIND": {},
|
||||||
|
"ACL": {},
|
||||||
|
"REPORT": {},
|
||||||
|
"MKACTIVITY": {},
|
||||||
|
"CHECKOUT": {},
|
||||||
|
"MERGE": {},
|
||||||
|
"M-SEARCH": {},
|
||||||
|
"NOTIFY": {},
|
||||||
|
"SUBSCRIBE": {},
|
||||||
|
"UNSUBSCRIBE": {},
|
||||||
|
"PATCH": {},
|
||||||
|
"PURGE": {},
|
||||||
|
"MKCALENDAR": {},
|
||||||
|
"LINK": {},
|
||||||
|
"UNLINK": {},
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsValidMethod(name string) bool {
|
||||||
|
if _, exists := validMethod[name]; exists {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func ExtractDomain(message *[]byte) string {
|
func ExtractDomain(message *[]byte) string {
|
||||||
i := 0
|
i := 0
|
||||||
for ; i < len(*message); i++ {
|
for ; i < len(*message); i++ {
|
||||||
@ -32,7 +76,7 @@ func ExtractDomain(message *[]byte) string {
|
|||||||
|
|
||||||
domain := strings.Split(string((*message)[i:j]), ":")[0]
|
domain := strings.Split(string((*message)[i:j]), ":")[0]
|
||||||
|
|
||||||
return strings.TrimSpace(domain)
|
return strings.ToUpper(strings.TrimSpace(domain))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExtractMethod(message *[]byte) string {
|
func ExtractMethod(message *[]byte) string {
|
||||||
|
Loading…
Reference in New Issue
Block a user