Skip to content

Commit f120d50

Browse files
committed
first commit
0 parents  commit f120d50

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Noscript-email
2+
3+
Noscript-email is a shell script that checks fail2ban.log for IPs that tripped the noscript filter. Webserver access logs are searched for these IPs and you are emailed what was accessed as well as the geolocation of the offender.
4+
5+
### Requirements:
6+
fail2ban
7+
geoiplookup
8+
9+
### Notes:
10+
Paths for all binaries are hard coded so check paths for rm, grep, geoiplookup, mail, echo, etc. if you have problems
11+

noscript.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Noscript-email is a shell script that checks fail2ban.log for IPs that tripped the noscript filter. Webserver access logs are searched for these IPs you are emailed what was accessed as well as the geolocation of the offender.
4+
# Paths are all binaries are hard coded so check paths for rm, grep, geoiplookup, mail, echo, etc. if you have problems
5+
6+
### User variables start
7+
8+
# Set your web server log location here:
9+
log=/var/log/nginx/access
10+
11+
# Set your email address here:
12+
13+
14+
### User variables end
15+
16+
# prep
17+
/bin/rm /tmp/noscript.txt 2>/dev/null
18+
19+
# checks each IP, writes what they accessed and their geolocation to /tmp/noscript.txt
20+
for i in $(/bin/grep noscript /var/log/fail2ban.log | /bin/grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | /usr/bin/uniq); do /bin/grep $i $log* >> /tmp/noscript.txt && /bin/echo >> /tmp/noscript.txt && /bin/echo "$i - $(/usr/bin/geoiplookup $i)" >> /tmp/noscript.txt && /bin/echo "---------" >> /tmp/noscript.txt; done
21+
22+
# mail results - edit to reflect your email address
23+
/bin/cat /tmp/noscript.txt | /usr/bin/mail -s "No-script bans - $(date)" $email
24+
25+
# cleanup
26+
/bin/rm /tmp/noscript.txt 2>/dev/null

0 commit comments

Comments
 (0)