Your IP has been banned from the server.
+Tú IP ha sido baneada del servidor.
+diff --git a/lib/crowdsec.lua b/lib/crowdsec.lua index fa89e09..a071523 100644 --- a/lib/crowdsec.lua +++ b/lib/crowdsec.lua @@ -138,7 +138,7 @@ end function csmod.validateCaptcha(captcha_res, remote_ip) - return captcha.Validate(captcha_res, remote_ip) + return captcha.ValidateMCaptcha(captcha_res, remote_ip) end diff --git a/lib/plugins/crowdsec/captcha.lua b/lib/plugins/crowdsec/captcha.lua index 36c867b..a0b6cec 100644 --- a/lib/plugins/crowdsec/captcha.lua +++ b/lib/plugins/crowdsec/captcha.lua @@ -9,16 +9,19 @@ local captcha_backend_url = {} captcha_backend_url["recaptcha"] = "https://www.recaptcha.net/recaptcha/api/siteverify" captcha_backend_url["hcaptcha"] = "https://hcaptcha.com/siteverify" captcha_backend_url["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/siteverify" +captcha_backend_url["mcaptcha"] = "https://mcaptcha.nadeko.net/api/v1/pow/siteverify" local captcha_frontend_js = {} captcha_frontend_js["recaptcha"] = "https://www.recaptcha.net/recaptcha/api.js" captcha_frontend_js["hcaptcha"] = "https://js.hcaptcha.com/1/api.js" captcha_frontend_js["turnstile"] = "https://challenges.cloudflare.com/turnstile/v0/api.js" +captcha_frontend_js["mcaptcha"] = "https://unpkg.com/@mcaptcha/vanilla-glue@0.1.0-rc2/dist/index.js" local captcha_frontend_key = {} captcha_frontend_key["recaptcha"] = "g-recaptcha" captcha_frontend_key["hcaptcha"] = "h-captcha" captcha_frontend_key["turnstile"] = "cf-turnstile" +captcha_frontend_key["mcaptcha"] = "m-captcha" M.SecretKey = "" M.SiteKey = "" @@ -112,5 +115,39 @@ function M.Validate(captcha_res, remote_ip) return result.success, nil end +function M.ValidateMCaptcha(captcha_res, remote_ip) + local body = { + token = captcha_res, + key = M.SiteKey, + secret = M.SecretKey + } + + local data = cjson.encode(body) + local httpc = http.new() + httpc:set_timeout(2000) + local res, err = httpc:request_uri(captcha_backend_url[M.CaptchaProvider], { + method = "POST", + body = data, + headers = { + ["Content-Type"] = "application/json", + }, + }) + httpc:close() + if err ~= nil then + return true, err + end + + local result = cjson.decode(res.body) + + if result.error and result.error == "Account not found" then + ngx.log(ngx.ERR, "siteKey is not valid") + return true, nil + elseif result.error and result.error == "Wrong password" then + ngx.log(ngx.ERR, "secretKey is not valid") + return true, nil + end + + return result.valid, nil +end return M diff --git a/templates/ban.html b/templates/ban.html index 7c13af1..dfabd04 100644 --- a/templates/ban.html +++ b/templates/ban.html @@ -1,96 +1,99 @@ -
-You are unable to visit the website.
-- This security check has been powered by -
- - - - CrowdSec - - -Your IP has been banned from the server.
+Tú IP ha sido baneada del servidor.
+- This security check has been powered by -
- - - - CrowdSec - - -(This will not leave any cookies in your browser)
+(Esto no dejará ninguna cookie en tu navegador)
+ + +