2025-11-21 18:08:11 +01:00
|
|
|
# Reaction
|
|
|
|
|
|
2025-12-02 12:03:33 +01:00
|
|
|
Reaction est un service qui scan les sorties des fichiers et effectue des actions quand un certain usage est détecté.
|
2025-11-21 18:08:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
apt install ./reaction_2.2.1-1_amd64.deb
|
|
|
|
|
systemctl enable --now reaction@reaction.jsonnet
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
reaction show
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```
|
2025-12-02 12:03:33 +01:00
|
|
|
local bots = [
|
|
|
|
|
"ChatGPT-User",
|
|
|
|
|
"DuckAssistBot",
|
|
|
|
|
"Meta-ExternalFetcher",
|
|
|
|
|
"AI2Bot",
|
|
|
|
|
"Applebot-Extended",
|
|
|
|
|
"Bytespider",
|
|
|
|
|
"CCBot",
|
|
|
|
|
"ClaudeBot",
|
|
|
|
|
"Diffbot",
|
|
|
|
|
"FacebookBot",
|
|
|
|
|
"Google-Extended",
|
|
|
|
|
"GPTBot",
|
|
|
|
|
"Kangaroo Bot",
|
|
|
|
|
"Meta-ExternalAgent",
|
|
|
|
|
"omgili",
|
|
|
|
|
"Timpibot",
|
|
|
|
|
"Webzio-Extended",
|
|
|
|
|
"Amazonbot",
|
|
|
|
|
"Applebot",
|
|
|
|
|
"OAI-SearchBot",
|
|
|
|
|
"PerplexityBot",
|
|
|
|
|
"YouBot",
|
|
|
|
|
"Yandexbot",
|
|
|
|
|
"Baiduspider"
|
|
|
|
|
];
|
|
|
|
|
|
2025-11-21 18:08:11 +01:00
|
|
|
local banFor(time) = {
|
|
|
|
|
ban: {
|
2025-12-02 12:03:33 +01:00
|
|
|
cmd: ['nft', 'add element inet reaction banned_ips { <ip> }'],
|
2025-11-21 18:08:11 +01:00
|
|
|
},
|
|
|
|
|
unban: {
|
2025-12-02 12:03:33 +01:00
|
|
|
cmd: ['nft', 'delete element inet reaction banned_ips { <ip> }'],
|
2025-11-21 18:08:11 +01:00
|
|
|
after: time,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
patterns: {
|
|
|
|
|
ip: {
|
|
|
|
|
type: 'ipv4',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
start: [
|
2025-12-02 12:03:33 +01:00
|
|
|
['nft', |||
|
|
|
|
|
table inet reaction {
|
|
|
|
|
set whitelist_ips {
|
|
|
|
|
type ipv4_addr
|
|
|
|
|
flags interval
|
|
|
|
|
elements = { 192.168.137.0/24 }
|
|
|
|
|
}
|
2025-11-21 18:08:11 +01:00
|
|
|
|
2025-12-02 12:03:33 +01:00
|
|
|
set banned_ips {
|
|
|
|
|
type ipv4_addr
|
|
|
|
|
flags interval
|
|
|
|
|
auto-merge
|
|
|
|
|
}
|
2025-11-21 18:08:11 +01:00
|
|
|
|
2025-12-02 12:03:33 +01:00
|
|
|
chain input {
|
|
|
|
|
type filter hook input priority 0
|
|
|
|
|
ip saddr @whitelist_ips accept
|
|
|
|
|
ip saddr @banned_ips drop
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
||| ],
|
2025-11-21 18:08:11 +01:00
|
|
|
],
|
|
|
|
|
|
|
|
|
|
stop: [
|
2025-12-02 12:03:33 +01:00
|
|
|
['nft', 'delete table inet reaction'],
|
2025-11-21 18:08:11 +01:00
|
|
|
],
|
|
|
|
|
|
|
|
|
|
streams: {
|
|
|
|
|
ssh: {
|
|
|
|
|
cmd: ['journalctl', '-fu', 'ssh.service'],
|
|
|
|
|
filters: {
|
|
|
|
|
failedlogin: {
|
|
|
|
|
regex: [
|
|
|
|
|
@'authentication failure;.*rhost=<ip>',
|
|
|
|
|
@'Failed password for .* from <ip>',
|
2025-12-02 12:03:33 +01:00
|
|
|
@'Connection from <ip> port [0-9]*: invalid format',
|
2025-11-21 18:08:11 +01:00
|
|
|
@'Invalid user .* from <ip>',
|
2025-12-02 12:03:33 +01:00
|
|
|
@'Timeout before authentication for <ip>',
|
2025-11-21 18:08:11 +01:00
|
|
|
],
|
|
|
|
|
retry: 3,
|
|
|
|
|
retryperiod: '6h',
|
|
|
|
|
actions: banFor('96h'),
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-12-02 12:03:33 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
apache: {
|
|
|
|
|
cmd: ['tail', '-n0', '-f', '/var/log/nginx/access.log'],
|
|
|
|
|
filters: {
|
|
|
|
|
aiBots: {
|
|
|
|
|
regex: [
|
|
|
|
|
// User-Agent is the last field
|
|
|
|
|
// Bot's name can be anywhere in the User-Agent
|
|
|
|
|
// (hence the leading and trailing [^"]*
|
|
|
|
|
@'^<ip> .* "[^"]*(%s)[^"]*"$' % std.join('|', bots)
|
|
|
|
|
],
|
|
|
|
|
actions: banFor('30d'),
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-11-21 18:08:11 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
```
|
2025-12-02 08:17:55 +01:00
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
nft list ruleset inet
|
|
|
|
|
```
|