-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.sh
43 lines (36 loc) · 905 Bytes
/
login.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
42
#!/bin/bash
#Login en bash para userland
#Elaborado por JP Rojas
Exit=$(ps | grep bash | cut -d'p' -f1 )
password_local=$(cat /home/.password | base64 -d | cut -f1)
user=$(whoami | cut -f1)
function login {
clear
neofetch
echo -e "\033[1;33mNota: Cantidad de intentos disponibles 10"
echo -e "\033[1;33mNota: su o su root para superusuario!"
echo -e "\033[1;37m"
for _ in {1..10} ; do
read -sp "ingrese su password: " pass
echo ""
pass=$(echo $pass | shasum -a 512 | cut -f1)
if [ "$pass" = "$password_local" ] ; then
echo "acceso consedido!"
pass=""
exit
else
echo "password incorrecta!"
fi
done
clear
echo "Saliendo de userland!"
sleep 1
kill -9 $Exit
}
function main {
trap "clear && echo 'Opcion invalida!' && sleep 1 && kill -9 $Exit" 2 20
if [ "$user" != 'root' ] ; then
login
fi
}
main