This repository was archived by the owner on Oct 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathcardmon.zsh
More file actions
executable file
·80 lines (68 loc) · 1.45 KB
/
Copy pathcardmon.zsh
File metadata and controls
executable file
·80 lines (68 loc) · 1.45 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
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
#!/usr/bin/zsh
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
blue=`tput setaf 4`
magenta=`tput setaf 5`
grey=`tput setaf 8`
reset=`tput sgr0`
bold=`tput bold`
underline=`tput smul`
print_good(){
echo "${green}[+]${reset}" $1
}
print_error(){
echo "${red}[x]${reset}" $1
}
print_info(){
echo "[*]" $1
}
print_usage(){
echo "Usage: cardmon.sh [-h] IFACE [on|off] [CHANNEL]"
}
while getopts "h" opt; do
case "$opt" in
h)
print_usage
exit 0
;;
esac
done
iface=$1
state=$2
channel=$3
if [ "$#" -eq 0 ]; then
print_error "Specify interface"
exit 0
fi
if [[ "`iwconfig`" =~ .*$iface.* ]]; then
:
else
print_error "No such interface: $iface"
exit 0
fi
if [ "$#" -eq "1" ]; then #Fix this length
iwconfig_out=`iwconfig $iface`
if [[ "$iwconfig_out" =~ .*Monitor.* ]]; then
print_info "Monitor mode is ${green}ENABLED${reset} on $iface"
else
print_info "Monitor mode is ${red}DISABLED${reset} on $iface"
fi
elif [ "$#" -eq "2" ]; then
ifconfig $iface down
if [ "$state" == "on" ]; then
iwconfig $iface mode monitor
print_info "Started monitor mode on $iface"
elif [ "$state" == "off" ]; then
iwconfig wlp3s0 mode managed
print_info "Started managed mode on $iface"
else
print_error "No such state (use [on|off])"
fi
ifconfig $iface up
elif [ "$#" -eq "3" ]; then
ifconfig $iface down
iw dev $iface set channel $channel
ifconfig $iface up
print_info "Set channel of $iface to $channel"
fi