-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathf2b-dump.sh
executable file
·41 lines (33 loc) · 1.26 KB
/
f2b-dump.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
# Temporary file to hold the Fail2Ban configuration details
temp_file=$(mktemp)
# Function to add content to the temporary file
add_content() {
# shellcheck disable=SC2129
echo -e "\n$1\n" >>"$temp_file"
cat "$2" >>"$temp_file" 2>/dev/null
echo -e "\n" >>"$temp_file"
}
# List all active jails
echo "Listing all active jails:" >>"$temp_file"
fail2ban-client status >>"$temp_file"
# Get status for each jail
jails=$(fail2ban-client status | grep 'Jail list:' | sed -E 's/^[^:]+:\s+//;s/,//g')
for jail in $jails; do
echo -e "\nStatus of $jail jail:\n" >>"$temp_file"
fail2ban-client status "$jail" >>"$temp_file"
done
# Global configurations
add_content "Global Fail2Ban Configuration (/etc/fail2ban/jail.conf):" "/etc/fail2ban/jail.conf"
add_content "Custom Global Configuration (/etc/fail2ban/jail.local):" "/etc/fail2ban/jail.local"
# Custom jail configurations in jail.d/
echo "Custom Jail Configurations in /etc/fail2ban/jail.d/:" >>"$temp_file"
for config_file in /etc/fail2ban/jail.d/*; do
[ -e "$config_file" ] || continue
add_content "Custom Jail Configuration ($config_file):" "$config_file"
done
# Upload to termbin
echo "Uploading to Termbin..." >>"$temp_file"
nc termbin.com 9999 <"$temp_file"
# Cleanup
rm "$temp_file"