-
Notifications
You must be signed in to change notification settings - Fork 12
/
shell2FA
63 lines (59 loc) · 1.8 KB
/
shell2FA
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# 2FA SSH SHELL LOGIN
#### CONFIGURATION ####
RECALL_SHELL="/bin/bash"
URGENT_KEY="l0g1nplz"
### TELEGRAM CONFIG ###
APIKEY="" # Insert Telegram Bot API KEY here
CHATID="" # Insert Chat ID here
#######################
echo ""
echo " --------------------- "
echo " | 2 F A - S h e l l | "
echo " | L o g i n | "
echo " --------------------- "
echo " Login with $(whoami) [at] $(hostname) "
echo ""
function RandomKey() {
awk 'BEGIN {
srand()
for (i=1;i<=1;i++){
print int(rand() * 1000000)
}
}'
}
KEYCODE=$(RandomKey)
if [[ ! -z $(curl -s "https://api.telegram.org/bot${APIKEY}/sendMessage?chat_id=${CHATID}&parse_mode=Markdown&text=2FA-SHELL+OTP%0A%0D%0A%0D%60HOSTNAME+:%60+*$(hostname)*%0A%0D%60USERNAME+:%60+*$(whoami)*%0A%0D%60OTP+KEY++:%60+*${KEYCODE}*" 2> /dev/null | grep '"ok":true') ]]; then
echo " INFO: OTP Sent!"
for counter in {1..3}
do
echo -ne " Input OTP Key : "
read OTP
if [[ ${OTP} == ${KEYCODE} ]]; then
echo ""
echo " INFO: Login Successfully!"
echo ""
curl -s "https://api.telegram.org/bot${APIKEY}/sendMessage?chat_id=${CHATID}&parse_mode=Markdown&text=2FA-SHELL+ALERT%0A%0D%0A%0D$(whoami)@$(hostname)%0A%0D%0A%0D*LOGIN+SUCCESSFULLY!*" &> /dev/null
${RECALL_SHELL}
exit
else
echo " ERROR: auth-fail (${counter}/3)"
echo ""
fi
done
echo " ERROR: Login attempt failed."
curl -s "https://api.telegram.org/bot${APIKEY}/sendMessage?chat_id=${CHATID}&parse_mode=Markdown&text=2FA-SHELL+ALERT%0A%0D%0A%0D$(whoami)@$(hostname)%0A%0D%0A%0D*LOGIN+FAILED!*" &> /dev/null
exit
else
echo " ERROR: Send OTP code failed."
echo " INFO: You can login with URGENT_KEY"
echo -ne " Input URGENT_KEY : "
read URGENT_INPUT
if [[ ${URGENT_INPUT} == ${URGENT_KEY} ]]; then
${RECALL_SHELL}
exit
else
echo " ERROR: Invalid URGENT_KEY"
exit
fi
fi