-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWirelessPacketCapture.sh
executable file
·121 lines (100 loc) · 3.57 KB
/
WirelessPacketCapture.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env bash
# get source files
source sources/colors.sh
source sources/errors.sh
source sources/networkpref.sh
source sources/crak.sh
source sources/generic.sh
source sources/shark.sh
clear
# Log logic start
checkLog
# Log logic end
dumpLog "Log for wireless interface start"
# Dependency checking point
echo "=========================="
echo -e "${YELLOW}${STAR}${NRML} Checking for dependencies.. "
sleep 0.5s
aircrackngCheck || ( dumpLog "Aircrack-ng not satisfied" && handleError )
sleep 0.5s
tsharkCheck || ( dumpLog "tShark not satisfied" && handleError )
echo "=========================="
sleep 0.5s
# Checking for wireless interfaces
echo -e "${YELLOW}${STAR}${NRML} Searching for wireless interfaces.."
INTR=$(iw dev | awk '$1=="Interface"{print $2}')
sleep 0.5s
if [[ -n $INTR ]];
then
echo -e "${GREEN}${GOOD}${NRML} Found default interface -- ${INTR}${BLUE}"
read -p "Do you want to use another interface instead?(if yes, enter 'y' and then give valid device mount point) [no]: " RES
echo -e "${NRML}"
if [[ ${RES,,} = 'yes' || ${RES,,} = 'y' ]];
then
echo -e "${BLUE}"
read -p "Enter the new wireless mount point: " INTR
echo -e "${NRML}"
validateWirelessInterface || interfaceError
echo -e "${YELLOW}${STAR}${NRML} New interface given ${INTR}"
else
echo -e "${YELLOW}${STAR}${NRML} Continuing with ${INTR} interface.."
fi
else
echo -e "${RED}${ERR}${NRML} No wireless interface found,"
echo -e "${BLUE}"
read -p "Do u want to add manual wireless interface? (if yes, enter 'y' and then give valid dev mount point) [no]: " RES
if [[ ${RES,,} = 'yes' || ${RES,,} = 'y' ]];
then
read -p "Enter the new wireless mount point: " INTR
echo -e "${NRML}"
validateWirelessInterface || interfaceError
echo -e "${YELLOW}${STAR}${NRML} New interface given ${INTR}"
else
echo -e "${RED}${ERR}${NRML} Unable to find wireless interface, exiting the script.."
echo "=========================="
exit 1
fi
fi
sleep 1s
echo "=========================="
# Configuration point
echo -e "${YELLOW}${STAR}${NRML} Configuring Wireless adapter..."
ip link set ${INTR} down &> /dev/null || handleError
ip link set ${INTR} name wlan0 &> /dev/null || handleError
INTR="wlan0"
ip link set ${INTR} up &> /dev/null || handleError
restartNetwork
echo -e "${GREEN}${GOOD}${NRML} Configuring Wireless adapter done"
echo "=========================="
# Monitor mode point
monitorMode
echo -e "${GREEN}${GOOD}${NRML} New monitor interface has been initialized: ${INTR}"
echo "=========================="
echo -e "${YELLOW}${STAR}${NRML} press 'q' two times to exit airodump screen once you have seen your target"
sleep 10s
# Dumping wifi networks
echo -e "${CYANLIGHT}"
dumpInfo
echo -e "${BLUE}"
read -p "Enter the target BSSID: " BSSID
read -p "Enter the channel of BSSID: " CH
echo -e "${NRML}"
#removeDataFiles
echo -e "${YELLOW}${STAR}${NRML} Target set to ${BSSID}, listening on channel ${CH}.."
sleep 2s
mkdir preauth 2> /dev/null || echo -e "${RED}${ERR}${NRML} Unable to create directory,directory may existed"
mkdir postauth 2> /dev/null || echo -e "${RED}${ERR}${NRML} Unable to create directory, directory may existed"
echo -e "${CYANLIGHT}"
targetSet
echo
echo -e "${YELLOW}${STAR}${NRML} Getting ready to capture packets...."
sleep 2s
# Managed mode point
managedMode
restartNetwork
sleep 20s
# tsharkCheck || echo -e "${RED}${ERR}${NRML} Error in handling packet capture, $(handleError)"
sleep 1s
startTshark && echo -e "${GREEN}${GOOD}${NRML} Successfully captured all packets"
echo "=========================="
dumpLog "Log for wireless interface end"