Closed momkin closed 4 years ago
The same problem with onion services and Tor Browser: auto refreshing entrance page again and again without access.
I am just having a wild guess and stab in the dark here.
But my assumption based of the fact javascript executes and your webpage still refreshes itself is it could be these javascript functions being the issue.
https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/blob/master/lua/anti_ddos_challenge.lua#L98
Delete the opening and closing functions. like so modify the config to this.
local JavascriptVars_opening = [[
]]
and
--[[
Javascript variable blacklist
]]
local JavascriptVars_closing = [[
]]
Hopefully that could be the issue but without looking myself i can't honnestly tell right now looking forward to anyone else who can shed more light upon this.
sorry no this doesn't change anything. Any idea how to debug it?
Has anybody already verified whether Mac OS and safari works?
It's failing here on iOS:
if cookie_name_encrypted_start_and_end_date_value ~= calculate_signature(remote_addr .. cookie_name_start_date_v
alue .. cookie_name_end_date_value) then --if users authentication encrypted cookie not equal to or matching our expected cookie
they should be giving us
return --return to refresh the page so it tries again
end
I tried encrypt_anti_ddos_cookies = 1 as well but it still fails in that part
OK in iOS Safari the cookie from th XML Request isn't set - no idea why. It's sent but not set.
Same happens on Safari at OS X. I think this is related to the fact that safari is much more strict about setting cookies from XMLHttp requests
This looks like a dead project to me 👎
OK found the issue.
Hint: https://stackoverflow.com/questions/1969232/what-are-allowed-characters-in-cookies
This script sets start time and end time with spaces in the values which safari crazily handles like a list and removed the first whitespace
Mon, 30-Dec-19 22:12:05 GMT gets: Mon,30-Dec-19 22:12:05 GMT
easiest fix is to use unixtime for the start and end date in cookie.
This is the patch to fix the problem:
commit 24defa5e6b6122974520ee48cc0b30beb0156673
Author: Stefan Priebe <s.priebe@profihost.ag>
Date: Mon Dec 30 23:33:57 2019 +0100
anti_ddos_challenge: fix cookie problem under safari - do not use whitepace in cookie values:
https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/issues/11
diff --git a/lua/anti_ddos_challenge.lua b/lua/anti_ddos_challenge.lua
index 0bfee5e..73562bd 100644
--- a/lua/anti_ddos_challenge.lua
+++ b/lua/anti_ddos_challenge.lua
@@ -487,6 +487,7 @@ local function grant_access()
--our start date cookie
local cookie_name_start_date_name = "cookie_" .. cookie_name_start_date
local cookie_name_start_date_value = ngx.var[cookie_name_start_date_name] or ""
+ local cookie_name_start_date_value_unix = tonumber(cookie_name_start_date_value)
--our end date cookie
local cookie_name_end_date_name = "cookie_" .. cookie_name_end_date
local cookie_name_end_date_value = ngx.var[cookie_name_end_date_name] or ""
@@ -506,9 +507,9 @@ local function grant_access()
--ngx.log(ngx.ERR, "x-auth-answer result | "..req_headers[x_auth_header_name]) --output x-auth-answer to log
if req_headers[x_auth_header_name] == JavascriptPuzzleVars_answer then --if the answer header provided by the browser Javascript matches what our Javascript puzzle answer should be
set_cookie1 = challenge.."="..cookie_value.."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --apply our uid cookie incase javascript setting this cookies time stamp correctly has issues
- set_cookie2 = cookie_name_start_date.."="..ngx.cookie_time(currenttime).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --start date cookie
- set_cookie3 = cookie_name_end_date.."="..ngx.cookie_time(currenttime+expire_time).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --end date cookie
- set_cookie4 = cookie_name_encrypted_start_and_end_date.."="..calculate_signature(remote_addr .. ngx.cookie_time(currenttime) .. ngx.cookie_time(currenttime+expire_time) ).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --start and end date combined to unique id
+ set_cookie2 = cookie_name_start_date.."="..currenttime.."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --start date cookie
+ set_cookie3 = cookie_name_end_date.."="..(currenttime+expire_time).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --end date cookie
+ set_cookie4 = cookie_name_encrypted_start_and_end_date.."="..calculate_signature(remote_addr .. currenttime .. (currenttime+expire_time) ).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --start and end date combined to unique id
set_cookies = {set_cookie1 , set_cookie2 , set_cookie3 , set_cookie4}
ngx.header["Access-Control-Allow-Origin"] = "*"
@@ -523,7 +524,7 @@ local function grant_access()
--ngx.log(ngx.ERR, "cookie encrypted combination value | "..cookie_name_encrypted_start_and_end_date_value) --log user provided cookie combined encrypted value
if cookie_name_start_date_value ~= nil and cookie_name_end_date_value ~= nil and cookie_name_encrypted_start_and_end_date_value ~= nil then --if all our cookies exist
- local cookie_name_end_date_value_unix = ngx.parse_http_time(cookie_name_end_date_value) or nil --convert our cookie end date provided by the user into a unix time stamp
+ local cookie_name_end_date_value_unix = tonumber(cookie_name_end_date_value) or nil --convert our cookie end date provided by the user into a unix time stamp
if cookie_name_end_date_value_unix == nil or cookie_name_end_date_value_unix == "" then --if our cookie end date date in unix does not exist
return --return to refresh the page so it tries again
end
@@ -531,7 +532,7 @@ local function grant_access()
--ngx.log(ngx.ERR, "cookie less than current time : " .. cookie_name_end_date_value_unix .. " | " .. currenttime ) --log output the users provided cookie time
return --return to refresh the page so it tries again
end
- if cookie_name_encrypted_start_and_end_date_value ~= calculate_signature(remote_addr .. cookie_name_start_date_value .. cookie_name_end_date_value) then --if users authentication encrypted cookie not equal to or matching our expected cookie they should be giving us
+ if cookie_name_encrypted_start_and_end_date_value ~= calculate_signature(remote_addr .. cookie_name_start_date_value_unix .. cookie_name_end_date_value_unix) then --if users authentication encrypted cookie not equal to or matching our expected cookie they should be giving us
return --return to refresh the page so it tries again
end
end
This is the patch to fix the problem:
commit 24defa5e6b6122974520ee48cc0b30beb0156673 Author: Stefan Priebe <s.priebe@profihost.ag> Date: Mon Dec 30 23:33:57 2019 +0100 anti_ddos_challenge: fix cookie problem under safari - do not use whitepace in cookie values: https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/issues/11 diff --git a/lua/anti_ddos_challenge.lua b/lua/anti_ddos_challenge.lua index 0bfee5e..73562bd 100644 --- a/lua/anti_ddos_challenge.lua +++ b/lua/anti_ddos_challenge.lua @@ -487,6 +487,7 @@ local function grant_access() --our start date cookie local cookie_name_start_date_name = "cookie_" .. cookie_name_start_date local cookie_name_start_date_value = ngx.var[cookie_name_start_date_name] or "" + local cookie_name_start_date_value_unix = tonumber(cookie_name_start_date_value) --our end date cookie local cookie_name_end_date_name = "cookie_" .. cookie_name_end_date local cookie_name_end_date_value = ngx.var[cookie_name_end_date_name] or "" @@ -506,9 +507,9 @@ local function grant_access() --ngx.log(ngx.ERR, "x-auth-answer result | "..req_headers[x_auth_header_name]) --output x-auth-answer to log if req_headers[x_auth_header_name] == JavascriptPuzzleVars_answer then --if the answer header provided by the browser Javascript matches what our Javascript puzzle answer should be set_cookie1 = challenge.."="..cookie_value.."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --apply our uid cookie incase javascript setting this cookies time stamp correctly has issues - set_cookie2 = cookie_name_start_date.."="..ngx.cookie_time(currenttime).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --start date cookie - set_cookie3 = cookie_name_end_date.."="..ngx.cookie_time(currenttime+expire_time).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --end date cookie - set_cookie4 = cookie_name_encrypted_start_and_end_date.."="..calculate_signature(remote_addr .. ngx.cookie_time(currenttime) .. ngx.cookie_time(currenttime+expire_time) ).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --start and end date combined to unique id + set_cookie2 = cookie_name_start_date.."="..currenttime.."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --start date cookie + set_cookie3 = cookie_name_end_date.."="..(currenttime+expire_time).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --end date cookie + set_cookie4 = cookie_name_encrypted_start_and_end_date.."="..calculate_signature(remote_addr .. currenttime .. (currenttime+expire_time) ).."; path=/; expires=" .. ngx.cookie_time(currenttime+expire_time) .. "; Max-Age=" .. expire_time .. ";" --start and end date combined to unique id set_cookies = {set_cookie1 , set_cookie2 , set_cookie3 , set_cookie4} ngx.header["Access-Control-Allow-Origin"] = "*" @@ -523,7 +524,7 @@ local function grant_access() --ngx.log(ngx.ERR, "cookie encrypted combination value | "..cookie_name_encrypted_start_and_end_date_value) --log user provided cookie combined encrypted value if cookie_name_start_date_value ~= nil and cookie_name_end_date_value ~= nil and cookie_name_encrypted_start_and_end_date_value ~= nil then --if all our cookies exist - local cookie_name_end_date_value_unix = ngx.parse_http_time(cookie_name_end_date_value) or nil --convert our cookie end date provided by the user into a unix time stamp + local cookie_name_end_date_value_unix = tonumber(cookie_name_end_date_value) or nil --convert our cookie end date provided by the user into a unix time stamp if cookie_name_end_date_value_unix == nil or cookie_name_end_date_value_unix == "" then --if our cookie end date date in unix does not exist return --return to refresh the page so it tries again end @@ -531,7 +532,7 @@ local function grant_access() --ngx.log(ngx.ERR, "cookie less than current time : " .. cookie_name_end_date_value_unix .. " | " .. currenttime ) --log output the users provided cookie time return --return to refresh the page so it tries again end - if cookie_name_encrypted_start_and_end_date_value ~= calculate_signature(remote_addr .. cookie_name_start_date_value .. cookie_name_end_date_value) then --if users authentication encrypted cookie not equal to or matching our expected cookie they should be giving us + if cookie_name_encrypted_start_and_end_date_value ~= calculate_signature(remote_addr .. cookie_name_start_date_value_unix .. cookie_name_end_date_value_unix) then --if users authentication encrypted cookie not equal to or matching our expected cookie they should be giving us return --return to refresh the page so it tries again end end
Could you please provide me the fixed anti_ddos_challenge.lua file ?
Thank you !
Here's the patch
Please wait a moment while we verify your request
]] .. top_body_ad_slot .. [[
Updated the main repo with your patch https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/commit/90397bcf351819200f364fbce4acf96be63dc68d hopefully that solves the problem and we can mark this issue as resolved :)
Would like to thank those who took the time to look into this and resolve it you are awesome.
I am not a apple or IOS / safari user and this is my first time back at my computer since christmas but i am so thrilled to see it was sorted.
Updated the main repo with your patch 90397bc hopefully that solves the problem and we can mark this issue as resolved :)
Would like to thank those who took the time to look into this and resolve it you are awesome.
I am not a apple or IOS / safari user and this is my first time back at my computer since christmas but i am so thrilled to see it was sorted.
After 5 seconds, the wait does not work, I checked, maybe some kind of bug, but I have not yet found the reason
Whatever you mean but to me my patch works fine
Updated the main repo with your patch 90397bc hopefully that solves the problem and we can mark this issue as resolved :)
Updated the main repo with your patch 90397bc hopefully that solves the problem and we can mark this issue as resolved :)
Would like to thank those who took the time to look into this and resolve it you are awesome.
I am not a apple or IOS / safari user and this is my first time back at my computer since christmas but i am so thrilled to see it was sorted.
Sorry but you didn’t used my patch you commit is broken.
Updated the main repo with your patch 90397bc hopefully that solves the problem and we can mark this issue as resolved :) Would like to thank those who took the time to look into this and resolve it you are awesome. I am not a apple or IOS / safari user and this is my first time back at my computer since christmas but i am so thrilled to see it was sorted.
After 5 seconds, the wait does not work, I checked, maybe some kind of bug, but I have not yet found the reason
Yes repo is currently broken. Use my patch instead.
I put back in the var that seems to be missing hopefully that resolves it.
https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/commit/43693ba2bee5b6f49957b3796c70b05002ab0dae
I put back in the var that seems to be missing hopefully that resolves it.
Hi, once again I found a bug fixed thanks, tell me, do you have an example of recaptcha on Lua? It would also be nice to do
I put back in the var that seems to be missing hopefully that resolves it.
how to make the client wait 5 seconds, but cannot update in the browser itself, when the check is in progress it will refresh the page the stub is gone, how to make it wait for this time exactly and cannot update until the time passes
@Webuser6666 i don't get what you mean - the ajax request is fired after 5s and sets a cookie if result is ok. a reload shows than the correct page. This is expected. What's wrong with it?
I'm a little bit confused the hole stuff stopped working for me since 2020 even in chrome with or without my patch. It endlessly reloads but doesn't set any cookie. Anybody else?
this is a new bug see: https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/issues/12
Since @disaster123 solved this problem i will close this issue as resolved :)
Issue title
Doesn't works on iPhone devices
Issue Description
When accessing a protected website on google chrome browser or safari on iPhone devices the checking your browser screen appears but after 5 sec passes it show the some page again and again it never let you access the website !
Versions:
Nginx config:
Screenshot(s):
[Screenshot(s) for difficult to describe visual issues are mandatory. Post links instead of Inline Images for Screenshots containing Adult material.]
Settings:
Other optional information you want to add other than the above: