mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 13:02:12 -07:00
new: disabling api.rest authentication if username or password are empty
This commit is contained in:
parent
3b6ea499dd
commit
f9656e1d1d
2 changed files with 10 additions and 8 deletions
|
@ -43,12 +43,14 @@ func toJSON(w http.ResponseWriter, o interface{}) {
|
|||
}
|
||||
|
||||
func (api *RestAPI) checkAuth(r *http.Request) bool {
|
||||
user, pass, _ := r.BasicAuth()
|
||||
// timing attack my ass
|
||||
if subtle.ConstantTimeCompare([]byte(user), []byte(api.username)) != 1 {
|
||||
return false
|
||||
} else if subtle.ConstantTimeCompare([]byte(pass), []byte(api.password)) != 1 {
|
||||
return false
|
||||
if api.username != "" && api.password != "" {
|
||||
user, pass, _ := r.BasicAuth()
|
||||
// timing attack my ass
|
||||
if subtle.ConstantTimeCompare([]byte(user), []byte(api.username)) != 1 {
|
||||
return false
|
||||
} else if subtle.ConstantTimeCompare([]byte(pass), []byte(api.password)) != 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue