Commit Graph

36 Commits

Author SHA1 Message Date
C0nw0nk
379814c399 Update anti_ddos_challenge.lua
Added Feature : Custom setting for master_switch, For those who use this script and are large server hosts or host allot of websites from their machine(s) this will allow you to setup this script in your Nginx `http {` block to run for all sites on your service then you can set it to custom hosts to protect specific websites only such as Tor websites.

For example setting `master_switch = 3` will make it so all websites / domain names you do not specify in the list will never see the authentication page while those you do specifiy in the list will be required to solve our authentication page puzzle in order to get access. Highly useful for protecting Tor services / backends on hosts with normal services running too.

This way if you host a domain like ".onion" they will be required to solve auth pages to get access while everything not specified like ".com" or specific domain names visitors will never see the auth page.
2020-02-20 17:35:16 +00:00
C0nw0nk
4417a6da16 Update anti_ddos_challenge.lua
Added Feature : Allow our randomly generated Javascript vars to be configurable and dynamic or static depending on user prefrence.

Fix bug : Tor users I forgot to check if Tor users solved our Mathematical puzzle now it checks that they have solved the puzzle before granting them access.

Fix bug : When generating random Javascript variables there was a chance for duplicate outputs / collisions with Javascript vars making Javascript not work whilst the odds for those collisions / duplicates was very very small it was something that maybe one request in a million could have been stuck with a broken javascript page so to prevent that ever happening I keep track of generated vars and prevent duplicates.
2020-02-18 19:54:23 +00:00
C0nw0nk
d7a133a553 Update anti_ddos_challenge.lua
Added Feature : 
A new Javascript encryption / Obfuscation method i built to my list of others inside my function, This will take Javascript encrypt it as a base64 string, Split it up into chunks randomize those chunks then output it. Just like a deck of cards you can shuffle the stack and allow the code to run still regardless of the order the deck would come out as.

Fix : 
Added defer and async ability to my Hexdecimal encryption when I Built the encryption function originaly in development I added it to the rest and forgot that one.
2020-02-10 20:50:10 +00:00
C0nw0nk
3563ed21f0 Update anti_ddos_challenge.lua
Added Feature to detect Tor users
Added Feature to block or allow Tor users (Allowing Tor users will still require for them to go through the authentication process the same as everyone else so don't worry)
Added Feature to encrypt Tor headers making them as Dynamic as possible
Added Feature to encrypt Tor cookies making them as Dynamic as possible
Added Tor Javascript Checks

Fixed unwanted collision bug between header x_auth_header_name when encrypted it was not unique so I made it unique to avoid any clashes in the future.
2020-02-05 15:55:21 +00:00
C0nw0nk
6087320fd7 Update anti_ddos_challenge.lua
Add feature to automatically detect if website we are serving traffic for is a Tor network website via the .onion domain extension and switch our compatibility to accomadate for Tor clients.
2020-02-02 18:55:54 +00:00
C0nw0nk
515a5d9be7 Update anti_ddos_challenge.lua
Change default from Dynamic GET and POST to just POST requests with XMLHttpRequest object the reason being is to avoid unwanted conflicts with caches on proxy servers / services (Cloudflare proxy being a prime culprit of this).
2020-02-01 15:38:33 +00:00
C0nw0nk
34444a013c Update anti_ddos_challenge.lua
Add feature to automatically get the connecting Clients IP Address without needing to manually set it in the config, I decided to make this for compatibility with every service connecting to your server. It can now work with Cloudflare, Proxies, Tor Direct connections etc simultaneously.
2020-02-01 11:56:32 +00:00
C0nw0nk
22406ba15b Update anti_ddos_challenge.lua
Fix output for remote_addr on Authentication page in HTML, If you change the variable `local remote_addr =` in your settings / setup / config at the start of the script the output on the auth page where it should say `IP Address` would be what you set the `remote_addr` as so to fix it and ensure it stays as an IP Address not User-Agent etc I manualy set it back with logical operators.
2020-01-31 21:15:55 +00:00
C0nw0nk
113f1dacae Update anti_ddos_challenge.lua
For services behind Cloudflares proxy service ensure our javascript runs without "Rocket Loader".

https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-specific-JavaScripts-

And for Tor users this seems to be an error they will see with it that should fix it. Making the Script elements run independently from Cloudflares script.

Request to access cookie or storage on “https://ajax.cloudflare.com/cdn-cgi/scripts/*/cloudflare-static/rocket-loader.min.js” was blocked because we are blocking all third-party storage access requests and content blocking is enabled
2020-01-31 20:13:24 +00:00
C0nw0nk
e570b1ed57 Update anti_ddos_challenge.lua
Fix for Javascript refreshing the page before the browser has a chance to set the cookies in response.

Fix to stop Firefox browsers message "firefox prevented this page from automatically reloading"

Remove un-used junk code.
2020-01-27 16:53:26 +00:00
C0nw0nk
20d6640a27 Update anti_ddos_challenge.lua
Remove junk javascript code.

Change the timer text element to inform the user to refresh their page incase their browser blocks it. (Firefox is a prime culprit of this "firefox prevented this page from automatically reloading")
2020-01-26 18:46:15 +00:00
Stefan Priebe
99d3d5fc82 remove unneeded Access-Control-Allow-Origin headers - this is never cross domain
correctly use vars expected_header_status and authentication_page_status_output
simplify and faster exit in case of ajax request
default authentication_page_status_output status to 503 otherwise google and other crawlers index this page
2020-01-07 07:45:09 +01:00
Stefan Priebe
30987f8b7a JavascriptPuzzleVars stopped working since 2020 as JS calcs 20200104 + 04012020 into 21253816
To fix number calculation with leading zeros:
* use parseInt
* explicit pass of a string
* define base of 10
2020-01-06 07:00:06 +01:00
C0nw0nk
43693ba2be Update anti_ddos_challenge.lua
Reinstate variable that originaly was there but got accidently removed in last patch.
2020-01-04 12:13:35 +00:00
C0nw0nk
90397bcf35 Update anti_ddos_challenge.lua
Applied user contributed patch to fix IOS issues with cookies a big thank you to those who contributed here.

https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/issues/11#issuecomment-569816246
2020-01-03 22:13:09 +00:00
C0nw0nk
defe93fdee Update anti_ddos_challenge.lua
Add feature to allow disabling of my credits as much as credit to be recieved is nice i do understand and realise people do not want to display them on their sites hence why i made it a feature to allow you to remove them easily and swiftly. :)
2019-11-15 19:51:51 +00:00
C0nw0nk
942915ae8a Update anti_ddos_challenge.lua
Add Enable/disable script this feature allows you to turn on or off this script so you can leave this file in your nginx configuration permamently.

This way you don't have to remove `access_by_lua_file anti_ddos_challenge.lua;` to stop protecting your websites :) you can set up your nginx config and use this feature to enable or disable protection.
2019-11-15 18:32:04 +00:00
C0nw0nk
3b13adaa12 Update anti_ddos_challenge.lua
Fix typo of value "charset" with "default_charset"
2019-11-15 18:12:22 +00:00
C0nw0nk
ac52cb4dff Update anti_ddos_challenge.lua
Make charset customisable value for those who wish to translate this script into their own native languages.

https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/issues/8
2019-11-15 18:09:55 +00:00
C0nw0nk
4e5060ef41 Update anti_ddos_challenge.lua
Update to fix hex encode in Javascript encryption so that it no longer requires Nginx Lua's ngx_devel_kit
2019-11-12 21:48:59 +00:00
C0nw0nk
f13998a56e Update anti_ddos_challenge.lua 2019-11-11 19:26:59 +00:00
C0nw0nk
499bc58631 Update anti_ddos_challenge.lua
Added new features of an IP Address Whitelist and Blacklist to permamently grant access or deny access to specific users of your site.
2019-09-14 22:56:08 +01:00
C0nw0nk
974e711ea6 Update anti_ddos_challenge.lua
Add a HTML page refresh feature incase Javascript one does not work.
2019-09-12 20:12:26 +01:00
C0nw0nk
3713e335ba Update anti_ddos_challenge.lua
Remove un-needed Javascript from my development stages where i planned Javascript based header response checks all not needed.

Change Javascript page refresh method from `window.location.reload();` to `location.reload(true);` as the Mozilla docs tell us we should be reloading pages this way. https://developer.mozilla.org/en-US/docs/Web/API/Location/reload
2019-09-12 19:52:49 +01:00
C0nw0nk
2d9a6da90d Update anti_ddos_challenge.lua
Remove un-needed Javascript code that causes browser issues.
2019-09-12 18:07:17 +01:00
C0nw0nk
a32a819b73 Update anti_ddos_challenge.lua
Fix Nginx Lua Bug with ngx.header["Set-Cookie"] function for some reason it only allows one instance of this header to be defined in a script. So to fix the issue I define the header once and only once in the entire script right at the end and set a variable that can be dynamic in setting multiple cookies.
2019-09-12 18:03:00 +01:00
C0nw0nk
447534b611 Update anti_ddos_challenge.lua
Add cors headers and include XMLHTTPREQUEST with credentials tag and remove domain tag from set-cookie to fix issue with Google Chrome. Still broken in Microsoft Edge !?
2019-08-28 01:17:53 +01:00
C0nw0nk
f2133a8307 Update anti_ddos_challenge.lua
Fix for set-cookie works in Firefox browser now Chrome, Microsoft edge still don't seem to work...!?
2019-08-28 00:18:59 +01:00
C0nw0nk
a7d388d02a Update anti_ddos_challenge.lua
Added Feature built in my method to encrypt and obfuscate Javascript outputs. (I am very proud of this!)

Bug fix: incase certain browsers lack in permissions to set cookies with javascript on the initital header request we will give them their cookie they still need javascript enabled to solve the authentication puzzle that will always be mandatory!

Added X-Requested-* headers for the next feature i am building in
2019-08-27 18:07:49 +01:00
C0nw0nk
124381ad79 Update anti_ddos_challenge.lua
Move current time variable out of configuration area.

Create currentdate variable to stop calling os.date() and os.time() multiple un-needed times.

Fix bug now the auth page only shows when the expire_time config value is set and around the time before if you had set a time greater than one day every 24 hours you would recieve the auth page even if your cookies are valid this expire_time checks solves that problem.
2019-08-26 21:29:25 +01:00
C0nw0nk
2e2a5e58a5 Update anti_ddos_challenge.lua
Add new security feature to make the cookies we set encrypted, unpredictable, dynamic and unique to each user/client to increase our security from content scrappers bots leechers etc. Where as before they could monitor static cookie names this prevents that.
2019-08-26 19:05:38 +01:00
C0nw0nk
655b82f49c Update anti_ddos_challenge.lua
Improve security on header making it unique to each individual client/user that visits the website.
2019-08-25 23:50:50 +01:00
C0nw0nk
1596b5c177 Update anti_ddos_challenge.lua
Add new security feature to make the header we sent our Javascript answer from the browser over unpredictable and dynamic to increase our security from content scrappers bots leechers etc.
2019-08-25 22:47:17 +01:00
C0nw0nk
f51662eda7 Update anti_ddos_challenge.lua
Remove Search Engines from the Browsers Javascript Checking (This will allow search engines to crawl still like Google because they can execute Javascript)
2019-08-25 21:22:49 +01:00
C0nw0nk
cabdbaa093 Update anti_ddos_challenge.lua
Fix expire_time description to show correct default time of 1 day.

Fix cookie bug when Javascript was setting a cookie it was setting a cookie of 'now' instead of the set config of expire_time into the future when the cookie should expire.

Added the challenge cookie to the headers set by grant_access function to update the cookie set by Javascript since the time stamp on the cookie would be out of sync with the other cookies otherwise this was all cookies will be updated and set/kept with the same time stamps.
2019-08-25 21:00:22 +01:00
C0nw0nk
72cce0223d Create anti_ddos_challenge.lua
For those who love my script feel free to drop me a thank you! :)
2019-08-22 13:18:53 +01:00