-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapsmanqr
executable file
·104 lines (89 loc) · 2.31 KB
/
capsmanqr
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
# Made by Sinfallas <sinfallas@yahoo.com>
# Licence: GPL-2
LC_ALL=C
SECONDS=0
LOCKFILE="/tmp/$(basename $0)_$(whoami)"
archi="/app/claves.txt"
source /usr/bin/mtkvariables
function clean_1() {
rm -f /tmp/$(basename $0)_$(whoami)
rm -f /run/$(basename $0).pid
}
echo "$BASHPID" > /run/$(basename $0).pid
trap "clean_1; exit" 0 1 2 3 9 15
lock || exit_error
if [[ -z "$suser" ]]; then
ayuda
fi
if [[ -z "$cfrom" ]]; then
ayuda
fi
if [[ -z "$cserver" ]]; then
ayuda
fi
if [[ -z "$cport" ]]; then
ayuda
fi
if [[ -z "$cuser" ]]; then
ayuda
fi
if [[ -z "$cpass" ]]; then
ayuda
fi
if [[ -z "$cdestinos" ]]; then
ayuda
fi
if [[ -z "$nssid" ]]; then
ayuda
fi
if [[ -z "$ips" ]]; then
ayuda
fi
if [[ -z "$sshport" ]]; then
ayuda
fi
if [[ -z "$sshpass" ]]; then
ayuda
fi
mkdir -p "$donde"/qr
clear
for i in ${ips[@]}; do
ping -A -c 5 $i > /dev/null
if [[ $? = 0 ]]; then
echo "IP: $i"
echo "IP: $i" >> "$archi"
clave=$(dd if=/dev/urandom bs=1 count=64 2>/dev/null | base64 -w 0 | tr -dc _A-Z-a-z-0-9 | cut -c 1-8)
echo "Clave: $clave"
echo "Clave: $clave" >> "$archi"
echo "=========================" >> "$archi"
$qre "WIFI:T:WPA;S:$nssid;P:$clave;;" -o "$donde"/qr/"$i".png
queversion
else
echo "ERROR: $i no esta disponible."
continue
fi
if [[ "$forcecaps" == "1" ]]; then
wcmd="caps"
fi
if [[ "$wcmd" == "caps" ]]; then
if [[ "$sshport" == "22" ]]; then
sshpass -p $sshpass $cssh $suser@$i "caps-man security set "$nssid" passphrase="$clave""
else
sshpass -p $sshpass $cssh -p $sshport $suser@$i "caps-man security set "$nssid" passphrase="$clave""
fi
else
if [[ "$sshport" == "22" ]]; then
sshpass -p $sshpass $cssh $suser@$i "interface wifi security set "$nssid" passphrase="$clave""
else
sshpass -p $sshpass $cssh -p $sshport $suser@$i "interface wifi security set "$nssid" passphrase="$clave""
fi
fi
done
echo "comprimiendo"
$ctar "$donde"/qr-"$fecha".tar.gz "$donde"/qr/
echo "correo"
$cmdcorreo --header "Subject: Cambio de clave de SSID el %DATE%" --body "Se cambiaron las claves del SSID, se adjunta el archivo." --attach-type "text/plain" --attach-name "claves.txt" --attach @/app/claves.txt --attach-type "application/x-compressed-tar" --attach-name "qr-$fecha.tar.gz" --attach @/app/qr-$fecha.tar.gz
echo "duracion $SECONDS segundos"
echo "Finalizado."
exit 0