Skip to content

Commit 2bca85c

Browse files
author
Joris Vandermeersch
committed
Release 2.3.0
2 parents 9df0197 + cf074bd commit 2bca85c

27 files changed

+349
-57
lines changed

CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Version 2.3.0
2+
-----------
3+
4+
[20240728] WebReusAbuse + jvdmr: Bugfix: segfault on empty config
5+
6+
[20240728] jvdmr: Bugfix: count initialisation in apache 2.0 and windows apache 2.4
7+
8+
[20240728] jvdmr: Add DOSWhitelistUri config option for Windows [EXPERIMENTAL/UNTESTED]
9+
110
Version 2.2.0
211
-----------
312

Dockerfile

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
1-
FROM jvdmr/apache-dev:latest
1+
FROM jvdmr/apache-dev:latest AS build
22
MAINTAINER @jvdmr
33

4-
EXPOSE 80
5-
64
ADD . /opt/jvdmr/apache2/mod_evasive
75
WORKDIR /opt/jvdmr/apache2/mod_evasive
86

97
RUN mv mod_evasive24.c mod_evasive.c && \
108
/usr/bin/apxs -i -a -c -l pcre2-8 mod_evasive.c && \
119
apache2ctl configtest
1210

13-
RUN cp mod_evasive.conf /etc/apache2/conf-enabled/mod_evasive.conf
14-
RUN cp test/sites.conf /etc/apache2/sites-enabled/sites.conf
11+
CMD bash
12+
13+
14+
FROM debian:stable AS test
15+
16+
EXPOSE 80
17+
18+
WORKDIR /opt/jvdmr/apache2/mod_evasive
19+
20+
ARG test_path test/00_regular_config
1521

22+
RUN apt-get update
23+
RUN apt-get -y install apache2
24+
25+
COPY --from=build /usr/lib/apache2/modules/mod_evasive.so /usr/lib/apache2/modules/mod_evasive.so
26+
COPY --from=build /etc/apache2/mods-available/evasive.load /etc/apache2/mods-available/evasive.load
27+
28+
RUN mkdir -p /opt/jvdmr/apache2/mod_evasive
29+
COPY ${test_path}/www /opt/jvdmr/apache2/mod_evasive/www
30+
COPY ${test_path}/etc/mod_evasive.conf /etc/apache2/conf-enabled/mod_evasive.conf
31+
COPY ${test_path}/etc/sites.conf /etc/apache2/sites-enabled/sites.conf
32+
33+
RUN a2enmod evasive
1634
CMD service apache2 start && bash
35+
36+
37+
FROM jvdmr/apache-dev:latest AS package
38+
39+
WORKDIR /opt/jvdmr/apache2/mod_evasive
40+
41+
COPY --from=build /usr/lib/apache2/modules/mod_evasive.so /usr/lib/apache2/modules/mod_evasive.so
42+
COPY mod_evasive.conf /etc/apache2/conf-enabled/mod_evasive.conf
43+
COPY debian-build.sh debian-build.sh
44+
45+
CMD bash

README.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ it maliciously.
5050

5151
Five different module sources have been provided:
5252

53-
* Apache v1.3 API: mod_evasive13.c (outdated)
54-
* Apache v2.0 API: mod_evasive20.c
5553
* Apache v2.4 API: mod_evasive24.c
5654
* Apache v2.4 API (windows): mod_evasive24win.c
55+
* Apache v2.0 API: mod_evasive20.c
56+
* Apache v1.3 API: mod_evasive13.c (outdated)
5757
* NSAPI (iPlanet): mod_evasiveNSAPI.c
5858

5959
NOTE: mod_evasiveNSAPI is a port submitted by Reine Persson <[email protected]>
60-
and is not officially supported as part of the mod_evasive project.
60+
and is not officially supported as part of the mod_evasive project.
6161

6262
# How it works
6363

@@ -170,24 +170,24 @@ following block to your httpd.conf:
170170
## Apache (1.3/2.0/2.4)
171171
```
172172
<IfModule mod_evasive.c>
173-
DOSEnabled true
174-
DOSHashTableSize 3097
175-
DOSPageCount 2
176-
DOSSiteCount 50
177-
DOSPageInterval 1
178-
DOSSiteInterval 1
179-
DOSBlockingPeriod 10
173+
DOSEnabled true
174+
DOSHashTableSize 3097
175+
DOSPageCount 2
176+
DOSSiteCount 50
177+
DOSPageInterval 1
178+
DOSSiteInterval 1
179+
DOSBlockingPeriod 10
180180
</IfModule>
181181
```
182182

183183
Optionally you can also add the following directives:
184184

185185
```
186186
   DOSEmailNotify [email protected]
187-
DOSSystemCommand "su - someuser -c '/sbin/... %s ...'"
188-
DOSLogDir "/var/lock/mod_evasive"
189-
DOSWhitelist 127.0.0.1
190-
DOSWhitelistUri whitelist.*regex
187+
DOSSystemCommand "su - someuser -c '/sbin/... %s ...'"
188+
DOSLogDir "/var/lock/mod_evasive"
189+
DOSWhitelist 127.0.0.1
190+
DOSWhitelistUri whitelist.*regex
191191
   DOSHTTPStatus 429
192192
```
193193

@@ -209,13 +209,13 @@ LoadModule evasive_module modules/mod_evasive.so
209209

210210
## NSAPI
211211
SunONE (iPlanet,Netscape) Configuration
212-
212+
213213
### Configure iPlanet 4.1
214214

215215
Edit obj.conf:
216216
```
217217
Init fn="load-modules" funcs="mod_evasive_init,mod_evasive_check" shlib="/opt/ns-4.1/plugins/lib/mod_evasive.sl"
218-
218+
219219
Init fn="mod_evasive_init" DOSPageCount=2 DOSSiteCount=50 DOSPageInterval=1 DOSSiteInterval=1 DOSBlockingPeriod=10 DOSWhitelist="10.60.0.7,10.65.0.10"
220220
```
221221

@@ -236,7 +236,7 @@ NameTrans fn=mod_evasive_check
236236
Edit magnus.conf:
237237
```                                                                                
238238
Init fn="load-modules" funcs="mod_evasive_init,mod_evasive_check" shlib="/opt/iplanet-6.0/plugins/lib/mod_evasive.sl"
239-
239+
240240
Init fn="mod_evasive_init" DOSWhitelist="10.60.0.7,10.65.0.10"
241241
```
242242

@@ -325,7 +325,7 @@ Choose an alternative temp directory
325325
By default "/tmp" will be used for locking mechanism, which opens some
326326
security issues if your system is open to shell users.
327327
328-
http://security.lss.hr/index.php?page=details&ID=LSS-2005-01-01
328+
http://security.lss.hr/index.php?page=details&ID=LSS-2005-01-01
329329
330330
In the event you have nonprivileged shell users, you'll want to create a
331331
directory writable only to the user Apache is running as (usually root),
@@ -353,8 +353,8 @@ blocked.
353353
To whitelist an address (or range) add an entry to the Apache configuration
354354
in the following fashion:
355355
356-
DOSWhitelist 127.0.0.1
357-
DOSWhitelist 127.0.0.*
356+
DOSWhitelist 127.0.0.1
357+
DOSWhitelist 127.0.0.*
358358
359359
Wildcards can be used on up to the last 3 octets if necessary. Multiple
360360
DOSWhitelist commands may be used in the configuration.
@@ -372,14 +372,18 @@ Use with caution.
372372
To whitelist a URI add an entry to the Apache configuration
373373
in the following fashion:
374374
375-
DOSWhitelistUri /path/to/whitelisted/resource
376-
DOSWhitelistUri .*whitelisted.*
375+
DOSWhitelistUri /path/to/whitelisted/resource
376+
DOSWhitelistUri .*whitelisted.*
377377
378378
`DOSWhitelistUri` supports perl-style regex and matches the whole request URI
379379
(everything between the domain name and the ?) against this regex.
380380
381381
You can add several entries.
382382
383+
> [!CAUTION]
384+
> This is currently UNTESTED on Windows, I'm not sure it will even compile. Let
385+
> me know about any issues, or even if it does work as expected! :pray:
386+
383387
# Tweaking Apache
384388
385389
The keep-alive settings for your children should be reasonable enough to
@@ -411,8 +415,8 @@ Please don't use this script to DoS others without their permission.
411415
# Known bugs and Issues
412416
413417
- This module appears to conflict with the Microsoft Frontpage Extensions.
414-
Frontpage sucks anyway, so if you're using Frontpage I assume you're asking
415-
for problems, and not really interested in conserving server resources anyway.
418+
Frontpage sucks anyway, so if you're using Frontpage I assume you're asking
419+
for problems, and not really interested in conserving server resources anyway.
416420
417421
- When used together with mod_rewrite, mod_rewrite seems to take priority over
418422
this. This means that Apache will always rewrite the url even during an
@@ -421,6 +425,9 @@ Please don't use this script to DoS others without their permission.
421425
https, the redirect to https will always happen. In this case you should
422426
enable mod_evasive on the https virtualhost only, as it will not have any
423427
effect on the http virtualhost.
428+
429+
- Using mpm_itk instead of the default mpm_event will cause mod_evasive to never
430+
get triggered.
424431
425432
# Feedback
426433

dist/libapache2-mod-evasive.deb

-616 Bytes
Binary file not shown.
Binary file not shown.

docker-build.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
#!/bin/bash
22

3-
docker build . -t mod_evasive || exit 1
4-
docker run -t -d -p 1980:80 mod_evasive
5-
./test/test.pl
6-
docker ps -a | grep mod_evasive | awk -F " +" '{print $7}' | xargs docker stop
7-
docker run -t -v `pwd`/dist:/opt/jvdmr/apache2/mod_evasive/dist mod_evasive bash debian-build.sh
3+
for tp in test/*
4+
do
5+
echo
6+
echo "Building test container"
7+
docker build . --target test --build-arg "test_path=${tp}" -t mod_evasive_test || exit 1
8+
echo "Starting test container"
9+
docker run --rm -t --name=mod_evasive_test -d -p 1980:80 mod_evasive_test
10+
echo "Running test"
11+
${tp}/test.sh
12+
echo "Stopping test container"
13+
docker kill mod_evasive_test
14+
done
15+
16+
echo
17+
echo "Building packaging container"
18+
docker build . --target package -t mod_evasive_package || exit 1
19+
echo "Packaging mod for Debian"
20+
docker run --rm -t --name=mod_evasive_package -v `pwd`/dist:/opt/jvdmr/apache2/mod_evasive/dist mod_evasive_package bash debian-build.sh
21+
echo "Done."

mod_evasive20.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,13 @@ int is_whitelisted(const char *ip, evasive_config *cfg) {
322322

323323
static apr_status_t destroy_config(void *dconfig) {
324324
evasive_config *cfg = (evasive_config *) dconfig;
325-
ntt_destroy(cfg->hit_list);
326-
free(cfg->email_notify);
327-
free(cfg->log_dir);
328-
free(cfg->system_command);
329-
free(cfg);
325+
if (cfg != NULL) {
326+
ntt_destroy(cfg->hit_list);
327+
free(cfg->email_notify);
328+
free(cfg->log_dir);
329+
free(cfg->system_command);
330+
free(cfg);
331+
}
330332
return APR_SUCCESS;
331333
}
332334

@@ -446,7 +448,7 @@ struct ntt_node *ntt_insert(struct ntt *ntt, const char *key, time_t timestamp)
446448
/* Create a new node */
447449
new_node = ntt_node_create(key);
448450
new_node->timestamp = timestamp;
449-
new_node->timestamp = 0;
451+
new_node->count = 0;
450452

451453
ntt->items++;
452454

mod_evasive24.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ int is_uri_whitelisted(const char *path, evasive_config *cfg) {
421421
static apr_status_t destroy_config(void *dconfig) {
422422
evasive_config *cfg = (evasive_config *) dconfig;
423423
if (cfg != NULL) {
424-
ntt_destroy(cfg->hit_list);
425-
free(cfg->email_notify);
426-
free(cfg->log_dir);
427-
free(cfg->system_command);
428-
free(cfg);
424+
ntt_destroy(cfg->hit_list);
425+
free(cfg->email_notify);
426+
free(cfg->log_dir);
427+
free(cfg->system_command);
428+
free(cfg);
429429
}
430430
return APR_SUCCESS;
431431
}

0 commit comments

Comments
 (0)