Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

75%
+4 −0
Q&A How to automatically block IPs that try exploit URLs?

If these requests are logged into a log file you can install fail2ban and configure it to act on these log entries. You can configure it to block the requests via the local firewall for a duration ...

posted 2mo ago by GeraldS‭  ·  edited 1mo ago by GeraldS‭

Answer
#2: Post edited by user avatar GeraldS‭ · 2024-10-07T11:22:36Z (about 1 month ago)
added example
  • If these requests are logged into a log file you can install `fail2ban` and configure it to act on these log entries. You can configure it to block the requests via the local firewall for a duration of your choosing.
  • If these requests are logged into a log file you can install [`fail2ban`](https://github.com/fail2ban/fail2ban) and configure it to act on these log entries. You can configure it to block the requests via the local firewall for a duration of your choosing.
  • This would be a very basic (and untested) example:
  • You create a service definition `/etc/fail2ban/filter.d/myservice.conf`:
  • ```ini
  • [Definition]
  • failregex = \$\(id>`wget\+http:\/\/\[.+\]\/t\+-O-\+\|\+sh`
  • ```
  • You can test it with the command `fail2ban-regex`:
  • ```
  • fail2ban-regex /var/log/myservice.log /etc/fail2ban/filter.d/myservice.conf
  • ```
  • Then you create a jail that uses this service in `/etc/fail2ban/jail.d/myservice.conf`
  • ```ini
  • # service name
  • [myservice]
  • # turn on /off
  • enabled = true
  • # ports to ban (numeric or text)
  • port = http,https
  • # filter from previous step
  • filter = myservice
  • # file to parse
  • logpath = /var/log/myservice.log
  • # ban rule:
  • # 5 times on 1 minute
  • maxretry = 5
  • findtime = 60
  • # ban on 10 minutes
  • bantime = 600
  • ```
  • This assumes that your service is accessed via regular HTTP/HTTPS ports, those are getting blocked.
#1: Initial revision by user avatar GeraldS‭ · 2024-10-02T13:59:07Z (about 2 months ago)
If these requests are logged into a log file you can install `fail2ban` and configure it to act on these log entries. You can configure it to block the requests via the local firewall for a duration of your choosing.