-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimitssh-ip
More file actions
46 lines (38 loc) · 1.36 KB
/
limitssh-ip
File metadata and controls
46 lines (38 loc) · 1.36 KB
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
42
43
44
45
46
#!/bin/bash
function send_log() {
CHATID=$(grep -E "^#bot# " "/etc/bot/.bot.db" | cut -d ' ' -f 3)
KEY=$(grep -E "^#bot# " "/etc/bot/.bot.db" | cut -d ' ' -f 2)
TIME="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
TEXT="
<code>────────────────────</code>
<b>⚠️ NOTIFICATIONS MULTI LOGIN SSH⚠️</b>
<code>────────────────────</code>
<code>Username : </code><code>$user</code>
<code>Limit IP : </code><code>${iplimit}</code>
<code>User Login : </code><code>${cekcek}</code>
<code>Akun Locked : </code><code>15 Menit</code>
<code>────────────────────</code>
"
curl -s --max-time $TIME -d "chat_id=$CHATID&disable_web_page_preview=1&text=$TEXT&parse_mode=html" $URL >/dev/null
}
clear
mulog=$(cekssh)
date=$(date)
data=( `ls /etc/kyt/limit/ssh/ip`)
for user in "${data[@]}"
do
iplimit=$(cat /etc/kyt/limit/ssh/ip/$user)
cekcek=$(echo -e "$mulog" | grep $user | wc -l)
if [[ $cekcek -gt $iplimit ]]; then
nais=3
passwd -l "$user" > /dev/null
send_log
# Jadwalkan untuk membuka kembali akun setelah 15 menit
echo "passwd -u $user" | at now + 15 minutes > /dev/null
else
echo > /dev/null
fi
sleep 0.1
done
echo > /dev/null