{"id":18644139,"url":"https://github.com/indix/mod_evasive","last_synced_at":"2025-11-05T01:30:36.061Z","repository":{"id":146495280,"uuid":"66901262","full_name":"indix/mod_evasive","owner":"indix","description":"git mirror of mod_evasive apache module from http://www.zdziarski.com/blog/wp-content/uploads/2010/02/mod_evasive_1.10.1.tar.gz","archived":false,"fork":false,"pushed_at":"2016-08-31T10:40:10.000Z","size":56,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T11:20:05.108Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/indix.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-30T03:01:03.000Z","updated_at":"2023-02-16T19:25:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"abd4f4b9-8157-4975-b4b6-565476e5ca39","html_url":"https://github.com/indix/mod_evasive","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indix%2Fmod_evasive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indix%2Fmod_evasive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indix%2Fmod_evasive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indix%2Fmod_evasive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indix","download_url":"https://codeload.github.com/indix/mod_evasive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239449291,"owners_count":19640528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T06:10:10.674Z","updated_at":"2025-11-05T01:30:36.031Z","avatar_url":"https://github.com/indix.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://snap-ci.com/ind9-ops/mod_evasive/branch/master/build_image)](https://snap-ci.com/ind9-ops/mod_evasive/branch/master)\n\n# Apache Evasive Maneuvers Module\n\nFor Apache 1.3, 2.0, and 2.4\n\nCopyright (c) Deep Logic, Inc.\n\nVersion 1.11 [2016.0831]\n\n## LICENSE\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; version 2\nof the License.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n\n## WHAT IS MOD_EVASIVE ?\n\nmod_evasive is an evasive maneuvers module for Apache to provide evasive\naction in the event of an HTTP DoS or DDoS attack or brute force attack.  It \nis also designed to be a detection tool, and can be easily configured to talk \nto ipchains, firewalls, routers, and etcetera.  \n\nDetection is performed by creating an internal dynamic hash table of IP \nAddresses and URIs, and denying any single IP address from any of the following:\n\n- Requesting the same page more than a few times per second\n- Making more than 50 concurrent requests on the same child per second\n- Making any requests while temporarily blacklisted (on a blocking list)\n\nThis method has worked well in both single-server script attacks as well \nas distributed attacks, but just like other evasive tools, is only as \nuseful to the point of bandwidth and processor consumption (e.g. the\namount of bandwidth and processor required to receive/process/respond\nto invalid requests), which is why it's a good idea to integrate this\nwith your firewalls and routers.\n\nThis module instantiates for each listener individually, and therefore has\na built-in cleanup mechanism and scaling capabilities.  Because of this,\nlegitimate requests are rarely ever compromised, only legitimate attacks.  Even\na user repeatedly clicking on 'reload' should not be affected unless they do\nit maliciously.\n\nThree different module sources have been provided:\n\nApache v1.3 API:\tmod_evasive.c\n\nApache v2.0 API:\tmod_evasive20.c\n\nApache v2.4 API:\tmod_evasive24.c\n\nNSAPI (iPlanet):\tmod_evasiveNSAPI.c *\n\nNOTE: mod_evasiveNSAPI is a port submitted by Reine Persson \u003creiper@rsv.se\u003e\n      and is not officially supported as part of the mod_evasive project.\n\n## HOW IT WORKS\n\nA web hit request comes in. The following steps take place:\n\n- The IP address of the requestor is looked up on the temporary blacklist\n- The IP address of the requestor and the URI are both hashed into a \"key\".  \n  A lookup is performed in the listener's internal hash table to determine \n  if the same host has requested this page more than once within the past \n  1 second.  \n- The IP address of the requestor is hashed into a \"key\".\n  A lookup is performed in the listerner's internal hash table to determine\n  if the same host has requested more than 50 objects within the past\n  second (from the same child).\n\nIf any of the above are true, a 403 response is sent.  This conserves\nbandwidth and system resources in the event of a DoS attack.  Additionally,\na system command and/or an email notification can also be triggered to block\nall the originating addresses of a DDoS attack. \n\nOnce a single 403 incident occurs, mod_evasive now blocks the entire IP \naddress for a period of 10 seconds (configurable).  If the host requests a \npage within this period, it is forced to wait even longer.  Since this is \ntriggered from requesting the same URL multiple times per second, this \nagain does not affect legitimate users.\n\nThe blacklist can/should be configured to talk to your network's firewalls \nand/or routers to push the attack out to the front lines, but this is not \nrequired.\n\nmod_evasive also performs syslog reporting using daemon.alert.  Messages\nwill look like this:\n\n```\nAug  6 17:41:49 elijah mod_evasive[23184]: [ID 801097 daemon.alert] Blacklisting address x.x.x.x: possible attack.\n```\n\n## WHAT IS THIS TOOL USEFUL FOR?\n\nThis tool is *excellent* at fending off request-based DoS attacks or scripted\nattacks, and brute force attacks. When integrated with firewalls or IP filters,\nmod_evasive can stand up to even large attacks. Its features will prevent you \nfrom wasting bandwidth or having a few thousand CGI scripts running as a \nresult of an attack.  \n\nIf you do not have an infrastructure capable of fending off any other types\nof DoS attacks, chances are this tool will only help you to the point of\nyour total bandwidth or server capacity for sending 403's.  Without a solid\ninfrastructure and address filtering tool in place, a heavy distributed DoS \nwill most likely still take you offline.  \n\n### HOW TO INSTALL\n\n#### APACHE v1.3\n\nWithout DSO Support:\n\n1. Extract this archive into src/modules in the Apache source tree\n2. Run ./configure --add-module=src/modules/evasive/mod_evasive.c\n3. make, install\n4. Restart Apache \n\nWith DSO Support, Ensim, or CPanel:\n\n1. $APACHE_ROOT/bin/apxs -iac mod_evasive.c\n2. Restart Apache\n\n#### APACHE v2.0\n\n1. Extract this archive\n2. Run $APACHE_ROOT/bin/apxs -i -a -c mod_evasive20.c\n3. The module will be built and installed into $APACHE_ROOT/modules, and loaded into your httpd.conf\n4. Restart Apache\n\n#### APACHE v2.4\n\n1. Extract this archive\n2. Run $APACHE_ROOT/bin/apxs -i -a -c mod_evasive24.c\n3. The module will be built and installed into $APACHE_ROOT/modules, and loaded into your httpd.conf\n4. Restart Apache\n\n#### NSAPI\n##### SunONE (iPlanet,netscape) Installation\n\nTested on:\n\n- iPlanet 4.1sp12\n- iPlanet 6.0sp5\n\nEdit compile script for your environment and compile `mod_evasiveNSAPI.c`\nto a shared library.\n\n### CONFIGURATION\n\nmod_evasive has default options configured, but you may also add the\nfollowing block to your httpd.conf:\n\n#### APACHE v1.3\n\n```\n\u003cIfModule mod_evasive.c\u003e\n    DOSHashTableSize    3097\n    DOSPageCount        2\n    DOSSiteCount        50\n    DOSPageInterval     1\n    DOSSiteInterval     1\n    DOSBlockingPeriod   10\n\u003c/IfModule\u003e\n```\n\n### APACHE v2.0\n```\n\u003cIfModule mod_evasive20.c\u003e\n    DOSHashTableSize    3097\n    DOSPageCount        2\n    DOSSiteCount        50\n    DOSPageInterval     1\n    DOSSiteInterval     1\n    DOSBlockingPeriod   10\n\u003c/IfModule\u003e\n```\n\n### APACHE v2.4\n\n```\n\u003cIfModule mod_evasive24.c\u003e\n    DOSHashTableSize    3097\n    DOSPageCount        2\n    DOSSiteCount        50\n    DOSPageInterval     1\n    DOSSiteInterval     1\n    DOSBlockingPeriod   10\n\u003c/IfModule\u003e\n```\n\nOptionally you can also add the following directives:\n\n\n```\n    DOSEmailNotify\tyou@yourdomain.com\n    DOSSystemCommand\t\"su - someuser -c '/sbin/... %s ...'\"\n    DOSLogDir\t\t\"/var/lock/mod_evasive\"\n```\n\nYou will also need to add this line if you are building with dynamic support:\n\n#### APACHE v1.3\n\n`AddModule\tmod_evasive.c`\n\n#### APACHE v2.0\n\n`LoadModule evasive20_module modules/mod_evasive20.so`\n\n(This line is already added to your configuration by apxs)\n\n#### APACHE v2.4\n\n`LoadModule evasive24_module modules/mod_evasive24.so`\n\n(This line is already added to your configuration by apxs)\n\n### NSAPI\n#### SunONE (iPlanet,Netscape) Configuration\n                                                                                \n#### Configure iPlanet 4.1\n\nEdit obj.conf:\n\n```                                                                                \nInit fn=\"load-modules\" funcs=\"mod_evasive_init,mod_evasive_check\" shlib=\"/opt/ns-4.1/plugins/lib/mod_evasive.sl\"\n\nInit fn=\"mod_evasive_init\" DOSPageCount=2 DOSSiteCount=50 DOSPageInterval=1 DOSSiteInterval=1 DOSBlockingPeriod=10 DOSWhitelist=\"10.60.0.7,10.65.0.10\"\n```\n\nIn the default object:\n\n```\nPathCheck fn=mod_evasive_check\n```\n                                                                                \nOr an own object\n\n```\n\u003cObject name=\"evasive\" ppath=\"/DoSProtectedArea*\"\u003e\nNameTrans fn=mod_evasive_check\n\u003c/Object\u003e\n```\n\n                                                                                \n#### Configure iPlanet 6.0\n                                                                                \nEdit magnus.conf:\n\n```\nInit fn=\"load-modules\" funcs=\"mod_evasive_init,mod_evasive_check\" shlib=\"/opt/iplanet-6.0/plugins/lib/mod_evasive.sl\"\n                                                                                \nInit fn=\"mod_evasive_init\" DOSWhitelist=\"10.60.0.7,10.65.0.10\"\n```\n\nEdit obj.conf:\n\nIn the default object:\n```\nPathCheck fn=mod_evasive_check\n```\n\nOr an own object\n\n```\n\u003cObject name=\"evasive\" ppath=\"/DoSProtectedArea*\"\u003e\nNameTrans fn=mod_evasive_check\n\u003c/Object\u003e\n```\n\n### Module Properties\n\n#### DOSHashTableSize\n\nThe hash table size defines the number of top-level nodes for each child's \nhash table.  Increasing this number will provide faster performance by \ndecreasing the number of iterations required to get to the record, but \nconsume more memory for table space.  You should increase this if you have\na busy web server.  The value you specify will automatically be tiered up to \nthe next prime number in the primes list (see mod_evasive.c for a list \nof primes used).\n\n#### DOSPageCount\n\nThis is the threshhold for the number of requests for the same page (or URI)\nper page interval.  Once the threshhold for that interval has been exceeded,\nthe IP address of the client will be added to the blocking list.\n \n#### DOSSiteCount\n\nThis is the threshhold for the total number of requests for any object by\nthe same client on the same listener per site interval.  Once the threshhold \nfor that interval has been exceeded, the IP address of the client will be added\nto the blocking list.\n\n#### DOSPageInterval\n\nThe interval for the page count threshhold; defaults to 1 second intervals.\n\n#### DOSSiteInterval\n\nThe interval for the site count threshhold; defaults to 1 second intervals.\n\n#### DOSBlockingPeriod\n\nThe blocking period is the amount of time (in seconds) that a client will be\nblocked for if they are added to the blocking list.  During this time, all\nsubsequent requests from the client will result in a 403 (Forbidden) and\nthe timer being reset (e.g. another 10 seconds).  Since the timer is reset\nfor every subsequent request, it is not necessary to have a long blocking\nperiod; in the event of a DoS attack, this timer will keep getting reset. \n\n#### DOSEmailNotify\n\nIf this value is set, an email will be sent to the address specified\nwhenever an IP address becomes blacklisted.  A locking mechanism using /tmp\nprevents continuous emails from being sent.\n\nNOTE: Be sure MAILER is set correctly in mod_evasive.c \n      (or mod_evasive20.c).  The default is \"/bin/mail -t %s\" where %s is \n      used to denote the destination email address set in the configuration.  \n      If you are running on linux or some other operating system with a \n      different type of mailer, you'll need to change this.\n\n#### DOSSystemCommand\n\nIf this value is set, the system command specified will be executed\nwhenever an IP address becomes blacklisted.  This is designed to enable\nsystem calls to ip filter or other tools.  A locking mechanism using /tmp\nprevents continuous system calls.  Use %s to denote the IP address of the\nblacklisted IP.\n\n#### DOSLogDir\n\nChoose an alternative temp directory\n\nBy default \"/tmp\" will be used for locking mechanism, which opens some \nsecurity issues if your system is open to shell users.\n\n  \thttp://security.lss.hr/index.php?page=details\u0026ID=LSS-2005-01-01\n\nIn the event you have nonprivileged shell users, you'll want to create a\ndirectory writable only to the user Apache is running as (usually root),\nthen set this in your httpd.conf.\n\n## WHITELISTING IP ADDRESSES\n\nIP addresses of trusted clients can be whitelisted to insure they are never \ndenied.  The purpose of whitelisting is to protect software, scripts, local \nsearchbots, or other automated tools from being denied for requesting large \namounts of data from the server.  Whitelisting should *not* be used to add \ncustomer lists or anything of the sort, as this will open the server to abuse.\nThis module is very difficult to trigger without performing some type of \nmalicious attack, and for that reason it is more appropriate to allow the \nmodule to decide on its own whether or not an individual customer should be \nblocked.\n\nTo whitelist an address (or range) add an entry to the Apache configuration \nin the following fashion:\n\nDOSWhitelist\t127.0.0.1\nDOSWhitelist\t127.0.0.*\n\nWildcards can be used on up to the last 3 octets if necessary.  Multiple\nDOSWhitelist commands may be used in the configuration.\n\n## TWEAKING APACHE\n\nThe keep-alive settings for your children should be reasonable enough to \nkeep each child up long enough to resist a DOS attack (or at least part of \none).  Remember, it is the child processes that maintain their own internal\nIP address tables, and so when one exits, so does all of the IP information it\nhad. For every child that exits, another 5-10 copies of the page may get \nthrough before putting the attacker back into '403 Land'.  With this said, \nyou should have a very high MaxRequestsPerChild, but not unlimited as this\nwill prevent cleanup.\n\nYou'll want to have a MaxRequestsPerChild set to a non-zero value, as\nDosEvasive cleans up its internal hashes only on exit.  The default\nMaxRequestsPerChild is usually 10000.  This should suffice in only allowing\na few requests per 10000 per child through in the event of an attack (although\nif you use DOSSystemCommand to firewall the IP address, a hole will no\nlonger be open in between child cycles).\n\n## TESTING\n\nWant to make sure it's working? Run test.pl, and view the response codes.\nIt's best to run it several times on the same machine as the web server until\nyou get 403 Forbidden messages. Some larger servers with high child counts \nmay require more of a beating than smaller servers before blacklisting\naddresses. \n\nPlease don't use this script to DoS others without their permission.\n\n## KNOWN BUGS\n\n- This module appears to conflict with the Microsoft Frontpage Extensions.\n  Frontpage sucks anyway, so if you're using Frontpage I assume you're asking\n  for problems, and not really interested in conserving server resources anyway.\n\n## FEEDBACK \n\nPlease email me with questions, constructive comments, or feedback:\n  jonathan@nuclearelephant.com\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findix%2Fmod_evasive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findix%2Fmod_evasive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findix%2Fmod_evasive/lists"}