View difference between Paste ID: umnVetMx and wB9aD4t4
SHOW: | | - or go back to the newest paste.
1
#!/bin/bash
2
##works on bash and zsh
3
##SOME CONFIG##
4
RED="\e[0;31m" ;
5
YEL="\e[0;33m" ;
6
NORM="\e[0m" ;
7
tst=`ifconfig | grep mon | cut -b 1-4`
8
arr_tst=($(echo $tst | tr " " "\n"))
9
10
fun_test() {       ##CHECK THE ERROR STATUS
11
  
12
if [[ $? -eq 0 ]] 
13
	then 
14
		ext="[OK]"
15
	else  
16
		ext="$RED [ERROR] $NORM" 
17
		exit 1
18
fi
19
20
}
21
22
23
fun_start () {
24
echo "Searching monitor Interfaces:"
25
echo -e $YEL
26
if [[ ${#arr_tst[@]} -eq "0" ]]
27
	then
28
		echo "No Monitor mode InterfaceS was found"
29
	else
30
		echo -e "This Monitor mode Interfaces was found:"
31
		#echo ${#arr_tst[@]} TEST INTERFACES NUMBER 
32
		sleep 1		
33
		for r in ${!arr_tst[@]}
34
			do
35-
				echo ${tst[r]}
35+
				echo ${arr_tst[r]}
36
			done
37
	echo "Monitor mode already started 
38
exiting..."
39
	exit 0
40
fi
41
42
echo -e $NORM
43
44
sudo ifconfig wlan0 down &> /dev/null  ##PUT WLAN0 DOWN OPTIONAL
45
 
46
sudo macchanger -r wlan0 &> /dev/null  ## CHANGE MAC WLAN0 OPTIONAL
47
fun_test
48
echo -e "set macchanger wlan0: $ext"
49
50
sudo airmon-ng start wlan0 &> /dev/null  ## START MON MODE ON WLAN0
51
fun_test
52
echo -e "start monitor mode: $ext"
53
54
sudo ifconfig mon0 down &> /dev/null ## PUT MON0 DOWN
55
56
sudo macchanger -r mon0 &> /dev/null ## CHANGE MAC MON0
57
fun_test
58
echo -e "set macchanger mon0: $ext"
59
60
sudo ifconfig mon0 up &> /dev/null  ## PUT MON0 UP 
61
62
}
63
64
65
fun_stop () {
66
67
echo "Stopping Monitor mode Interfaces"
68
if [[ ${#arr_tst[@]} -eq "0" ]]
69
	then
70
		echo "No Monitor mode Interface was found exiting..."
71
		exit 0
72
	else		
73
		for o in ${!arr_tst[@]}
74
			do
75
				sudo airmon-ng stop ${arr_tst[o]} &> /dev/null  ## STOP ALL MON INTERFACES
76
				fun_test
77
				echo -e "Stopping ${arr_tst[o]} : $ext"
78
				sleep 2
79
80
			done
81
	exit 0
82
fi
83
84
}
85
86
fun_usage () {
87
echo -e $YEL
88
	echo -e "[*]If not yet started, make up & running monitor mode Interfaces"
89
	echo -e "USAGE: $0 { start | stop }"
90
	echo 
91
	echo -e "[*] $0 start"
92
	echo -e "[i] Turn mon0 Monitor mode Interface ON"
93
	echo
94
	echo -e "[*] $0 stop"
95
	echo -e "[i] Turn ALL Monitor mode Interfaces OFF"
96
echo -e $NORM
97
exit 0
98
}
99
100
fun_arg () {
101
if [[ $# != "1" ]]
102
	then
103
		echo "need start or stop argument"
104
		fun_usage
105
	else
106
		case $1 in
107
		start) fun_start  ;;
108
		stop) fun_stop  ;;
109
		*) fun_usage ;;
110
		esac	
111
fi
112
}
113
114
115
116
if [ $UID -eq 0 ]   ## CHECK PERMISSION
117
	then
118
		echo
119
	else
120
		gksu
121
fi
122
123
fun_arg $1